@@ -55,6 +55,7 @@ LLVM_TARGETS_TO_BUILD="X86;ARM;AArch64;PowerPC;SystemZ"
55
55
# referred to as `SWIFT_INSTALL_COMPONENTS` in the remainder of this script.
56
56
KNOWN_SETTINGS=(
57
57
# name default description
58
+ dry-run " " " print the commands that would be executed, but do not execute them"
58
59
build-args " " " arguments to the build tool; defaults to -j8 when CMake generator is \" Unix Makefiles\" "
59
60
build-dir " " " out-of-tree build directory; default is in-tree. **This argument is required**"
60
61
host-cc " " " the path to CC, the 'clang' compiler for the host platform. **This argument is required**"
@@ -222,23 +223,42 @@ KNOWN_SETTINGS=(
222
223
# Centalized access point for traced command invocation.
223
224
# Every operation that might mutates file system should be called via
224
225
# these functions.
226
+
225
227
function call() {
226
- { set -x; } 2> /dev/null
227
- " $@ "
228
- { set +x; } 2> /dev/null
228
+ if [[ ${DRY_RUN} ]]; then
229
+ echo " ${PS4} " $( quoted_print " $@ " )
230
+ else
231
+ { set -x; } 2> /dev/null
232
+ " $@ "
233
+ { set +x; } 2> /dev/null
234
+ fi
229
235
}
230
236
231
237
function with_pushd() {
232
238
local dir=$1
233
239
shift
234
- set -x
235
- pushd " ${dir} "
236
- " $@ "
237
- { set -x; } 2> /dev/null # because $@ might includes { set +x; }
238
- popd
239
- { set +x; } 2> /dev/null
240
+ if [[ " $1 " == " call" ]]; then
241
+ shift
242
+ fi
243
+ if [[ ${DRY_RUN} ]]; then
244
+ echo ${PS4} pushd " ${dir} "
245
+ echo " ${PS4} " $( quoted_print " $@ " )
246
+ echo ${PS4} popd
247
+ else
248
+ set -x
249
+ pushd " ${dir} "
250
+ " $@ "
251
+ { set -x; } 2> /dev/null # because $@ might includes { set +x; }
252
+ popd
253
+ { set +x; } 2> /dev/null
254
+ fi
240
255
}
241
256
257
+ function quoted_print() {
258
+ python -c ' import pipes; import sys; print(" ".join(pipes.quote(arg) for arg in sys.argv[1:]))' " $@ "
259
+ }
260
+
261
+
242
262
function toupper() {
243
263
echo " $@ " | tr ' [:lower:]' ' [:upper:]'
244
264
}
@@ -1434,7 +1454,7 @@ function set_swiftpm_bootstrap_command() {
1434
1454
XCTEST_BUILD_DIR=$( build_directory ${host} xctest)
1435
1455
fi
1436
1456
fi
1437
- if [ ! -e " ${LLBUILD_BIN } " ]; then
1457
+ if [ " ${SKIP_BUILD_LLBUILD } " ]; then
1438
1458
echo " Error: Cannot build swiftpm without llbuild (swift-build-tool)."
1439
1459
exit 1
1440
1460
fi
@@ -2334,7 +2354,11 @@ for host in "${ALL_HOSTS[@]}"; do
2334
2354
if [[ " ${target} " != " " ]]; then
2335
2355
echo " --- ${target} ---"
2336
2356
trap " tests_busted ${product} '(${target} )'" ERR
2337
- if [[ " ${CMAKE_GENERATOR} " == Ninja ]] && ! ( " ${build_cmd[@]} " --version 2>&1 | grep -i -q llbuild ); then
2357
+
2358
+ # NOTE: In dry-run mode, build_dir might not exist yet. In that
2359
+ # case, -n query will fail. So, in dry-run mode,
2360
+ # we don't expand test script.
2361
+ if [[ ! " ${DRY_RUN} " && " ${CMAKE_GENERATOR} " == Ninja ]] && ! ( " ${build_cmd[@]} " --version 2>&1 | grep -i -q llbuild ); then
2338
2362
# Ninja buffers command output to avoid scrambling the output
2339
2363
# of parallel jobs, which is awesome... except that it
2340
2364
# interferes with the progress meter when testing. Instead of
@@ -2530,29 +2554,38 @@ for host in "${ALL_HOSTS[@]}"; do
2530
2554
done
2531
2555
2532
2556
if [[ " ${DARWIN_INSTALL_EXTRACT_SYMBOLS} " ]] && [[ $( host_has_darwin_symbols ${host} ) ]]; then
2533
- set -x
2534
- # Copy executables and shared libraries from the `host_install_destdir` to
2535
- # INSTALL_SYMROOT and run dsymutil on them.
2536
- (cd " ${host_install_destdir} " &&
2537
- find ./" ${TOOLCHAIN_PREFIX} " -perm -0111 -type f -print | cpio -pdm " ${INSTALL_SYMROOT} " )
2557
+ echo " --- Extracting symbols ---"
2538
2558
2539
- # Run dsymutil on executables and shared libraries.
2540
- #
2541
- # Exclude shell scripts.
2542
- (cd " ${INSTALL_SYMROOT} " &&
2543
- find ./" ${TOOLCHAIN_PREFIX} " -perm -0111 -type f -print | \
2544
- grep -v swift-stdlib-tool | \
2545
- grep -v crashlog.py | \
2546
- grep -v symbolication.py | \
2547
- xargs -n 1 -P ${BUILD_JOBS} $( xcrun_find_tool dsymutil) )
2548
-
2549
- # Strip executables, shared libraries and static libraries in
2550
- # `host_install_destdir`.
2551
- find " ${host_install_destdir}${TOOLCHAIN_PREFIX} /" \
2552
- -perm -0111 -or -name " *.a" -type f -print | \
2553
- xargs -n 1 -P ${BUILD_JOBS} $( xcrun_find_tool strip) -S
2559
+ # FIXME: Since it's hard to trace output pipe call,
2560
+ # For now, We don't support dry-run trace for this block
2561
+ # Instead, just echo we do "darwin_intall_extract_symbols".
2562
+ if [[ " ${DRY_RUN} " ]]; then
2563
+ call darwin_install_extract_symbols
2564
+ else
2565
+ set -x
2566
+ # Copy executables and shared libraries from the `host_install_destdir` to
2567
+ # INSTALL_SYMROOT and run dsymutil on them.
2568
+ (cd " ${host_install_destdir} " &&
2569
+ find ./" ${TOOLCHAIN_PREFIX} " -perm -0111 -type f -print | cpio -pdm " ${INSTALL_SYMROOT} " )
2554
2570
2555
- { set +x; } 2> /dev/null
2571
+ # Run dsymutil on executables and shared libraries.
2572
+ #
2573
+ # Exclude shell scripts.
2574
+ (cd " ${INSTALL_SYMROOT} " &&
2575
+ find ./" ${TOOLCHAIN_PREFIX} " -perm -0111 -type f -print | \
2576
+ grep -v swift-stdlib-tool | \
2577
+ grep -v crashlog.py | \
2578
+ grep -v symbolication.py | \
2579
+ xargs -n 1 -P ${BUILD_JOBS} $( xcrun_find_tool dsymutil) )
2580
+
2581
+ # Strip executables, shared libraries and static libraries in
2582
+ # `host_install_destdir`.
2583
+ find " ${host_install_destdir}${TOOLCHAIN_PREFIX} /" \
2584
+ -perm -0111 -or -name " *.a" -type f -print | \
2585
+ xargs -n 1 -P ${BUILD_JOBS} $( xcrun_find_tool strip) -S
2586
+
2587
+ { set +x; } 2> /dev/null
2588
+ fi
2556
2589
fi
2557
2590
done
2558
2591
# Everything is 'installed', but some products may be awaiting lipo.
0 commit comments