Skip to content

Commit ea92fb7

Browse files
authored
[build-script] Respect TOOLCHAINS environment variable (#14202) (#14285)
* Respect the TOOLCHAINS environment variable if set when deciding the darwin xcrun toolchain. * Updated test/lit.cfg to respect the TOOLCHAINS environment variable when deciding the xcrun toolchain for Darwin platforms, rather than hardcoding the default. * Fixed the default darwin xcrun toolchain logic. (cherry picked from commit a436044)
1 parent 6bb3ac3 commit ea92fb7

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

test/lit.cfg

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ if config.test_exec_root is None:
152152
# name: The name of this test suite.
153153
config.name = 'Swift(%s)' % config.variant_suffix[1:]
154154

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

160161
# testFormat: The test format to use to interpret tests.
161162
config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode)

utils/build-script

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import platform
1818
import sys
1919
import time
2020

21+
from build_swift import defaults
2122
from build_swift import driver_arguments
2223

2324
from swift_build_support.swift_build_support import (
@@ -1041,6 +1042,13 @@ def main_normal():
10411042
shell.dry_run = args.dry_run
10421043

10431044
# Prepare and validate toolchain
1045+
if args.darwin_xcrun_toolchain is None:
1046+
xcrun_toolchain = os.environ.get('TOOLCHAINS',
1047+
defaults.DARWIN_XCRUN_TOOLCHAIN)
1048+
1049+
diagnostics.note('Using toolchain {}'.format(xcrun_toolchain))
1050+
args.darwin_xcrun_toolchain = xcrun_toolchain
1051+
10441052
toolchain = host_toolchain(xcrun_toolchain=args.darwin_xcrun_toolchain)
10451053
os.environ['TOOLCHAINS'] = args.darwin_xcrun_toolchain
10461054

utils/build_swift/driver_arguments.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ def create_argument_parser():
314314
help='the number of parallel build jobs to use')
315315

316316
option('--darwin-xcrun-toolchain', store,
317-
default=defaults.DARWIN_XCRUN_TOOLCHAIN,
318317
help='the name of the toolchain to use on Darwin')
319318
option('--cmake', store_path(executable=True),
320319
help='the path to a CMake executable that will be used to build '

utils/build_swift/tests/expected_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@
107107
defaults.DARWIN_DEPLOYMENT_VERSION_TVOS,
108108
'darwin_deployment_version_watchos':
109109
defaults.DARWIN_DEPLOYMENT_VERSION_WATCHOS,
110-
'darwin_xcrun_toolchain':
111-
defaults.DARWIN_XCRUN_TOOLCHAIN,
110+
'darwin_xcrun_toolchain': None,
112111
'distcc': False,
113112
'dry_run': False,
114113
'enable_asan': False,

0 commit comments

Comments
 (0)