Skip to content

[build-script] Respect TOOLCHAINS environment variable (5.0 branch) #14285

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
7 changes: 4 additions & 3 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ if config.test_exec_root is None:
# name: The name of this test suite.
config.name = 'Swift(%s)' % config.variant_suffix[1:]

# Tweak the environment appropriately for various platforms.
# Respect the TOOLCHAINS environment variable when deciding the xcrun
# toolchain for Darwin platforms.
if platform.system() == 'Darwin':
# Prefer the latest version of the Xcode tools.
config.environment['TOOLCHAINS'] = 'default'
config.environment['TOOLCHAINS'] = \
os.environ.get('TOOLCHAINS', config.darwin_xcrun_toolchain)

# testFormat: The test format to use to interpret tests.
config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode)
Expand Down
8 changes: 8 additions & 0 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import platform
import sys
import time

from build_swift import defaults
from build_swift import driver_arguments

from swift_build_support.swift_build_support import (
Expand Down Expand Up @@ -1041,6 +1042,13 @@ def main_normal():
shell.dry_run = args.dry_run

# Prepare and validate toolchain
if args.darwin_xcrun_toolchain is None:
xcrun_toolchain = os.environ.get('TOOLCHAINS',
defaults.DARWIN_XCRUN_TOOLCHAIN)

diagnostics.note('Using toolchain {}'.format(xcrun_toolchain))
args.darwin_xcrun_toolchain = xcrun_toolchain

toolchain = host_toolchain(xcrun_toolchain=args.darwin_xcrun_toolchain)
os.environ['TOOLCHAINS'] = args.darwin_xcrun_toolchain

Expand Down
1 change: 0 additions & 1 deletion utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ def create_argument_parser():
help='the number of parallel build jobs to use')

option('--darwin-xcrun-toolchain', store,
default=defaults.DARWIN_XCRUN_TOOLCHAIN,
help='the name of the toolchain to use on Darwin')
option('--cmake', store_path(executable=True),
help='the path to a CMake executable that will be used to build '
Expand Down
3 changes: 1 addition & 2 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
defaults.DARWIN_DEPLOYMENT_VERSION_TVOS,
'darwin_deployment_version_watchos':
defaults.DARWIN_DEPLOYMENT_VERSION_WATCHOS,
'darwin_xcrun_toolchain':
defaults.DARWIN_XCRUN_TOOLCHAIN,
'darwin_xcrun_toolchain': None,
'distcc': False,
'dry_run': False,
'enable_asan': False,
Expand Down