@@ -23,6 +23,78 @@ index 01390761c8c..d84c142397c 100644
23
23
24
24
// NOTE: 25185.byteSwapped = 0x62 'a', 0x61 'b'
25
25
// CHECK-LABEL: test_ascii_scalar_scalar2
26
+ diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
27
+ index 3140c8bb545..9755dde2bab 100755
28
+ --- a/swift/utils/build-script-impl
29
+ +++ b/swift/utils/build-script-impl
30
+ @@ -2351,7 +2351,7 @@ for host in "${ALL_HOSTS[@]}"; do
31
+ continue
32
+ fi
33
+
34
+ - if [[ "${CROSS_COMPILE_BUILD_SWIFT_TOOLS}" == "0" ]]; then
35
+ + if [[ "$(true_false ${CROSS_COMPILE_BUILD_SWIFT_TOOLS})" == "FALSE" ]]; then
36
+ echo "Skipping building Foundation Macros for ${host}, because the host tools are not being built"
37
+ continue
38
+ fi
39
+ @@ -2940,7 +2940,7 @@ for host in "${ALL_HOSTS[@]}"; do
40
+ continue
41
+ fi
42
+
43
+ - if [[ "${CROSS_COMPILE_BUILD_SWIFT_TOOLS}" == "0" && "${product}" == "foundation_macros" ]]; then
44
+ + if [[ "$(true_false ${CROSS_COMPILE_BUILD_SWIFT_TOOLS})" == "FALSE" && "${product}" == "foundation_macros" ]]; then
45
+ echo "Skipping installing Foundation Macros for ${host}, because the host tools are not being built"
46
+ continue
47
+ fi
48
+ diff --git a/swift/utils/build_swift/build_swift/driver_arguments.py b/swift/utils/build_swift/build_swift/driver_arguments.py
49
+ index 2b7d6d07799..e0d04d22825 100644
50
+ --- a/swift/utils/build_swift/build_swift/driver_arguments.py
51
+ +++ b/swift/utils/build_swift/build_swift/driver_arguments.py
52
+ @@ -677,6 +677,12 @@ def create_argument_parser():
53
+ "for each cross-compiled toolchain's destdir, useful when building "
54
+ "multiple toolchains and can be disabled if only cross-compiling one.")
55
+
56
+ + option('--cross-compile-build-swift-tools', toggle_true,
57
+ + default=True,
58
+ + help="Cross-compile the Swift compiler, other host tools from the "
59
+ + "compiler repository, and various macros for each listed "
60
+ + "--cross-compile-hosts platform.")
61
+ +
62
+ option('--stdlib-deployment-targets', store,
63
+ type=argparse.ShellSplitType(),
64
+ default=None,
65
+ diff --git a/swift/utils/build_swift/tests/expected_options.py b/swift/utils/build_swift/tests/expected_options.py
66
+ index f8d1a3526ed..b655d610923 100644
67
+ --- a/swift/utils/build_swift/tests/expected_options.py
68
+ +++ b/swift/utils/build_swift/tests/expected_options.py
69
+ @@ -155,6 +155,7 @@ EXPECTED_DEFAULTS = {
70
+ 'compiler_vendor': defaults.COMPILER_VENDOR,
71
+ 'coverage_db': None,
72
+ 'cross_compile_append_host_target_to_destdir': True,
73
+ + 'cross_compile_build_swift_tools': True,
74
+ 'cross_compile_deps_path': None,
75
+ 'cross_compile_hosts': [],
76
+ 'infer_cross_compile_hosts_on_darwin': False,
77
+ @@ -622,6 +623,7 @@ EXPECTED_OPTIONS = [
78
+ EnableOption('--build-swift-clang-overlays'),
79
+ EnableOption('--build-swift-remote-mirror'),
80
+ EnableOption('--cross-compile-append-host-target-to-destdir'),
81
+ + EnableOption('--cross-compile-build-swift-tools'),
82
+ EnableOption('--color-in-tests'),
83
+ EnableOption('--distcc'),
84
+ EnableOption('--sccache'),
85
+ diff --git a/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py b/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
86
+ index a0289515fd0..355d72fe21f 100644
87
+ --- a/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
88
+ +++ b/swift/utils/swift_build_support/swift_build_support/build_script_invocation.py
89
+ @@ -119,6 +119,8 @@ class BuildScriptInvocation(object):
90
+ "--cmake-generator", args.cmake_generator,
91
+ "--cross-compile-append-host-target-to-destdir", str(
92
+ args.cross_compile_append_host_target_to_destdir).lower(),
93
+ + "--cross-compile-build-swift-tools", str(
94
+ + args.cross_compile_build_swift_tools).lower(),
95
+ "--build-jobs", str(args.build_jobs),
96
+ "--lit-jobs", str(args.lit_jobs),
97
+ "--common-cmake-options=%s" % ' '.join(
26
98
diff --git a/swift/utils/swift_build_support/swift_build_support/products/cmake_product.py b/swift/utils/swift_build_support/swift_build_support/products/cmake_product.py
27
99
index dc338334f28..f1a9f4d28bf 100644
28
100
--- a/swift/utils/swift_build_support/swift_build_support/products/cmake_product.py
@@ -36,6 +108,100 @@ index dc338334f28..f1a9f4d28bf 100644
36
108
assert self.toolchain.cmake is not None
37
109
cmake_build = []
38
110
_cmake = cmake.CMake(self.args, self.toolchain,
111
+ @@ -71,9 +71,7 @@ class CMakeProduct(product.Product):
112
+ env=env)
113
+
114
+ is_llvm = self.product_name() == "llvm"
115
+ - if (not is_llvm and not self.args.skip_build) or (
116
+ - is_llvm and self.args._build_llvm
117
+ - ):
118
+ + if (not is_llvm and not self.args.skip_build) or (is_llvm and build_llvm):
119
+ cmake_opts = [self.build_dir, "--config", build_type]
120
+
121
+ shell.call(
122
+ diff --git a/swift/utils/swift_build_support/swift_build_support/products/llvm.py b/swift/utils/swift_build_support/swift_build_support/products/llvm.py
123
+ index ffae1d66702..72e400c55be 100644
124
+ --- a/swift/utils/swift_build_support/swift_build_support/products/llvm.py
125
+ +++ b/swift/utils/swift_build_support/swift_build_support/products/llvm.py
126
+ @@ -249,10 +249,13 @@ class LLVM(cmake_product.CMakeProduct):
127
+ # space/time efficient than -g on that platform.
128
+ llvm_cmake_options.define('LLVM_USE_SPLIT_DWARF:BOOL', 'YES')
129
+
130
+ - if not self.args._build_llvm:
131
+ + build = True
132
+ + if not self.args._build_llvm or (not self.args.cross_compile_build_swift_tools
133
+ + and self.is_cross_compile_target(host_target)):
134
+ # Indicating we don't want to build LLVM at all should
135
+ # override everything.
136
+ build_targets = []
137
+ + build = False
138
+ elif self.args.skip_build or not self.args.build_llvm:
139
+ # We can't skip the build completely because the standalone
140
+ # build of Swift depends on these.
141
+ @@ -399,7 +402,8 @@ class LLVM(cmake_product.CMakeProduct):
142
+
143
+ self._handle_cxx_headers(host_target, platform)
144
+
145
+ - self.build_with_cmake(build_targets, self.args.llvm_build_variant, [])
146
+ + self.build_with_cmake(build_targets, self.args.llvm_build_variant, [],
147
+ + build_llvm=build)
148
+
149
+ # copy over the compiler-rt builtins for iOS/tvOS/watchOS to ensure
150
+ # that Swift's stdlib can use compiler-rt builtins when targeting
151
+ @@ -484,7 +488,9 @@ class LLVM(cmake_product.CMakeProduct):
152
+ Whether or not this product should be installed with the given
153
+ arguments.
154
+ """
155
+ - return self.args.install_llvm
156
+ + return self.args.install_llvm and (
157
+ + self.args.cross_compile_build_swift_tools or
158
+ + not self.is_cross_compile_target(host_target))
159
+
160
+ def install(self, host_target):
161
+ """
162
+ diff --git a/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py b/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
163
+ index ddb3b553de7..d127424709c 100644
164
+ --- a/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
165
+ +++ b/swift/utils/swift_build_support/swift_build_support/products/swift_testing_macros.py
166
+ @@ -42,13 +42,24 @@ class SwiftTestingMacros(product.Product):
167
+ return True
168
+
169
+ def should_build(self, host_target):
170
+ - return True
171
+ + build_macros = not self.is_cross_compile_target(host_target) or \
172
+ + self.args.cross_compile_build_swift_tools
173
+ + if not build_macros:
174
+ + print("Skipping building Testing Macros for %s, because the host tools "
175
+ + "are not being built" % host_target)
176
+ + return build_macros
177
+
178
+ def should_test(self, host_target):
179
+ return False
180
+
181
+ def should_install(self, host_target):
182
+ - return self.args.install_swift_testing_macros
183
+ + install_macros = self.args.install_swift_testing_macros and \
184
+ + (not self.is_cross_compile_target(host_target) or
185
+ + self.args.cross_compile_build_swift_tools)
186
+ + if self.args.install_swift_testing_macros and not install_macros:
187
+ + print("Skipping installing Testing Macros for %s, because the host tools "
188
+ + "are not being built" % host_target)
189
+ + return install_macros
190
+
191
+ def _cmake_product(self, host_target):
192
+ build_root = os.path.dirname(self.build_dir)
193
+ @@ -121,3 +132,11 @@ class SwiftTestingMacrosCMakeShim(cmake_product.CMakeProduct):
194
+ install_prefix = install_destdir + self.args.install_prefix
195
+
196
+ self.install_with_cmake(['install'], install_prefix)
197
+ +
198
+ + @classmethod
199
+ + def is_build_script_impl_product(cls):
200
+ + return False
201
+ +
202
+ + @classmethod
203
+ + def is_before_build_script_impl_product(cls):
204
+ + return False
39
205
diff --git a/swift/utils/swift_build_support/swift_build_support/products/product.py b/swift/utils/swift_build_support/swift_build_support/products/product.py
40
206
index 47e7ab79905..6bd94c3cad8 100644
41
207
--- a/swift/utils/swift_build_support/swift_build_support/products/product.py
@@ -179,3 +345,49 @@ index 508d6204eaf..64a862eaf0e 100644
179
345
return flags
180
346
181
347
def cmake_options(self, args):
348
+ diff --git a/swift/validation-test/BuildSystem/android_cross_compile.test b/swift/validation-test/BuildSystem/android_cross_compile.test
349
+ index 8396568dce7..02c71aa308c 100644
350
+ --- a/swift/validation-test/BuildSystem/android_cross_compile.test
351
+ +++ b/swift/validation-test/BuildSystem/android_cross_compile.test
352
+ @@ -1,11 +1,15 @@
353
+ # REQUIRES: standalone_build
354
+ - # UNSUPPORTED: OS=macosx
355
+ - # UNSUPPORTED: OS=ios
356
+ - # UNSUPPORTED: OS=tvos
357
+ - # UNSUPPORTED: OS=watchos
358
+
359
+ # RUN: %empty-directory(%t)
360
+ - # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --libdispatch --cross-compile-hosts=android-aarch64 --skip-local-build --android --android-ndk %t/ndk/ --android-arch aarch64 2>&1 | %FileCheck %s
361
+ + # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --foundation --swift-testing --swift-testing-macros --install-foundation --install-swift-testing-macros --install-llvm --cross-compile-hosts=android-aarch64 --cross-compile-build-swift-tools=False --android --android-ndk %t/ndk/ --android-arch aarch64 2>&1 | %FileCheck %s
362
+
363
+ - # CHECK: -DCMAKE_Swift_FLAGS{{.*}}-target {{.*}}unknown-linux-android{{.*}} -sdk
364
+ - # CHECK: -DCMAKE_SYSTEM_NAME=Android {{.*}} -DCMAKE_ANDROID_NDK
365
+ + # CHECK: pushd {{.*}}/llvm-android-aarch64
366
+ + # CHECK-NOT: cmake --build {{.*}}/llvm-android-aarch64 --config
367
+ + # CHECK-NOT: cmake --build {{.*}}/llvm-android-aarch64 {{.*}} install-llvm
368
+ + # CHECK: cmake {{.*}}-DSWIFT_INCLUDE_TOOLS:BOOL=FALSE{{.*}}/swift
369
+ + # CHECK: Skipping building Foundation Macros for android-aarch64, because the host tools are not being built
370
+ + # CHECK: Skipping installing Foundation Macros for android-aarch64, because the host tools are not being built
371
+ + # CHECK: Skipping building Testing Macros for android-aarch64, because the host tools are not being built
372
+ + # CHECK: Skipping installing Testing Macros for android-aarch64, because the host tools are not being built
373
+ + # CHECK: cmake {{.*}}-DCMAKE_TOOLCHAIN_FILE:PATH={{.*}}swifttesting-android-aarch64/BuildScriptToolchain.cmake
374
+ + # CHECK: -DCMAKE_Swift_FLAGS=-target aarch64-unknown-linux-android{{.*}} -sdk
375
+ diff --git a/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test b/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
376
+ index 25dbee7709e..deea2cef7a1 100644
377
+ --- a/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
378
+ +++ b/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
379
+ @@ -1,9 +1,13 @@
380
+ # REQUIRES: standalone_build
381
+ - # REQUIRES: OS=macosx
382
+
383
+ # RUN: %empty-directory(%t)
384
+ # RUN: mkdir -p %t
385
+ # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --install-all --cmake %cmake --skip-build-llvm --skip-build-swift 2>&1 | %FileCheck %s
386
+ + # RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --install-all --cmake %cmake --skip-build-llvm --skip-build-swift --cross-compile-hosts=android-aarch64 --skip-local-build --android --android-ndk %t/ndk/ 2>&1 | %FileCheck --check-prefix=ANDROID %s
387
+
388
+ # CHECK: DRY_RUN! Writing Toolchain file to path:{{.*}}BuildScriptToolchain.cmake
389
+ # CHECK: cmake {{.*}}-DCMAKE_TOOLCHAIN_FILE:PATH={{.*}}BuildScriptToolchain.cmake {{.*}}cmark
390
+ +
391
+ + # ANDROID: DRY_RUN! Writing Toolchain file to path:{{.*}}cmark-android-aarch64/BuildScriptToolchain.cmake
392
+ + # ANDROID: cmake {{.*}}-DCMAKE_TOOLCHAIN_FILE:PATH={{.*}}cmark-android-aarch64/BuildScriptToolchain.cmake
393
+ + # ANDROID: -DCMAKE_Swift_FLAGS=-target aarch64-unknown-linux-android
0 commit comments