Skip to content

Commit ec55f4b

Browse files
committed
[build] Add a flag that allows disabling appending the host target's name to the install-destdir for a cross-compiled toolchain
This is useful if you're cross-compiling the toolchain for a single host and don't want your specified install path modified.
1 parent 11a1611 commit ec55f4b

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

utils/build-script-impl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ KNOWN_SETTINGS=(
246246
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
247247
cross-compile-install-prefixes "" "semicolon-separated list of install prefixes to use for the cross-compiled hosts. The list expands, so if there are more cross-compile hosts than prefixes, unmatched hosts use the last prefix in the list"
248248
cross-compile-deps-path "" "path for CMake to look for cross-compiled library dependencies, such as libXML2"
249+
cross-compile-append-host-target-to-destdir "1" "turns on appending the host target name of each cross-compiled toolchain to its install-destdir, to keep them separate from the natively-built toolchain"
249250
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
250251
coverage-db "" "If set, coverage database to use when prioritizing testing"
251252
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
@@ -1130,8 +1131,10 @@ function get_host_install_destdir() {
11301131
if [[ $(should_include_host_in_lipo ${host}) ]]; then
11311132
# If this is one of the hosts we should lipo, install in to a temporary subdirectory.
11321133
local host_install_destdir="${BUILD_DIR}/intermediate-install/${host}"
1133-
elif [[ "${host}" == "merged-hosts" ]]; then
1134-
# This assumes that all hosts are merged to the lipo.
1134+
elif [[ "${host}" == "merged-hosts" ]] ||
1135+
[[ "$(true_false ${CROSS_COMPILE_APPEND_HOST_TARGET_TO_DESTDIR})" == "FALSE" ]]; then
1136+
# This assumes that all hosts are merged to the lipo, or the build
1137+
# was told not to append anything.
11351138
local host_install_destdir="${INSTALL_DESTDIR}"
11361139
else
11371140
local host_install_destdir="${INSTALL_DESTDIR}/${host}"

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,12 @@ def create_argument_parser():
563563
help='A space separated list of targets to cross-compile host '
564564
'Swift tools for. Can be used multiple times.')
565565

566+
option('--cross-compile-append-host-target-to-destdir', toggle_true,
567+
default=True,
568+
help="Append each cross-compilation host target's name as a subdirectory "
569+
"for each cross-compiled toolchain's destdir, useful when building "
570+
"multiple toolchains and can be disabled if only cross-compiling one.")
571+
566572
option('--stdlib-deployment-targets', store,
567573
type=argparse.ShellSplitType(),
568574
default=None,

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
'cmark_build_variant': 'Debug',
127127
'compiler_vendor': defaults.COMPILER_VENDOR,
128128
'coverage_db': None,
129+
'cross_compile_append_host_target_to_destdir': True,
129130
'cross_compile_hosts': [],
130131
'darwin_deployment_version_ios':
131132
defaults.DARWIN_DEPLOYMENT_VERSION_IOS,
@@ -532,6 +533,7 @@ class BuildScriptImplOption(_BaseOption):
532533
EnableOption('--build-swift-static-stdlib'),
533534
EnableOption('--build-swift-stdlib-unittest-extra'),
534535
EnableOption('--build-swift-stdlib-static-print'),
536+
EnableOption('--cross-compile-append-host-target-to-destdir'),
535537
EnableOption('--distcc'),
536538
EnableOption('--sccache'),
537539
EnableOption('--enable-asan'),

utils/swift_build_support/swift_build_support/build_script_invocation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def convert_to_impl_arguments(self):
124124
"--lldb-assertions", str(
125125
args.lldb_assertions).lower(),
126126
"--cmake-generator", args.cmake_generator,
127+
"--cross-compile-append-host-target-to-destdir", str(
128+
args.cross_compile_append_host_target_to_destdir).lower(),
127129
"--build-jobs", str(args.build_jobs),
128130
"--common-cmake-options=%s" % ' '.join(
129131
pipes.quote(opt) for opt in cmake.common_options()),

utils/swift_build_support/swift_build_support/products/product.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ def host_install_destdir(self, host_target):
225225
# install in to a temporary subdirectory.
226226
return '%s/intermediate-install/%s' % \
227227
(os.path.dirname(self.build_dir), host_target)
228-
elif host_target == "merged-hosts":
229-
# This assumes that all hosts are merged to the lipo.
228+
elif host_target == "merged-hosts" or \
229+
not self.args.cross_compile_append_host_target_to_destdir:
230+
# This assumes that all hosts are merged to the lipo, or the build
231+
# was told not to append anything.
230232
return self.args.install_destdir
231233
else:
232234
return '%s/%s' % (self.args.install_destdir, host_target)

0 commit comments

Comments
 (0)