Skip to content

Commit 9dd5d12

Browse files
authored
Rework swift-stress-tester repo building (#21523)
This change makes build-script-impl use a new, shared version of swift-stress-tester’s build-script-helper.py which also supports building swift-evolve. It also adds the necessary flags and variables to build swift-evolve from build-script.
1 parent 865dc0c commit 9dd5d12

File tree

5 files changed

+85
-9
lines changed

5 files changed

+85
-9
lines changed

utils/build-presets.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ llbuild
10311031
swiftpm
10321032
swiftsyntax
10331033
skstresstester
1034+
swiftevolve
10341035
playgroundsupport
10351036

10361037
# Build with debug info, this allows us to symbolicate crashes from
@@ -1057,6 +1058,7 @@ install-swiftpm
10571058
install-swiftsyntax
10581059
skip-install-swiftsyntax-module
10591060
install-skstresstester
1061+
install-swiftevolve
10601062
install-playgroundsupport
10611063

10621064
install-destdir=%(install_destdir)s
@@ -1165,6 +1167,7 @@ skip-test-cmark
11651167
skip-test-playgroundsupport
11661168
skip-test-swiftsyntax
11671169
skip-test-skstresstester
1170+
skip-test-swiftevolve
11681171

11691172
#===------------------------------------------------------------------------===#
11701173
# LLDB build configurations

utils/build-script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ class BuildScriptInvocation(object):
481481
"--swiftpm-build-type", args.build_variant,
482482
"--swiftsyntax-build-type", args.build_variant,
483483
"--skstresstester-build-type", args.build_variant,
484+
"--swiftevolve-build-type", args.build_variant,
484485
"--llbuild-build-type", args.build_variant,
485486
"--swift-enable-assertions", str(args.swift_assertions).lower(),
486487
"--swift-stdlib-enable-assertions", str(
@@ -602,6 +603,8 @@ class BuildScriptInvocation(object):
602603
impl_args += ["--skip-build-swiftsyntax"]
603604
if not args.build_skstresstester:
604605
impl_args += ["--skip-build-skstresstester"]
606+
if not args.build_swiftevolve:
607+
impl_args += ["--skip-build-swiftevolve"]
605608
if not args.build_playgroundsupport:
606609
impl_args += ["--skip-build-playgroundsupport"]
607610
if args.build_swift_dynamic_stdlib:
@@ -647,6 +650,7 @@ class BuildScriptInvocation(object):
647650
"--skip-test-swiftpm",
648651
"--skip-test-swiftsyntax",
649652
"--skip-test-skstresstester",
653+
"--skip-test-swiftevolve",
650654
"--skip-test-xctest",
651655
"--skip-test-foundation",
652656
"--skip-test-libdispatch",

utils/build-script-impl

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ KNOWN_SETTINGS=(
8484
swiftpm-build-type "Debug" "the build variant for swiftpm"
8585
swiftsyntax-build-type "Debug" "the build variant for swiftSyntax"
8686
skstresstester-build-type "Debug" "the build variant for the SourceKit stress tester"
87+
swiftevolve-build-type "Debug" "the build variant for the swift-evolve tool"
8788
llbuild-enable-assertions "1" "enable assertions in llbuild"
8889
enable-asan "" "enable Address Sanitizer"
8990
enable-ubsan "" "enable Undefined Behavior Sanitizer"
@@ -126,6 +127,7 @@ KNOWN_SETTINGS=(
126127
skip-build-swiftpm "" "set to skip building swiftpm"
127128
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
128129
skip-build-skstresstester "" "set to skip building the SourceKit stress tester"
130+
skip-build-swiftevolve "" "set to skip building the swift-evolve tool"
129131
skip-build-xctest "" "set to skip building xctest"
130132
skip-build-foundation "" "set to skip building foundation"
131133
skip-build-libdispatch "" "set to skip building libdispatch"
@@ -140,6 +142,7 @@ KNOWN_SETTINGS=(
140142
skip-test-swiftpm "" "set to skip testing swiftpm"
141143
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
142144
skip-test-skstresstester "" "set to skip testing the SourceKit stress tester"
145+
skip-test-swiftevolve "" "set to skip testing the swift-evolve tool"
143146
skip-test-xctest "" "set to skip testing xctest"
144147
skip-test-foundation "" "set to skip testing foundation"
145148
skip-test-libdispatch "" "set to skip testing libdispatch"
@@ -197,6 +200,7 @@ KNOWN_SETTINGS=(
197200
install-swiftsyntax "" "whether to install swiftsyntax"
198201
skip-install-swiftsyntax-module "" "set to skip installing swiftsyntax modules"
199202
install-skstresstester "" "whether to install the SourceKit stress tester"
203+
install-swiftevolve "" "whether to install the swift-evolve tool"
200204
install-xctest "" "whether to install xctest"
201205
install-foundation "" "whether to install foundation"
202206
install-libdispatch "" "whether to install libdispatch"
@@ -1177,7 +1181,9 @@ LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
11771181
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
11781182
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
11791183
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
1180-
SKSTRESSTESTER_SOURCE_DIR="${WORKSPACE}/swift-stress-tester/SourceKitStressTester"
1184+
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester"
1185+
SKSTRESSTESTER_SOURCE_DIR="${STRESSTEST_PACKAGE_DIR}/SourceKitStressTester"
1186+
SWIFTEVOLVE_SOURCE_DIR="${STRESSTEST_PACKAGE_DIR}/SwiftEvolve"
11811187
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11821188
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11831189
FOUNDATION_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
@@ -1251,14 +1257,17 @@ fi
12511257
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
12521258
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
12531259
fi
1254-
# The SourceKit stress tester is dependent on SwiftSyntax, so it must be added
1255-
# to the list of build products first.
1260+
# The SourceKit stress tester and swift-evolve are dependent on SwiftSyntax, so
1261+
# it must be added to the list of build products first.
12561262
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
12571263
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
12581264
fi
12591265
if [[ ! "${SKIP_BUILD_SKSTRESSTESTER}" ]] ; then
12601266
PRODUCTS=("${PRODUCTS[@]}" skstresstester)
12611267
fi
1268+
if [[ ! "${SKIP_BUILD_SWIFTEVOLVE}" ]] ; then
1269+
PRODUCTS=("${PRODUCTS[@]}" swiftevolve)
1270+
fi
12621271

12631272
# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
12641273
function contains_product() {
@@ -1572,6 +1581,9 @@ function build_directory_bin() {
15721581
skstresstester)
15731582
echo "${root}/${SKSTRESSTESTER_BUILD_TYPE}/bin"
15741583
;;
1584+
swiftevolve)
1585+
echo "${root}/${SWIFTEVOLVE_BUILD_TYPE}/bin"
1586+
;;
15751587
xctest)
15761588
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
15771589
;;
@@ -1717,6 +1729,9 @@ function cmake_config_opt() {
17171729
skstresstester)
17181730
echo "--config ${SKSTRESSTESTER_BUILD_TYPE}"
17191731
;;
1732+
swiftevolve)
1733+
echo "--config ${SWIFTEVOLVE_BUILD_TYPE}"
1734+
;;
17201735
xctest)
17211736
echo "--config ${XCTEST_BUILD_TYPE}"
17221737
;;
@@ -1826,9 +1841,12 @@ function set_swiftsyntax_build_command() {
18261841
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
18271842
}
18281843

1829-
function set_skstresstester_build_command() {
1844+
function set_stresstester_build_script_helper_command() {
1845+
local package_name="$1"
1846+
local package_build_type="$2"
1847+
18301848
if [ "${SKIP_BUILD_SWIFTSYNTAX}" ]; then
1831-
echo "Error: Cannot build the SourceKit stress tester without SwiftSyntax."
1849+
echo "Error: Cannot build $package_name without SwiftSyntax."
18321850
exit 1
18331851
fi
18341852

@@ -1837,16 +1855,17 @@ function set_skstresstester_build_command() {
18371855
swiftsyntax_config="release"
18381856
fi
18391857
local config="debug"
1840-
if [[ $(is_cmake_release_build_type "${SKSTRESSTESTER_BUILD_TYPE}") ]] ; then
1858+
if [[ $(is_cmake_release_build_type "${package_build_type}") ]] ; then
18411859
config="release"
18421860
fi
18431861

1844-
skstresstester_build_command=("${SKSTRESSTESTER_SOURCE_DIR}/Utilities/build-script-helper.py")
1862+
stresstester_build_script_helper_command=("${STRESSTEST_PACKAGE_DIR}/build-script-helper.py")
18451863
if [[ "${VERBOSE_BUILD}" ]] ; then
1846-
skstresstester_build_command+=(-v)
1864+
stresstester_build_script_helper_command+=(-v)
18471865
fi
18481866

1849-
skstresstester_build_command+=(
1867+
stresstester_build_script_helper_command+=(
1868+
--package-dir="${package_name}"
18501869
--build-dir="${build_dir}"
18511870
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
18521871
--swift-build-exec="${SWIFT_BUILD}"
@@ -1856,6 +1875,16 @@ function set_skstresstester_build_command() {
18561875
--config="${config}")
18571876
}
18581877

1878+
function set_skstresstester_build_command() {
1879+
set_stresstester_build_script_helper_command SourceKitStressTester "${SKSTRESSTESTER_BUILD_TYPE}"
1880+
skstresstester_build_command=("${stresstester_build_script_helper_command[@]}")
1881+
}
1882+
1883+
function set_swiftevolve_build_command() {
1884+
set_stresstester_build_script_helper_command SwiftEvolve "${SWIFTEVOLVE_BUILD_TYPE}"
1885+
swiftevolve_build_command=("${stresstester_build_script_helper_command[@]}")
1886+
}
1887+
18591888
# Construct the appropriate options to pass to an Xcode
18601889
# build of any LLDB target.
18611890
function set_lldb_xcodebuild_options() {
@@ -2544,6 +2573,16 @@ for host in "${ALL_HOSTS[@]}"; do
25442573
set_skstresstester_build_command
25452574
call "${skstresstester_build_command[@]}"
25462575

2576+
continue
2577+
;;
2578+
swiftevolve)
2579+
if [[ "$(uname -s)" != "Darwin" ]]; then
2580+
echo "error: unable to build swift-evolve on this platform"
2581+
continue
2582+
fi
2583+
set_swiftevolve_build_command
2584+
call "${swiftevolve_build_command[@]}"
2585+
25472586
continue
25482587
;;
25492588
xctest)
@@ -3173,6 +3212,14 @@ for host in "${ALL_HOSTS[@]}"; do
31733212
call "${skstresstester_build_command[@]}" test
31743213
continue
31753214
;;
3215+
swiftevolve)
3216+
if [[ "${SKIP_TEST_SWIFTEVOLVE}" ]]; then
3217+
continue
3218+
fi
3219+
echo "--- Running tests for ${product} ---"
3220+
call "${swiftevolve_build_command[@]}" test
3221+
continue
3222+
;;
31763223
xctest)
31773224
if [[ "${SKIP_TEST_XCTEST}" ]]; then
31783225
continue
@@ -3517,6 +3564,23 @@ for host in "${ALL_HOSTS[@]}"; do
35173564
call "${skstresstester_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
35183565
continue
35193566
;;
3567+
swiftevolve)
3568+
if [[ -z "${INSTALL_SWIFTEVOLVE}" ]] ; then
3569+
continue
3570+
fi
3571+
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
3572+
echo "--install-destdir is required to install products."
3573+
exit 1
3574+
fi
3575+
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
3576+
echo "--install-swiftsyntax is required to install swift-evolve"
3577+
exit 1
3578+
fi
3579+
3580+
echo "--- Installing ${product} ---"
3581+
call "${swiftevolve_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
3582+
continue
3583+
;;
35203584
xctest)
35213585
if [[ -z "${INSTALL_XCTEST}" ]] ; then
35223586
continue

utils/build_swift/driver_arguments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ def create_argument_parser():
521521
option(['--skstresstester'], store_true('build_skstresstester'),
522522
help='build the SourceKit stress tester')
523523

524+
option(['--swiftevolve'], store_true('build_swiftevolve'),
525+
help='build the swift-evolve tool')
526+
524527
option('--xctest', toggle_true('build_xctest'),
525528
help='build xctest')
526529

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
'build_swiftpm': False,
8484
'build_swiftsyntax': False,
8585
'build_skstresstester': False,
86+
'build_swiftevolve': False,
8687
'build_tvos': True,
8788
'build_tvos_device': False,
8889
'build_tvos_simulator': False,
@@ -400,6 +401,7 @@ class IgnoreOption(_BaseOption):
400401
SetTrueOption('--swiftpm', dest='build_swiftpm'),
401402
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
402403
SetTrueOption('--skstresstester', dest='build_skstresstester'),
404+
SetTrueOption('--swiftevolve', dest='build_swiftevolve'),
403405
SetTrueOption('-B', dest='benchmark'),
404406
SetTrueOption('-S', dest='skip_build'),
405407
SetTrueOption('-b', dest='build_llbuild'),

0 commit comments

Comments
 (0)