Skip to content

[build-script] Use the build-script-impl from the swift repo that invoked build-script. #8439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions utils/SwiftBuildSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ def _get_default_source_root():
"SWIFT_BUILD_ROOT", os.path.join(SWIFT_SOURCE_ROOT, "build"))


def _get_default_swift_repo_name():
result = ""

# Are we in a Swift checkout? Start from this file and check its parent
# directories.
#
# $SWIFT_SOURCE_ROOT/$SWIFT_REPO_NAME/utils/SwiftBuildSupport.py
(swift_path, parent_dirname) = os.path.split(os.path.dirname(__file__))
if parent_dirname != "utils":
return result
if not os.path.exists(os.path.join(swift_path, 'CMakeLists.txt')):
return result
return swift_path

# Set SWIFT_REPO_NAME in your environment to control the name of the swift
# directory name that is used.
SWIFT_REPO_NAME = os.environ.get(
"SWIFT_REPO_NAME", _get_default_swift_repo_name())


def _load_preset_files_impl(preset_file_names, substitutions={}):
config = ConfigParser.SafeConfigParser(substitutions, allow_no_value=True)
if config.read(preset_file_names) == []:
Expand Down
6 changes: 4 additions & 2 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sys.path.append(os.path.dirname(__file__))
from SwiftBuildSupport import (
HOME,
SWIFT_BUILD_ROOT,
SWIFT_REPO_NAME,
SWIFT_SOURCE_ROOT,
get_all_preset_names,
get_preset_options,
Expand All @@ -54,7 +55,7 @@ import swift_build_support.workspace # noqa (E402)


build_script_impl = os.path.join(
SWIFT_SOURCE_ROOT, "swift", "utils", "build-script-impl")
SWIFT_SOURCE_ROOT, SWIFT_REPO_NAME, "utils", "build-script-impl")


def exit_rejecting_arguments(message, parser=None):
Expand Down Expand Up @@ -1096,7 +1097,8 @@ def main_preset():
args.preset_file_names = [
os.path.join(HOME, ".swift-build-presets"),
os.path.join(
SWIFT_SOURCE_ROOT, "swift", "utils", "build-presets.ini")
SWIFT_SOURCE_ROOT, SWIFT_REPO_NAME, "utils",
"build-presets.ini")
]

if args.show_presets:
Expand Down
Empty file modified utils/python_lint.py
100644 → 100755
Empty file.