@@ -218,6 +218,7 @@ KNOWN_SETTINGS=(
218
218
common-cmake-options " " " CMake options used for all targets, including LLVM/Clang"
219
219
# TODO: Remove this some time later.
220
220
user-config-args " " " **Renamed to --extra-cmake-options**: User-supplied arguments to cmake when used to do configuration."
221
+ only-execute " all" " Only execute the named action (see implementation)"
221
222
)
222
223
223
224
# Centalized access point for traced command invocation.
@@ -308,6 +309,51 @@ function float_min() {
308
309
fi
309
310
}
310
311
312
+ # Support for performing isolated actions.
313
+ #
314
+ # This is part of refactoring more work to be done or controllable via
315
+ # `build-script` itself. For additional information, see:
316
+ # https://bugs.swift.org/browse/SR-237
317
+ #
318
+ # To use this functionality, the script is invoked with:
319
+ # ONLY_EXECUTE=<action name>
320
+ # where <action name> is one of:
321
+ # all -- execute all actions
322
+ # ${host}-${product}-build -- the build of the product
323
+ # ${host}-${product}-test -- the test of the product
324
+ # ${host}-${product}-install -- the install of the product
325
+ # ${host}-package -- the package construction and test
326
+ # merged-hosts-lipo -- the lipo step, if used
327
+ # and if used, only the one individual action will be performed.
328
+ #
329
+ # If not set, the default is `all`.
330
+
331
+ # should_execute_action(name) -> 1 or nil
332
+ #
333
+ # Check if the named action should be run in the given script invocation.
334
+ function should_execute_action() {
335
+ local name=" $1 "
336
+
337
+ if [[ " ${ONLY_EXECUTE} " = " all" ]] ||
338
+ [[ " ${ONLY_EXECUTE} " = " ${name} " ]]; then
339
+ echo 1
340
+ fi
341
+ }
342
+
343
+ # should_execute_host_actions_for_phase(host, phase-name) -> 1 or nil
344
+ #
345
+ # Check if the there are any actions to execute for this host and phase (i.e.,
346
+ # "build", "test", or "install")
347
+ function should_execute_host_actions_for_phase() {
348
+ local host=" $1 "
349
+ local phase_name=" $2 "
350
+
351
+ if [[ " ${ONLY_EXECUTE} " = " all" ]] ||
352
+ [[ " ${ONLY_EXECUTE} " == ${host} -* -${phase_name} ]]; then
353
+ echo 1
354
+ fi
355
+ }
356
+
311
357
function num_llvm_parallel_lto_link_jobs() {
312
358
case " $( uname -s -m) " in
313
359
Darwin\ x86_64)
@@ -1512,19 +1558,26 @@ function set_swiftpm_bootstrap_command() {
1512
1558
1513
1559
1514
1560
for host in " ${ALL_HOSTS[@]} " ; do
1561
+ # Skip this pass when the only action to execute can't match.
1562
+ if ! [[ $( should_execute_host_actions_for_phase ${host} build) ]]; then
1563
+ continue
1564
+ fi
1515
1565
1516
1566
calculate_targets_for_host $host
1517
1567
1518
1568
set_build_options_for_host $host
1519
1569
1520
- echo " Building the standard library for: ${SWIFT_STDLIB_TARGETS[@]} "
1521
- if [[ " ${SWIFT_TEST_TARGETS[@]} " ]] && ! [[ " ${SKIP_TEST_SWIFT} " ]]; then
1522
- echo " Running Swift tests for: ${SWIFT_TEST_TARGETS[@]} "
1523
- fi
1524
- if ! [[ " ${SKIP_TEST_BENCHMARKS} " ]] &&
1525
- [[ " ${SWIFT_RUN_BENCHMARK_TARGETS[@]} " ]] &&
1526
- ! [[ " ${SKIP_TEST_BENCHMARK} " ]]; then
1527
- echo " Running Swift benchmarks for: ${SWIFT_RUN_BENCHMARK_TARGETS[@]} "
1570
+ # Don't echo anything if only executing an individual action.
1571
+ if [[ " ${ONLY_EXECUTE} " = " all" ]]; then
1572
+ echo " Building the standard library for: ${SWIFT_STDLIB_TARGETS[@]} "
1573
+ if [[ " ${SWIFT_TEST_TARGETS[@]} " ]] && ! [[ " ${SKIP_TEST_SWIFT} " ]]; then
1574
+ echo " Running Swift tests for: ${SWIFT_TEST_TARGETS[@]} "
1575
+ fi
1576
+ if ! [[ " ${SKIP_TEST_BENCHMARKS} " ]] &&
1577
+ [[ " ${SWIFT_RUN_BENCHMARK_TARGETS[@]} " ]] &&
1578
+ ! [[ " ${SKIP_TEST_BENCHMARK} " ]]; then
1579
+ echo " Running Swift benchmarks for: ${SWIFT_RUN_BENCHMARK_TARGETS[@]} "
1580
+ fi
1528
1581
fi
1529
1582
1530
1583
common_cmake_options_host=(" ${COMMON_CMAKE_OPTIONS[@]} " )
@@ -1644,6 +1697,11 @@ for host in "${ALL_HOSTS[@]}"; do
1644
1697
)
1645
1698
1646
1699
for product in " ${PRODUCTS[@]} " ; do
1700
+ # Check if we should perform this action.
1701
+ if ! [[ $( should_execute_action " ${host} -${product} -build" ) ]]; then
1702
+ continue
1703
+ fi
1704
+
1647
1705
unset skip_build
1648
1706
source_dir_var=" $( toupper ${product} ) _SOURCE_DIR"
1649
1707
source_dir=${! source_dir_var}
@@ -2198,12 +2256,21 @@ tests_busted ()
2198
2256
}
2199
2257
2200
2258
for host in " ${ALL_HOSTS[@]} " ; do
2259
+ # Skip this pass when the only action to execute can't match.
2260
+ if ! [[ $( should_execute_host_actions_for_phase ${host} test) ]]; then
2261
+ continue
2262
+ fi
2201
2263
2202
2264
# Calculate test targets
2203
2265
calculate_targets_for_host $host
2204
2266
2205
2267
# Run the tests for each product
2206
2268
for product in " ${PRODUCTS[@]} " ; do
2269
+ # Check if we should perform this action.
2270
+ if ! [[ $( should_execute_action " ${host} -${product} -test" ) ]]; then
2271
+ continue
2272
+ fi
2273
+
2207
2274
case ${product} in
2208
2275
cmark)
2209
2276
if [[ " ${SKIP_TEST_CMARK} " ]]; then
@@ -2410,6 +2477,10 @@ done
2410
2477
LIPO_SRC_DIRS=()
2411
2478
2412
2479
for host in " ${ALL_HOSTS[@]} " ; do
2480
+ # Skip this pass when the only action to execute can't match.
2481
+ if ! [[ $( should_execute_host_actions_for_phase ${host} install) ]]; then
2482
+ continue
2483
+ fi
2413
2484
2414
2485
# Calculate the directory to install products in to.
2415
2486
host_install_destdir=$( get_host_install_destdir ${host} )
@@ -2423,6 +2494,10 @@ for host in "${ALL_HOSTS[@]}"; do
2423
2494
set_build_options_for_host $host
2424
2495
2425
2496
for product in " ${PRODUCTS[@]} " ; do
2497
+ # Check if we should perform this action.
2498
+ if ! [[ $( should_execute_action " ${host} -${product} -install" ) ]]; then
2499
+ continue
2500
+ fi
2426
2501
2427
2502
INSTALL_TARGETS=" install"
2428
2503
@@ -2729,6 +2804,11 @@ function build_and_test_installable_package() {
2729
2804
# Build and test packages.
2730
2805
for host in " ${ALL_HOSTS[@]} " ; do
2731
2806
2807
+ # Check if we should perform this action.
2808
+ if ! [[ $( should_execute_action " ${host} -package" ) ]]; then
2809
+ continue
2810
+ fi
2811
+
2732
2812
if [[ $( should_include_host_in_lipo ${host} ) ]]; then
2733
2813
continue
2734
2814
fi
@@ -2738,11 +2818,17 @@ done
2738
2818
2739
2819
# Lipo those products which require it, optionally build and test an installable package.
2740
2820
if [[ ${# LIPO_SRC_DIRS[@]} -gt 0 ]]; then
2741
- echo " --- Merging and running lipo ---"
2742
-
2743
2821
# This is from multiple hosts; Which host should we say it is?
2744
2822
# Let's call it 'merged-hosts' so that we can identify it.
2745
2823
mergedHost=" merged-hosts"
2824
+
2825
+ # Check if we should perform this action.
2826
+ if ! [[ $( should_execute_action " ${mergedHost} -lipo" ) ]]; then
2827
+ continue
2828
+ fi
2829
+
2830
+ echo " --- Merging and running lipo ---"
2831
+
2746
2832
call " ${SWIFT_SOURCE_DIR} " /utils/recursive-lipo --lipo=$( xcrun_find_tool lipo) --copy-subdirs=" $( get_host_install_prefix ${host} ) lib/swift $( get_host_install_prefix ${host} ) lib/swift_static" --destination=" $( get_host_install_destdir ${mergedHost} ) " ${LIPO_SRC_DIRS[@]}
2747
2833
2748
2834
# Build and test the lipo-ed package.
0 commit comments