Skip to content

Commit 7ed085c

Browse files
committed
[build-script] Migrate SwiftSyntax to swift_build_support
1 parent d5c28d8 commit 7ed085c

File tree

9 files changed

+136
-148
lines changed

9 files changed

+136
-148
lines changed

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,12 +1096,6 @@ endif()
10961096
# declares the swift-stdlib-* set of targets. These targets will then
10971097
# implicitly depend on any targets declared with IS_STDLIB.
10981098
#
1099-
# One such library that declares IS_STDLIB is SwiftSyntax, living in
1100-
# tools/SwiftSyntax. If we include stdlib/ after tools/,
1101-
# the swift-stdlib-* set of targets will not have been generated yet,
1102-
# causing the implicit dependency for SwiftSyntax to silently not be
1103-
# created. This then will cause SwiftSyntax to fail to build.
1104-
#
11051099
# https://bugs.swift.org/browse/SR-5975
11061100
if(SWIFT_BUILD_STDLIB)
11071101
add_subdirectory(stdlib)
@@ -1126,7 +1120,7 @@ add_subdirectory(include)
11261120

11271121
if(SWIFT_INCLUDE_TOOLS)
11281122
add_subdirectory(lib)
1129-
1123+
11301124
# Always include this after including stdlib/!
11311125
# Refer to the large comment above the add_subdirectory(stdlib) call.
11321126
# https://bugs.swift.org/browse/SR-5975

utils/build-script

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ class BuildScriptInvocation(object):
338338
"--libicu-build-type", args.libicu_build_variant,
339339
"--xctest-build-type", args.build_variant,
340340
"--swiftpm-build-type", args.build_variant,
341-
"--swiftsyntax-build-type", args.build_variant,
342341
"--llbuild-build-type", args.build_variant,
343342
"--swift-enable-assertions", str(args.swift_assertions).lower(),
344343
"--swift-stdlib-enable-assertions", str(
@@ -467,8 +466,6 @@ class BuildScriptInvocation(object):
467466
impl_args += ["--skip-build-libicu"]
468467
if not args.build_swiftpm:
469468
impl_args += ["--skip-build-swiftpm"]
470-
if not args.build_swiftsyntax:
471-
impl_args += ["--skip-build-swiftsyntax"]
472469
if not args.build_playgroundsupport:
473470
impl_args += ["--skip-build-playgroundsupport"]
474471
if args.build_swift_dynamic_stdlib:
@@ -512,7 +509,6 @@ class BuildScriptInvocation(object):
512509
"--skip-test-lldb",
513510
"--skip-test-llbuild",
514511
"--skip-test-swiftpm",
515-
"--skip-test-swiftsyntax",
516512
"--skip-test-xctest",
517513
"--skip-test-foundation",
518514
"--skip-test-libdispatch",
@@ -817,10 +813,14 @@ class BuildScriptInvocation(object):
817813
build_dir=self.workspace.build_dir(
818814
host_target, product_name))
819815
if product.should_build(host_target):
816+
print("--- Building %s ---" % product_name)
820817
product.build(host_target)
821818
if product.should_test(host_target):
819+
print("--- Running tests for %s ---" % product_name)
822820
product.test(host_target)
821+
print("--- Finished tests for %s ---" % product_name)
823822
if product.should_install(host_target):
823+
print("--- Installing %s ---" % product_name)
824824
product.install(host_target)
825825

826826
# Extract symbols...

utils/build-script-impl

Lines changed: 5 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ KNOWN_SETTINGS=(
7979
playgroundsupport-build-type "Debug" "the build variant for PlaygroundSupport"
8080
xctest-build-type "Debug" "the build variant for xctest"
8181
swiftpm-build-type "Debug" "the build variant for swiftpm"
82-
swiftsyntax-build-type "Debug" "the build variant for swiftSyntax"
83-
# When this flag is set, the build-script will only build/install the swift-syntax parser
84-
# This is a temporary workaround of having a separate build product for swift-syntax parser
85-
skip-swiftsyntax-swiftside "" "skip building/installing the swift side of swiftsyntax"
8682
llbuild-enable-assertions "1" "enable assertions in llbuild"
8783
enable-asan "" "enable Address Sanitizer"
8884
enable-ubsan "" "enable Undefined Behavior Sanitizer"
@@ -101,8 +97,6 @@ KNOWN_SETTINGS=(
10197
installable-package "" "the path to the archive of the installation directory"
10298
test-installable-package "" "whether to run post-packaging tests on the produced package"
10399
reconfigure "" "force a CMake configuration run even if CMakeCache.txt already exists"
104-
build-libparser-only "" "only build libSwiftSyntaxParser"
105-
libparser-ver "" "current version of libSwiftSyntaxParser"
106100
skip-reconfigure "" "set to skip reconfigure"
107101
swift-primary-variant-sdk "" "default SDK for target binaries"
108102
swift-primary-variant-arch "" "default arch for target binaries"
@@ -126,7 +120,6 @@ KNOWN_SETTINGS=(
126120
skip-build-llbuild "" "set to skip building llbuild"
127121
skip-build-libcxx "" "set to skip building libcxx"
128122
skip-build-swiftpm "" "set to skip building swiftpm"
129-
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
130123
skip-build-xctest "" "set to skip building xctest"
131124
skip-build-foundation "" "set to skip building foundation"
132125
skip-build-libdispatch "" "set to skip building libdispatch"
@@ -140,7 +133,6 @@ KNOWN_SETTINGS=(
140133
skip-test-swift "" "set to skip testing Swift"
141134
skip-test-llbuild "" "set to skip testing llbuild"
142135
skip-test-swiftpm "" "set to skip testing swiftpm"
143-
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
144136
skip-test-xctest "" "set to skip testing xctest"
145137
skip-test-foundation "" "set to skip testing foundation"
146138
skip-test-libdispatch "" "set to skip testing libdispatch"
@@ -198,9 +190,6 @@ KNOWN_SETTINGS=(
198190
install-lldb "" "whether to install LLDB"
199191
install-llbuild "" "whether to install llbuild"
200192
install-swiftpm "" "whether to install swiftpm"
201-
install-swiftsyntax "" "whether to install swiftsyntax"
202-
skip-install-swiftsyntax-module "" "set to skip installing swiftsyntax modules"
203-
swiftsyntax-verify-generated-files "" "set to verify that the generated files in the source tree match the ones that would be generated from current master"
204193
install-xctest "" "whether to install xctest"
205194
install-foundation "" "whether to install foundation"
206195
install-libcxx "" "whether to install libc++"
@@ -1191,7 +1180,6 @@ CMARK_SOURCE_DIR="${WORKSPACE}/cmark"
11911180
LLDB_SOURCE_DIR="${WORKSPACE}/lldb"
11921181
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
11931182
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
1194-
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
11951183
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester"
11961184
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
11971185
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
@@ -1245,8 +1233,8 @@ PRODUCTS=("${PRODUCTS[@]}" swift)
12451233
if [[ ! "${SKIP_BUILD_LLDB}" ]] ; then
12461234
PRODUCTS=("${PRODUCTS[@]}" lldb)
12471235
fi
1248-
# LLBuild, SwiftPM, SwiftSyntax and XCTest are dependent on Foundation, so
1249-
# Foundation must be added to the list of build products first.
1236+
# LLBuild, SwiftPM and XCTest are dependent on Foundation, so Foundation must
1237+
# be added to the list of build products first.
12501238
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
12511239
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
12521240
if [[ -z "${SKIP_BUILD_SWIFT_STATIC_LIBDISPATCH}" ]] ; then
@@ -1265,19 +1253,14 @@ fi
12651253
if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" ]] ; then
12661254
PRODUCTS=("${PRODUCTS[@]}" playgroundsupport)
12671255
fi
1268-
# SwiftPM and SwiftSyntax are dependent on XCTest, so XCTest must be added to
1269-
# the list of build products first.
1256+
# SwiftPM is dependent on XCTest, so XCTest must be added to the list of build
1257+
# products first.
12701258
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
12711259
PRODUCTS=("${PRODUCTS[@]}" xctest)
12721260
fi
1273-
# SwiftSyntax is dependent on SwiftPM, so SwiftPM must be added to the list of
1274-
# build products first.
12751261
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
12761262
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
12771263
fi
1278-
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
1279-
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
1280-
fi
12811264

12821265
# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
12831266
function contains_product() {
@@ -1583,9 +1566,6 @@ function build_directory_bin() {
15831566
swiftpm)
15841567
echo "${root}/${SWIFTPM_BUILD_TYPE}/bin"
15851568
;;
1586-
swiftsyntax)
1587-
echo "${root}/${SWIFTSYNTAX_BUILD_TYPE}/bin"
1588-
;;
15891569
xctest)
15901570
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
15911571
;;
@@ -1728,9 +1708,6 @@ function cmake_config_opt() {
17281708
swiftpm)
17291709
echo "--config ${SWIFTPM_BUILD_TYPE}"
17301710
;;
1731-
swiftsyntax)
1732-
echo "--config ${SWIFTSYNTAX_BUILD_TYPE}"
1733-
;;
17341711
xctest)
17351712
echo "--config ${XCTEST_BUILD_TYPE}"
17361713
;;
@@ -1821,43 +1798,13 @@ function set_swiftpm_bootstrap_command() {
18211798

18221799
function swiftpm_find_tool() {
18231800
tool=$1
1824-
if [[ "${SKIP_BUILD_SWIFTPM}" || "${BUILD_LIBPARSER_ONLY}" ]]; then
1801+
if [[ "${SKIP_BUILD_SWIFTPM}" ]]; then
18251802
echo "$(xcrun_find_tool ${tool})"
18261803
else
18271804
echo "$(build_directory_bin ${LOCAL_HOST} swiftpm)/${tool}"
18281805
fi
18291806
}
18301807

1831-
function set_swiftsyntax_build_command() {
1832-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
1833-
# we don't have a compiler built so we have to use the one in the environment.
1834-
SWIFTC_BIN="$(xcrun_find_tool swiftc)"
1835-
else
1836-
SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
1837-
fi
1838-
1839-
swiftsyntax_build_command=("${SWIFTSYNTAX_SOURCE_DIR}/build-script.py")
1840-
# Add --release if we have to build in release mode.
1841-
if [[ $(is_cmake_release_build_type "${SWIFTSYNTAX_BUILD_TYPE}") ]] ; then
1842-
swiftsyntax_build_command+=(--release)
1843-
fi
1844-
if [[ "${VERBOSE_BUILD}" ]] ; then
1845-
swiftsyntax_build_command+=(-v)
1846-
fi
1847-
swiftsyntax_build_command+=(
1848-
--build-dir="$(build_directory ${host} swiftsyntax)"
1849-
--swift-build-exec="$(swiftpm_find_tool swift-build)"
1850-
--swift-test-exec="$(swiftpm_find_tool swift-test)"
1851-
--swiftc-exec="${SWIFTC_BIN}"
1852-
--syntax-parser-header-dir="${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser"
1853-
--syntax-parser-lib-dir="$(build_directory ${host} swift)/lib"
1854-
--swift-syntax-test-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swift-syntax-test"
1855-
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
1856-
if [[ "${SWIFTSYNTAX_VERIFY_GENERATED_FILES}" ]] ; then
1857-
swiftsyntax_build_command+=(--verify-generated-files)
1858-
fi
1859-
}
1860-
18611808
#
18621809
# Configure and build each product
18631810
#
@@ -2358,15 +2305,6 @@ for host in "${ALL_HOSTS[@]}"; do
23582305
build_targets=("${build_targets[@]}"
23592306
"${SWIFT_BENCHMARK_TARGETS[@]}")
23602307
fi
2361-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
2362-
build_targets=(libSwiftSyntaxParser)
2363-
if [ "${LIBPARSER_VER}" ] ; then
2364-
cmake_options=(
2365-
"${cmake_options[@]}"
2366-
-DSWIFT_LIBPARSER_VER:STRING="${LIBPARSER_VER}"
2367-
)
2368-
fi
2369-
fi
23702308
skip_build=${SKIP_BUILD_SWIFT}
23712309
;;
23722310
lldb)
@@ -2501,15 +2439,6 @@ for host in "${ALL_HOSTS[@]}"; do
25012439
call "${swiftpm_bootstrap_command[@]}"
25022440

25032441
# swiftpm installs itself with a bootstrap method. No further cmake building is performed.
2504-
continue
2505-
;;
2506-
swiftsyntax)
2507-
if [[ "${SKIP_SWIFTSYNTAX_SWIFTSIDE}" ]]; then
2508-
continue
2509-
fi
2510-
set_swiftsyntax_build_command
2511-
call "${swiftsyntax_build_command[@]}"
2512-
25132442
continue
25142443
;;
25152444
xctest)
@@ -3014,16 +2943,6 @@ for host in "${ALL_HOSTS[@]}"; do
30142943
# As swiftpm tests itself, we break early here.
30152944
continue
30162945
;;
3017-
swiftsyntax)
3018-
if [[ "${SKIP_TEST_SWIFTSYNTAX}" ]]; then
3019-
continue
3020-
fi
3021-
echo "--- Running tests for ${product} ---"
3022-
set_swiftsyntax_build_command
3023-
call "${swiftsyntax_build_command[@]}" -t
3024-
# As swiftSyntax tests itself, we break early here.
3025-
continue
3026-
;;
30272946
xctest)
30282947
if [[ "${SKIP_TEST_XCTEST}" ]]; then
30292948
continue
@@ -3308,11 +3227,6 @@ for host in "${ALL_HOSTS[@]}"; do
33083227
continue
33093228
fi
33103229
INSTALL_TARGETS=install-swift-components
3311-
# Swift syntax parser is currently a sub-product of Swift;
3312-
# We need to specify the install target separately here.
3313-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
3314-
INSTALL_TARGETS=tools/libSwiftSyntaxParser/install
3315-
fi
33163230
;;
33173231
llbuild)
33183232
if [[ -z "${INSTALL_LLBUILD}" ]] ; then
@@ -3343,43 +3257,6 @@ for host in "${ALL_HOSTS[@]}"; do
33433257
set_swiftpm_bootstrap_command
33443258
call "${swiftpm_bootstrap_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
33453259
# As swiftpm bootstraps the installation itself, we break early here.
3346-
continue
3347-
;;
3348-
swiftsyntax)
3349-
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
3350-
continue
3351-
fi
3352-
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
3353-
echo "--install-destdir is required to install products."
3354-
exit 1
3355-
fi
3356-
echo "--- Installing ${product} ---"
3357-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
3358-
# We don't have a toolchain so we should install to the specified dir
3359-
DYLIB_DIR="${INSTALL_DESTDIR}"
3360-
MODULE_DIR="${INSTALL_DESTDIR}/${product}.swiftmodule"
3361-
# Create the install dir if it doesn't exist
3362-
call mkdir -p "${INSTALL_DESTDIR}"
3363-
# Install libParser is necessary
3364-
rsync -a "$(build_directory ${host} swift)/lib/lib_InternalSwiftSyntaxParser.dylib" "${INSTALL_DESTDIR}"
3365-
# Install module map of libParser so client can import SwiftSyntax
3366-
rsync -a "${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser" "${INSTALL_DESTDIR}"
3367-
else
3368-
# We have a toolchain so install to the toolchain
3369-
DYLIB_DIR="${host_install_destdir}${host_install_prefix}/lib/swift/${SWIFT_HOST_VARIANT}"
3370-
MODULE_DIR="${DYLIB_DIR}/${product}.swiftmodule"
3371-
fi
3372-
if [[ "${SKIP_SWIFTSYNTAX_SWIFTSIDE}" ]]; then
3373-
continue
3374-
fi
3375-
set_swiftsyntax_build_command
3376-
if [[ -z "${SKIP_INSTALL_SWIFTSYNTAX_MODULE}" ]] ; then
3377-
mkdir -p "${MODULE_DIR}"
3378-
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --swiftmodule-base-name "${MODULE_DIR}/${SWIFT_HOST_VARIANT_ARCH}" --install
3379-
else
3380-
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --install
3381-
fi
3382-
33833260
continue
33843261
;;
33853262
xctest)

utils/build_swift/driver_arguments.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def _apply_default_arguments(args):
203203
args.test_tvos = False
204204
args.test_watchos = False
205205
args.test_android = False
206+
args.test_swiftsyntax = False
206207
args.test_indexstoredb = False
207208
args.test_sourcekitlsp = False
208209
args.test_skstresstester = False
@@ -568,6 +569,15 @@ def create_argument_parser():
568569
help='build IndexStoreDB')
569570
option(['--sourcekit-lsp'], toggle_true('build_sourcekitlsp'),
570571
help='build SourceKitLSP')
572+
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),
573+
help='install SwiftSyntax')
574+
option('--skip-install-swiftsyntax-module',
575+
toggle_true('skip_install_swiftsyntax_module'),
576+
help='skip installing the SwiftSyntax modules')
577+
option('--swiftsyntax-verify-generated-files',
578+
toggle_true('swiftsyntax_verify_generated_files'),
579+
help='set to verify that the generated files in the source tree '
580+
'match the ones that would be generated from current master')
571581
option(['--install-sourcekit-lsp'], toggle_true('install_sourcekitlsp'),
572582
help='install SourceKitLSP')
573583
option(['--install-skstresstester'], toggle_true('install_skstresstester'),
@@ -957,6 +967,8 @@ def create_argument_parser():
957967
help='skip testing Android device targets on the host machine (the '
958968
'phone itself)')
959969

970+
option('--skip-test-swiftsyntax', toggle_false('test_swiftsyntax'),
971+
help='skip testing SwiftSyntax')
960972
option('--skip-test-indexstore-db', toggle_false('test_indexstoredb'),
961973
help='skip testing indexstore-db')
962974
option('--skip-test-sourcekit-lsp', toggle_false('test_sourcekitlsp'),

utils/build_swift/tests/expected_options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
'build_swiftevolve': False,
8989
'build_indexstoredb': False,
9090
'build_sourcekitlsp': False,
91+
'install_swiftsyntax': False,
92+
'skip_install_swiftsyntax_module': False,
93+
'swiftsyntax_verify_generated_files': False,
9194
'install_sourcekitlsp': False,
9295
'install_skstresstester': False,
9396
'install_swiftevolve': False,
@@ -205,6 +208,7 @@
205208
'test_watchos': False,
206209
'test_watchos_host': False,
207210
'test_watchos_simulator': False,
211+
'test_swiftsyntax': False,
208212
'test_indexstoredb': False,
209213
'test_sourcekitlsp': False,
210214
'test_skstresstester': False,
@@ -475,6 +479,11 @@ class BuildScriptImplOption(_BaseOption):
475479
EnableOption('--libicu', dest='build_libicu'),
476480
EnableOption('--indexstore-db', dest='build_indexstoredb'),
477481
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
482+
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
483+
EnableOption('--skip-install-swiftsyntax-module',
484+
dest='skip_install_swiftsyntax_module'),
485+
EnableOption('--swiftsyntax-verify-generated-files',
486+
dest='swiftsyntax_verify_generated_files'),
478487
EnableOption('--install-sourcekit-lsp', dest='install_sourcekitlsp'),
479488
EnableOption('--install-skstresstester', dest='install_skstresstester'),
480489
EnableOption('--install-swiftevolve', dest='install_swiftevolve'),
@@ -532,6 +541,7 @@ class BuildScriptImplOption(_BaseOption):
532541
DisableOption('--skip-test-watchos-host', dest='test_watchos_host'),
533542
DisableOption('--skip-test-watchos-simulator',
534543
dest='test_watchos_simulator'),
544+
DisableOption('--skip-test-swiftsyntax', dest='test_swiftsyntax'),
535545
DisableOption('--skip-test-indexstore-db', dest='test_indexstoredb'),
536546
DisableOption('--skip-test-sourcekit-lsp', dest='test_sourcekitlsp'),
537547
DisableOption('--skip-test-skstresstester', dest='test_skstresstester'),

0 commit comments

Comments
 (0)