Skip to content

Commit 3821e6e

Browse files
committed
[build-script] Set TOOLCHAIN_PREFIX in Python
Rather than setting the path to the .xctoolchain in the build-script-impl shellscript, do so in the Python build-script. A small step towards achieving SR-237.
1 parent d717f8f commit 3821e6e

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

utils/build-script

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from __future__ import print_function
1414
import argparse
1515
import multiprocessing
1616
import os
17+
import platform
1718
import shutil
1819
import sys
1920
import textwrap
@@ -761,6 +762,12 @@ the number of parallel build jobs to use""",
761762
"--skip-build-benchmarks",
762763
]
763764

765+
if platform.system() == 'Darwin':
766+
build_script_impl_inferred_args += [
767+
"--toolchain-prefix",
768+
swift_build_support.targets.darwin_toolchain_prefix(args.install_prefix),
769+
]
770+
764771
if args.build_subdir is None:
765772
# Create a name for the build directory.
766773
args.build_subdir = args.cmake_generator.replace(" ", "_")

utils/build-script-impl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ KNOWN_SETTINGS=(
8686
cmake-generator "Unix Makefiles" "kind of build system to generate; see output of 'cmake --help' for choices"
8787
verbose-build "" "print the commands executed during the build"
8888
install-prefix "" "installation prefix"
89+
toolchain-prefix "" "the path to the .xctoolchain directory that houses the install prefix path"
8990
install-destdir "" "the path to use as the filesystem root for the installation"
9091
install-symroot "" "the path to install debug symbols into"
9192
swift-install-components "" "a semicolon-separated list of Swift components to install"
@@ -714,15 +715,6 @@ function true_false() {
714715
esac
715716
}
716717

717-
#
718-
# Set default values for command-line parameters.
719-
#
720-
721-
if [[ "$(uname -s)" == "Darwin" ]] ; then
722-
TOOLCHAIN_PREFIX=$(echo ${INSTALL_PREFIX} | sed -E 's/\/usr$//')
723-
fi
724-
725-
726718
# A list of deployment targets to cross-compile the Swift host tools for.
727719
# We can't run the resulting binaries on the build machine.
728720
CROSS_TOOLS_DEPLOYMENT_TARGETS=()

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# See http://swift.org/LICENSE.txt for license information
99
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010

11+
import os
1112
import platform
1213

1314

@@ -56,3 +57,12 @@ def install_prefix():
5657
return '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr'
5758
else:
5859
return '/usr'
60+
61+
62+
def darwin_toolchain_prefix(darwin_install_prefix):
63+
"""
64+
Given the install prefix for a Darwin system, and assuming that that path
65+
is to a .xctoolchain directory, return the path to the .xctoolchain
66+
directory.
67+
"""
68+
return os.path.split(darwin_install_prefix)[0]

0 commit comments

Comments
 (0)