Skip to content

Commit 2e720c3

Browse files
author
Nathan Hawes
authored
Merge pull request #20160 from nathawes/build-script-skstresstester
[build-script] Update build-script to support building and installing the SourceKit stress tester
2 parents 40f45f7 + 5a4ea90 commit 2e720c3

File tree

6 files changed

+115
-10
lines changed

6 files changed

+115
-10
lines changed

utils/build-presets.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,8 @@ watchos
10211021
lldb
10221022
llbuild
10231023
swiftpm
1024+
swiftsyntax
1025+
skstresstester
10241026
playgroundsupport
10251027

10261028
# Build with debug info, this allows us to symbolicate crashes from
@@ -1044,6 +1046,9 @@ install-swift
10441046
install-lldb
10451047
install-llbuild
10461048
install-swiftpm
1049+
install-swiftsyntax
1050+
skip-install-swiftsyntax-module
1051+
install-skstresstester
10471052
install-playgroundsupport
10481053

10491054
install-destdir=%(install_destdir)s
@@ -1151,10 +1156,7 @@ skip-test-lldb
11511156
skip-test-cmark
11521157
skip-test-playgroundsupport
11531158
skip-test-swiftsyntax
1154-
1155-
swiftsyntax
1156-
install-swiftsyntax
1157-
skip-install-swiftsyntax-module
1159+
skip-test-skstresstester
11581160

11591161
#===------------------------------------------------------------------------===#
11601162
# LLDB build configurations

utils/build-script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ class BuildScriptInvocation(object):
474474
"--xctest-build-type", args.build_variant,
475475
"--swiftpm-build-type", args.build_variant,
476476
"--swiftsyntax-build-type", args.build_variant,
477+
"--skstresstester-build-type", args.build_variant,
477478
"--llbuild-build-type", args.build_variant,
478479
"--swift-enable-assertions", str(args.swift_assertions).lower(),
479480
"--swift-stdlib-enable-assertions", str(
@@ -593,6 +594,8 @@ class BuildScriptInvocation(object):
593594
impl_args += ["--skip-build-swiftpm"]
594595
if not args.build_swiftsyntax:
595596
impl_args += ["--skip-build-swiftsyntax"]
597+
if not args.build_skstresstester:
598+
impl_args += ["--skip-build-skstresstester"]
596599
if not args.build_playgroundsupport:
597600
impl_args += ["--skip-build-playgroundsupport"]
598601
if args.build_swift_dynamic_stdlib:
@@ -637,6 +640,7 @@ class BuildScriptInvocation(object):
637640
"--skip-test-llbuild",
638641
"--skip-test-swiftpm",
639642
"--skip-test-swiftsyntax",
643+
"--skip-test-skstresstester",
640644
"--skip-test-xctest",
641645
"--skip-test-foundation",
642646
"--skip-test-libdispatch",

utils/build-script-impl

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ KNOWN_SETTINGS=(
8383
xctest-build-type "Debug" "the build variant for xctest"
8484
swiftpm-build-type "Debug" "the build variant for swiftpm"
8585
swiftsyntax-build-type "Debug" "the build variant for swiftSyntax"
86+
skstresstester-build-type "Debug" "the build variant for the SourceKit stress tester"
8687
llbuild-enable-assertions "1" "enable assertions in llbuild"
8788
enable-asan "" "enable Address Sanitizer"
8889
enable-ubsan "" "enable Undefined Behavior Sanitizer"
@@ -124,6 +125,7 @@ KNOWN_SETTINGS=(
124125
skip-build-llbuild "" "set to skip building llbuild"
125126
skip-build-swiftpm "" "set to skip building swiftpm"
126127
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
128+
skip-build-skstresstester "" "set to skip building the SourceKit stress tester"
127129
skip-build-xctest "" "set to skip building xctest"
128130
skip-build-foundation "" "set to skip building foundation"
129131
skip-build-libdispatch "" "set to skip building libdispatch"
@@ -137,6 +139,7 @@ KNOWN_SETTINGS=(
137139
skip-test-llbuild "" "set to skip testing llbuild"
138140
skip-test-swiftpm "" "set to skip testing swiftpm"
139141
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
142+
skip-test-skstresstester "" "set to skip testing the SourceKit stress tester"
140143
skip-test-xctest "" "set to skip testing xctest"
141144
skip-test-foundation "" "set to skip testing foundation"
142145
skip-test-libdispatch "" "set to skip testing libdispatch"
@@ -193,6 +196,7 @@ KNOWN_SETTINGS=(
193196
install-swiftpm "" "whether to install swiftpm"
194197
install-swiftsyntax "" "whether to install swiftsyntax"
195198
skip-install-swiftsyntax-module "" "set to skip installing swiftsyntax modules"
199+
install-skstresstester "" "whether to install the SourceKit stress tester"
196200
install-xctest "" "whether to install xctest"
197201
install-foundation "" "whether to install foundation"
198202
install-libdispatch "" "whether to install libdispatch"
@@ -1171,6 +1175,7 @@ LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
11711175
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
11721176
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
11731177
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
1178+
SKSTRESSTESTER_SOURCE_DIR="${WORKSPACE}/swift-stress-tester/SourceKitStressTester"
11741179
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11751180
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11761181
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
@@ -1211,8 +1216,9 @@ PRODUCTS=("${PRODUCTS[@]}" swift)
12111216
if [[ ! "${SKIP_BUILD_LLDB}" ]] ; then
12121217
PRODUCTS=("${PRODUCTS[@]}" lldb)
12131218
fi
1214-
# LLBuild, SwiftPM, SwiftSyntax and XCTest are dependent on Foundation, so Foundation must be
1215-
# added to the list of build products first.
1219+
# LLBuild, SwiftPM, SwiftSyntax, the SourceKit stress tester and XCTest are
1220+
# dependent on Foundation, so Foundation must be added to the list of build
1221+
# products first.
12161222
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
12171223
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
12181224
fi
@@ -1225,19 +1231,24 @@ fi
12251231
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
12261232
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
12271233
fi
1228-
# SwiftPM and SwiftSyntax are dependent on XCTest, so XCTest must be added to the list of
1229-
# build products first.
1234+
# SwiftPM, SwiftSyntax and the SourceKit stress tester are dependent on XCTest,
1235+
# so XCTest must be added to the list of build products first.
12301236
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
12311237
PRODUCTS=("${PRODUCTS[@]}" xctest)
12321238
fi
1233-
# SwiftSyntax is dependent on SwiftPM, so SwiftPM must be added to the list of
1234-
# build products first.
1239+
# SwiftSyntax and the SourceKit stress tester are dependent on SwiftPM, so
1240+
# SwiftPM must be added to the list of build products first.
12351241
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
12361242
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
12371243
fi
1244+
# The SourceKit stress tester is dependent on SwiftSyntax, so it must be added
1245+
# to the list of build products first.
12381246
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
12391247
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
12401248
fi
1249+
if [[ ! "${SKIP_BUILD_SKSTRESSTESTER}" ]] ; then
1250+
PRODUCTS=("${PRODUCTS[@]}" skstresstester)
1251+
fi
12411252

12421253
# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
12431254
function contains_product() {
@@ -1548,6 +1559,9 @@ function build_directory_bin() {
15481559
swiftsyntax)
15491560
echo "${root}/${SWIFTSYNTAX_BUILD_TYPE}/bin"
15501561
;;
1562+
skstresstester)
1563+
echo "${root}/${SKSTRESSTESTER_BUILD_TYPE}/bin"
1564+
;;
15511565
xctest)
15521566
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
15531567
;;
@@ -1687,6 +1701,9 @@ function cmake_config_opt() {
16871701
swiftsyntax)
16881702
echo "--config ${SWIFTSYNTAX_BUILD_TYPE}"
16891703
;;
1704+
skstresstester)
1705+
echo "--config ${SKSTRESSTESTER_BUILD_TYPE}"
1706+
;;
16901707
xctest)
16911708
echo "--config ${XCTEST_BUILD_TYPE}"
16921709
;;
@@ -1796,6 +1813,36 @@ function set_swiftsyntax_build_command() {
17961813
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
17971814
}
17981815

1816+
function set_skstresstester_build_command() {
1817+
if [ "${SKIP_BUILD_SWIFTSYNTAX}" ]; then
1818+
echo "Error: Cannot build the SourceKit stress tester without SwiftSyntax."
1819+
exit 1
1820+
fi
1821+
1822+
local swiftsyntax_config="debug"
1823+
if [[ $(is_cmake_release_build_type "${SWIFTSYNTAX_BUILD_TYPE}") ]] ; then
1824+
swiftsyntax_config="release"
1825+
fi
1826+
local config="debug"
1827+
if [[ $(is_cmake_release_build_type "${SKSTRESSTESTER_BUILD_TYPE}") ]] ; then
1828+
config="release"
1829+
fi
1830+
1831+
skstresstester_build_command=("${SKSTRESSTESTER_SOURCE_DIR}/Utilities/build-script-helper.py")
1832+
if [[ "${VERBOSE_BUILD}" ]] ; then
1833+
skstresstester_build_command+=(-v)
1834+
fi
1835+
1836+
skstresstester_build_command+=(
1837+
--build-dir="${build_dir}"
1838+
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
1839+
--swift-build-exec="${SWIFT_BUILD}"
1840+
--swift-test-exec="${SWIFT_TEST}"
1841+
--sourcekitd-dir="$(build_directory ${host} swift)/lib"
1842+
--swiftsyntax-dir="$(build_directory ${host} swiftsyntax)/${swiftsyntax_config}"
1843+
--config="${config}")
1844+
}
1845+
17991846
# Construct the appropriate options to pass to an Xcode
18001847
# build of any LLDB target.
18011848
function set_lldb_xcodebuild_options() {
@@ -2474,6 +2521,16 @@ for host in "${ALL_HOSTS[@]}"; do
24742521
set_swiftsyntax_build_command
24752522
call "${swiftsyntax_build_command[@]}"
24762523

2524+
continue
2525+
;;
2526+
skstresstester)
2527+
if [[ "$(uname -s)" != "Darwin" ]]; then
2528+
echo "error: unable to build swift-stress-tester on this platform"
2529+
continue
2530+
fi
2531+
set_skstresstester_build_command
2532+
call "${skstresstester_build_command[@]}"
2533+
24772534
continue
24782535
;;
24792536
xctest)
@@ -3088,6 +3145,14 @@ for host in "${ALL_HOSTS[@]}"; do
30883145
# As swiftSyntax tests itself, we break early here.
30893146
continue
30903147
;;
3148+
skstresstester)
3149+
if [[ "${SKIP_TEST_SKSTRESSTESTER}" ]]; then
3150+
continue
3151+
fi
3152+
echo "--- Running tests for ${product} ---"
3153+
call "${skstresstester_build_command[@]}" test
3154+
continue
3155+
;;
30913156
xctest)
30923157
if [[ "${SKIP_TEST_XCTEST}" ]]; then
30933158
continue
@@ -3401,6 +3466,23 @@ for host in "${ALL_HOSTS[@]}"; do
34013466
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --install
34023467
fi
34033468

3469+
continue
3470+
;;
3471+
skstresstester)
3472+
if [[ -z "${INSTALL_SKSTRESSTESTER}" ]] ; then
3473+
continue
3474+
fi
3475+
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
3476+
echo "--install-destdir is required to install products."
3477+
exit 1
3478+
fi
3479+
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
3480+
echo "--install-swiftsyntax is required to install the SourceKit stress tester"
3481+
exit 1
3482+
fi
3483+
3484+
echo "--- Installing ${product} ---"
3485+
call "${skstresstester_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
34043486
continue
34053487
;;
34063488
xctest)

utils/build_swift/driver_arguments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ def create_argument_parser():
518518
option(['--swiftsyntax'], store_true('build_swiftsyntax'),
519519
help='build swiftSyntax')
520520

521+
option(['--skstresstester'], store_true('build_skstresstester'),
522+
help='build the SourceKit stress tester')
523+
521524
option('--xctest', toggle_true('build_xctest'),
522525
help='build xctest')
523526

@@ -985,6 +988,8 @@ def create_argument_parser():
985988
/llbuild (optional)
986989
/swiftpm (optional, requires llbuild)
987990
/swift-syntax (optional, requires swiftpm)
991+
/swift-stress-tester (optional,
992+
requires swift-syntax)
988993
/compiler-rt (optional)
989994
/swift-corelibs-xctest (optional)
990995
/swift-corelibs-foundation (optional)

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
'build_swift_stdlib_unittest_extra': False,
8181
'build_swiftpm': False,
8282
'build_swiftsyntax': False,
83+
'build_skstresstester': False,
8384
'build_tvos': True,
8485
'build_tvos_device': False,
8586
'build_tvos_simulator': False,
@@ -396,6 +397,7 @@ class IgnoreOption(_BaseOption):
396397
SetTrueOption('--skip-build'),
397398
SetTrueOption('--swiftpm', dest='build_swiftpm'),
398399
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
400+
SetTrueOption('--skstresstester', dest='build_skstresstester'),
399401
SetTrueOption('-B', dest='benchmark'),
400402
SetTrueOption('-S', dest='skip_build'),
401403
SetTrueOption('-b', dest='build_llbuild'),

utils/update_checkout/update-checkout-config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"remote": { "id": "apple/swift-package-manager" } },
1919
"swift-syntax": {
2020
"remote": { "id": "apple/swift-syntax" } },
21+
"swift-stress-tester": {
22+
"remote": { "id": "apple/swift-stress-tester" } },
2123
"compiler-rt": {
2224
"remote": { "id": "apple/swift-compiler-rt" } },
2325
"swift-corelibs-xctest": {
@@ -50,6 +52,7 @@
5052
"llbuild": "master",
5153
"swiftpm": "master",
5254
"swift-syntax": "master",
55+
"swift-stress-tester": "master",
5356
"compiler-rt": "stable",
5457
"swift-corelibs-xctest": "master",
5558
"swift-corelibs-foundation": "master",
@@ -74,6 +77,7 @@
7477
"llbuild": "master",
7578
"swiftpm": "master",
7679
"swift-syntax": "master",
80+
"swift-stress-tester": "master",
7781
"swift-corelibs-xctest": "master",
7882
"swift-corelibs-foundation": "master",
7983
"swift-corelibs-libdispatch": "master",
@@ -94,6 +98,7 @@
9498
"llbuild": "swift-3.0-branch",
9599
"swiftpm": "swift-3.0-branch",
96100
"swift-syntax": "master",
101+
"swift-stress-tester": "master",
97102
"compiler-rt": "swift-3.0-branch",
98103
"swift-corelibs-xctest": "swift-3.0-branch",
99104
"swift-corelibs-foundation": "swift-3.0-branch",
@@ -114,6 +119,7 @@
114119
"llbuild": "swift-3.1-branch",
115120
"swiftpm": "swift-3.1-branch",
116121
"swift-syntax": "master",
122+
"swift-stress-tester": "master",
117123
"compiler-rt": "swift-3.1-branch",
118124
"swift-corelibs-xctest": "swift-3.1-branch",
119125
"swift-corelibs-foundation": "swift-3.1-branch",
@@ -134,6 +140,7 @@
134140
"llbuild": "swift-4.0-branch",
135141
"swiftpm": "swift-4.0-branch",
136142
"swift-syntax": "master",
143+
"swift-stress-tester": "master",
137144
"compiler-rt": "swift-4.0-branch",
138145
"swift-corelibs-xctest": "swift-4.0-branch",
139146
"swift-corelibs-foundation": "swift-4.0-branch",
@@ -154,6 +161,7 @@
154161
"llbuild": "swift-4.1-branch",
155162
"swiftpm": "swift-4.1-branch",
156163
"swift-syntax": "master",
164+
"swift-stress-tester": "master",
157165
"compiler-rt": "swift-4.1-branch",
158166
"swift-corelibs-xctest": "swift-4.1-branch",
159167
"swift-corelibs-foundation": "swift-4.1-branch",
@@ -174,6 +182,7 @@
174182
"llbuild": "swift-4.2-branch",
175183
"swiftpm": "swift-4.2-branch",
176184
"swift-syntax": "swift-4.2-branch",
185+
"swift-stress-tester": "master",
177186
"compiler-rt": "swift-4.2-branch",
178187
"swift-corelibs-xctest": "swift-4.2-branch",
179188
"swift-corelibs-foundation": "swift-4.2-branch",
@@ -195,6 +204,7 @@
195204
"llbuild": "swift-5.0-branch",
196205
"swiftpm": "swift-5.0-branch",
197206
"swift-syntax": "swift-5.0-branch",
207+
"swift-stress-tester": "swift-5.0-branch",
198208
"swift-corelibs-xctest": "swift-5.0-branch",
199209
"swift-corelibs-foundation": "swift-5.0-branch",
200210
"swift-corelibs-libdispatch": "swift-5.0-branch",

0 commit comments

Comments
 (0)