Skip to content

Commit d717f8f

Browse files
committed
[build-script] Set INSTALL_PREFIX in Python
Rather than setting a default value for the INSTALL_PREFIX in the build-script-impl shellscript, do so in the Python build-script. A small step towards achieving SR-237.
1 parent 3b61ad3 commit d717f8f

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

utils/build-script

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@ also build for Apple watchos, but disallow tests that require an watchOS device"
532532
name of the directory under $SWIFT_BUILD_ROOT where the build products will be
533533
placed""",
534534
metavar="PATH")
535+
parser.add_argument("--install-prefix",
536+
help="The installation prefix. This is where built Swift products "
537+
"(like bin, lib, and include) will be installed.",
538+
metavar="PATH",
539+
default=swift_build_support.targets.install_prefix())
535540

536541
parser.add_argument("-j", "--jobs",
537542
help="""
@@ -566,6 +571,7 @@ the number of parallel build jobs to use""",
566571
'--host-target',
567572
'--skip-build',
568573
'--show-sdks',
574+
'--install-prefix',
569575
]))
570576

571577
if args.host_target is None:
@@ -830,6 +836,7 @@ the number of parallel build jobs to use""",
830836
build_script_impl_args = [
831837
os.path.join(SWIFT_SOURCE_ROOT, "swift", "utils", "build-script-impl"),
832838
"--build-dir", build_dir,
839+
"--install-prefix", os.path.abspath(args.install_prefix),
833840
"--host-target", args.host_target,
834841
"--host-cc", host_clang.cc,
835842
"--host-cxx", host_clang.cxx,

utils/build-script-impl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,6 @@ function true_false() {
718718
# Set default values for command-line parameters.
719719
#
720720

721-
if [[ "${INSTALL_PREFIX}" == "" ]] ; then
722-
if [[ "$(uname -s)" == "Darwin" ]] ; then
723-
INSTALL_PREFIX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr"
724-
else
725-
INSTALL_PREFIX="/usr"
726-
fi
727-
fi
728-
729721
if [[ "$(uname -s)" == "Darwin" ]] ; then
730722
TOOLCHAIN_PREFIX=$(echo ${INSTALL_PREFIX} | sed -E 's/\/usr$//')
731723
fi

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ def host_target():
4444
return 'freebsd-x86_64'
4545

4646
return None
47+
48+
49+
def install_prefix():
50+
"""
51+
Returns the default path at which built Swift products (like bin, lib,
52+
and include) will be installed, based on the host machine's operating
53+
system.
54+
"""
55+
if platform.system() == 'Darwin':
56+
return '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr'
57+
else:
58+
return '/usr'

0 commit comments

Comments
 (0)