Skip to content

Commit 8a6030b

Browse files
committed
Add build-script infrastructure to build swiftSyntax in its own repository
1 parent 5f34199 commit 8a6030b

File tree

5 files changed

+91
-4
lines changed

5 files changed

+91
-4
lines changed

utils/build-script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ class BuildScriptInvocation(object):
483483
"--libicu-build-type", args.libicu_build_variant,
484484
"--xctest-build-type", args.build_variant,
485485
"--swiftpm-build-type", args.build_variant,
486+
"--swiftsyntax-build-type", args.build_variant,
486487
"--llbuild-build-type", args.build_variant,
487488
"--swift-enable-assertions", str(args.swift_assertions).lower(),
488489
"--swift-stdlib-enable-assertions", str(
@@ -600,6 +601,8 @@ class BuildScriptInvocation(object):
600601
impl_args += ["--skip-build-libicu"]
601602
if not args.build_swiftpm:
602603
impl_args += ["--skip-build-swiftpm"]
604+
if not args.build_swiftsyntax:
605+
impl_args += ["--skip-build-swiftsyntax"]
603606
if not args.build_playgroundsupport:
604607
impl_args += ["--skip-build-playgroundsupport"]
605608
if args.build_swift_dynamic_stdlib:
@@ -643,6 +646,7 @@ class BuildScriptInvocation(object):
643646
"--skip-test-lldb",
644647
"--skip-test-llbuild",
645648
"--skip-test-swiftpm",
649+
"--skip-test-swiftsyntax",
646650
"--skip-test-xctest",
647651
"--skip-test-foundation",
648652
"--skip-test-libdispatch",

utils/build-script-impl

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ KNOWN_SETTINGS=(
8282
playgroundsupport-build-type "Debug" "the build variant for PlaygroundSupport"
8383
xctest-build-type "Debug" "the build variant for xctest"
8484
swiftpm-build-type "Debug" "the build variant for swiftpm"
85+
swiftsyntax-build-type "Debug" "the build variant for swiftSyntax"
8586
llbuild-enable-assertions "1" "enable assertions in llbuild"
8687
enable-asan "" "enable Address Sanitizer"
8788
enable-ubsan "" "enable Undefined Behavior Sanitizer"
@@ -122,6 +123,7 @@ KNOWN_SETTINGS=(
122123
skip-build-lldb "" "set to skip building LLDB"
123124
skip-build-llbuild "" "set to skip building llbuild"
124125
skip-build-swiftpm "" "set to skip building swiftpm"
126+
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
125127
skip-build-xctest "" "set to skip building xctest"
126128
skip-build-foundation "" "set to skip building foundation"
127129
skip-build-libdispatch "" "set to skip building libdispatch"
@@ -134,6 +136,7 @@ KNOWN_SETTINGS=(
134136
skip-test-swift "" "set to skip testing Swift"
135137
skip-test-llbuild "" "set to skip testing llbuild"
136138
skip-test-swiftpm "" "set to skip testing swiftpm"
139+
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
137140
skip-test-xctest "" "set to skip testing xctest"
138141
skip-test-foundation "" "set to skip testing foundation"
139142
skip-test-libdispatch "" "set to skip testing libdispatch"
@@ -142,7 +145,7 @@ KNOWN_SETTINGS=(
142145
skip-test-linux "" "set to skip testing Swift stdlibs for Linux"
143146
skip-test-freebsd "" "set to skip testing Swift stdlibs for FreeBSD"
144147
skip-test-cygwin "" "set to skip testing Swift stdlibs for Cygwin"
145-
skip-test-haiku "" "set to skip testing Swift stdlibs for Haiku"
148+
skip-test-haiku "" "set to skip testing Swift stdlibs for Haiku"
146149
skip-test-osx "" "set to skip testing Swift stdlibs for OS X"
147150
skip-test-ios-32bit-simulator "" "set to skip testing Swift stdlibs for iOS 32bit simulators"
148151
skip-test-ios-simulator "" "set to skip testing Swift stdlibs for iOS simulators (i.e. test devices only)"
@@ -1162,6 +1165,7 @@ CMARK_SOURCE_DIR="${WORKSPACE}/cmark"
11621165
LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
11631166
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
11641167
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
1168+
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
11651169
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11661170
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
11671171
LIBDISPATCH_SOURCE_DIR="${WORKSPACE}/swift-corelibs-libdispatch"
@@ -1202,7 +1206,7 @@ PRODUCTS=("${PRODUCTS[@]}" swift)
12021206
if [[ ! "${SKIP_BUILD_LLDB}" ]] ; then
12031207
PRODUCTS=("${PRODUCTS[@]}" lldb)
12041208
fi
1205-
# LLBuild, SwiftPM and XCTest are dependent on Foundation, so Foundation must be
1209+
# LLBuild, SwiftPM, SwiftSyntax and XCTest are dependent on Foundation, so Foundation must be
12061210
# added to the list of build products first.
12071211
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
12081212
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
@@ -1216,14 +1220,19 @@ fi
12161220
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
12171221
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
12181222
fi
1219-
# SwiftPM is dependent on XCTest, so XCTest must be added to the list of
1223+
# SwiftPM and SwiftSyntax are dependent on XCTest, so XCTest must be added to the list of
12201224
# build products first.
12211225
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
12221226
PRODUCTS=("${PRODUCTS[@]}" xctest)
12231227
fi
1228+
# SwiftSyntax is dependent on SwiftPM, so SwiftPM must be added to the list of
1229+
# build products first.
12241230
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
12251231
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
12261232
fi
1233+
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
1234+
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
1235+
fi
12271236

12281237
# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
12291238
function contains_product() {
@@ -1531,6 +1540,9 @@ function build_directory_bin() {
15311540
swiftpm)
15321541
echo "${root}/${SWIFTPM_BUILD_TYPE}/bin"
15331542
;;
1543+
swiftsyntax)
1544+
echo "${root}/${SWIFTSYNTAX_BUILD_TYPE}/bin"
1545+
;;
15341546
xctest)
15351547
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
15361548
;;
@@ -1551,7 +1563,13 @@ function build_directory_bin() {
15511563
;;
15521564
esac
15531565
else
1554-
echo "${root}/bin"
1566+
if [[ "${product}" == "swiftpm" ]] ; then
1567+
# All projects that call this depend on SwiftPM so we know that
1568+
# swiftpm_bootstrap_command has already been set
1569+
echo "$(${swiftpm_bootstrap_command[@]} --show-bin-path)"
1570+
else
1571+
echo "${root}/bin"
1572+
fi
15551573
fi
15561574
}
15571575

@@ -1661,6 +1679,9 @@ function cmake_config_opt() {
16611679
swiftpm)
16621680
echo "--config ${SWIFTPM_BUILD_TYPE}"
16631681
;;
1682+
swiftsyntax)
1683+
echo "--config ${SWIFTSYNTAX_BUILD_TYPE}"
1684+
;;
16641685
xctest)
16651686
echo "--config ${XCTEST_BUILD_TYPE}"
16661687
;;
@@ -1703,6 +1724,10 @@ function set_swiftpm_bootstrap_command() {
17031724
echo "Error: Cannot build swiftpm without llbuild (swift-build-tool)."
17041725
exit 1
17051726
fi
1727+
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then
1728+
echo "Error: Cannot build swiftpm when llbuild is built using Xcode."
1729+
exit 1
1730+
fi
17061731
swiftpm_bootstrap_command=("${SWIFTPM_SOURCE_DIR}/Utilities/bootstrap" "${swiftpm_bootstrap_options[@]}")
17071732
# Add --release if we have to build in release mode.
17081733
if [[ "${SWIFTPM_BUILD_TYPE}" == "Release" ]] ; then
@@ -1741,6 +1766,29 @@ function set_swiftpm_bootstrap_command() {
17411766
fi
17421767
}
17431768

1769+
function set_swiftsyntax_build_command() {
1770+
if [ "${SKIP_BUILD_SWIFTPM}" ]; then
1771+
echo "Error: Cannot build swiftsyntax without swiftpm."
1772+
exit 1
1773+
fi
1774+
1775+
swiftsyntax_build_command=("${SWIFTSYNTAX_SOURCE_DIR}/build-script.py")
1776+
# Add --release if we have to build in release mode.
1777+
if [[ $(is_cmake_release_build_type "${SWIFTSYNTAX_BUILD_TYPE}") ]] ; then
1778+
swiftsyntax_build_command+=(--release)
1779+
fi
1780+
if [[ "${VERBOSE_BUILD}" ]] ; then
1781+
swiftsyntax_build_command+=(-v)
1782+
fi
1783+
swiftsyntax_build_command+=(
1784+
--build-dir="${build_dir}"
1785+
--swift-build-exec="$(build_directory_bin ${LOCAL_HOST} swiftpm)/swift-build"
1786+
--swift-test-exec="$(build_directory_bin ${LOCAL_HOST} swiftpm)/swift-test"
1787+
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
1788+
--swift-syntax-test-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swift-syntax-test"
1789+
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
1790+
}
1791+
17441792
# Construct the appropriate options to pass to an Xcode
17451793
# build of any LLDB target.
17461794
function set_lldb_xcodebuild_options() {
@@ -2398,6 +2446,12 @@ for host in "${ALL_HOSTS[@]}"; do
23982446
call "${swiftpm_bootstrap_command[@]}"
23992447

24002448
# swiftpm installs itself with a bootstrap method. No further cmake building is performed.
2449+
continue
2450+
;;
2451+
swiftsyntax)
2452+
set_swiftsyntax_build_command
2453+
call "${swiftsyntax_build_command[@]}"
2454+
24012455
continue
24022456
;;
24032457
xctest)
@@ -2937,6 +2991,15 @@ for host in "${ALL_HOSTS[@]}"; do
29372991
# As swiftpm tests itself, we break early here.
29382992
continue
29392993
;;
2994+
swiftsyntax)
2995+
if [[ "${SKIP_TEST_SWIFTSYNTAX}" ]]; then
2996+
continue
2997+
fi
2998+
echo "--- Running tests for ${product} ---"
2999+
call "${swiftsyntax_build_command[@]}" -t
3000+
# As swiftSyntax tests itself, we break early here.
3001+
continue
3002+
;;
29403003
xctest)
29413004
if [[ "${SKIP_TEST_XCTEST}" ]]; then
29423005
continue
@@ -3216,6 +3279,10 @@ for host in "${ALL_HOSTS[@]}"; do
32163279
# As swiftpm bootstraps the installation itself, we break early here.
32173280
continue
32183281
;;
3282+
swiftsyntax)
3283+
# SwiftSyntax is not installed as part of the toolchain
3284+
continue
3285+
;;
32193286
xctest)
32203287
if [[ -z "${INSTALL_XCTEST}" ]] ; then
32213288
continue

utils/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ def create_argument_parser():
505505
option(['-p', '--swiftpm'], store_true('build_swiftpm'),
506506
help='build swiftpm')
507507

508+
option(['--swiftsyntax'], store_true('build_swiftsyntax'),
509+
help='build swiftSyntax')
510+
508511
option('--xctest', toggle_true('build_xctest'),
509512
help='build xctest')
510513

@@ -971,6 +974,7 @@ def create_argument_parser():
971974
/lldb (optional)
972975
/llbuild (optional)
973976
/swiftpm (optional, requires llbuild)
977+
/swift-syntax (optional, requires swiftpm)
974978
/compiler-rt (optional)
975979
/swift-corelibs-xctest (optional)
976980
/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
@@ -79,6 +79,7 @@
7979
'build_swift_static_stdlib': False,
8080
'build_swift_stdlib_unittest_extra': False,
8181
'build_swiftpm': False,
82+
'build_swiftsyntax': False,
8283
'build_tvos': True,
8384
'build_tvos_device': False,
8485
'build_tvos_simulator': False,
@@ -394,6 +395,7 @@ class IgnoreOption(_BaseOption):
394395
SetTrueOption('--playgroundsupport', dest='build_playgroundsupport'),
395396
SetTrueOption('--skip-build'),
396397
SetTrueOption('--swiftpm', dest='build_swiftpm'),
398+
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
397399
SetTrueOption('-B', dest='benchmark'),
398400
SetTrueOption('-S', dest='skip_build'),
399401
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
@@ -16,6 +16,8 @@
1616
"remote": { "id": "apple/swift-llbuild" } },
1717
"swiftpm": {
1818
"remote": { "id": "apple/swift-package-manager" } },
19+
"swift-syntax": {
20+
"remote": { "id": "apple/swift-syntax" } },
1921
"compiler-rt": {
2022
"remote": { "id": "apple/swift-compiler-rt" } },
2123
"swift-corelibs-xctest": {
@@ -43,6 +45,7 @@
4345
"cmark": "master",
4446
"llbuild": "master",
4547
"swiftpm": "master",
48+
"swift-syntax": "master",
4649
"compiler-rt": "stable",
4750
"swift-corelibs-xctest": "master",
4851
"swift-corelibs-foundation": "master",
@@ -65,6 +68,7 @@
6568
"cmark": "master",
6669
"llbuild": "master",
6770
"swiftpm": "master",
71+
"swift-syntax": "master",
6872
"swift-corelibs-xctest": "master",
6973
"swift-corelibs-foundation": "master",
7074
"swift-corelibs-libdispatch": "master",
@@ -83,6 +87,7 @@
8387
"cmark": "swift-3.0-branch",
8488
"llbuild": "swift-3.0-branch",
8589
"swiftpm": "swift-3.0-branch",
90+
"swift-syntax": "master",
8691
"compiler-rt": "swift-3.0-branch",
8792
"swift-corelibs-xctest": "swift-3.0-branch",
8893
"swift-corelibs-foundation": "swift-3.0-branch",
@@ -102,6 +107,7 @@
102107
"cmark": "swift-3.1-branch",
103108
"llbuild": "swift-3.1-branch",
104109
"swiftpm": "swift-3.1-branch",
110+
"swift-syntax": "master",
105111
"compiler-rt": "swift-3.1-branch",
106112
"swift-corelibs-xctest": "swift-3.1-branch",
107113
"swift-corelibs-foundation": "swift-3.1-branch",
@@ -121,6 +127,7 @@
121127
"cmark": "swift-4.0-branch",
122128
"llbuild": "swift-4.0-branch",
123129
"swiftpm": "swift-4.0-branch",
130+
"swift-syntax": "master",
124131
"compiler-rt": "swift-4.0-branch",
125132
"swift-corelibs-xctest": "swift-4.0-branch",
126133
"swift-corelibs-foundation": "swift-4.0-branch",
@@ -140,6 +147,7 @@
140147
"cmark": "swift-4.1-branch",
141148
"llbuild": "swift-4.1-branch",
142149
"swiftpm": "swift-4.1-branch",
150+
"swift-syntax": "master",
143151
"compiler-rt": "swift-4.1-branch",
144152
"swift-corelibs-xctest": "swift-4.1-branch",
145153
"swift-corelibs-foundation": "swift-4.1-branch",
@@ -159,6 +167,7 @@
159167
"cmark": "swift-4.2-branch",
160168
"llbuild": "swift-4.2-branch",
161169
"swiftpm": "swift-4.2-branch",
170+
"swift-syntax": "swift-4.2-branch",
162171
"compiler-rt": "swift-4.2-branch",
163172
"swift-corelibs-xctest": "swift-4.2-branch",
164173
"swift-corelibs-foundation": "swift-4.2-branch",
@@ -179,6 +188,7 @@
179188
"cmark": "master",
180189
"llbuild": "master",
181190
"swiftpm": "master",
191+
"swift-syntax": "master",
182192
"swift-corelibs-xctest": "master",
183193
"swift-corelibs-foundation": "master",
184194
"swift-corelibs-libdispatch": "master",

0 commit comments

Comments
 (0)