Skip to content

Commit 77135a9

Browse files
authored
Merge pull request #27934 from ahoppen/swiftsyntax-build-support
Migrate building SwiftSyntax to swift_build_support
2 parents b7c4c51 + 932525d commit 77135a9

File tree

16 files changed

+140
-154
lines changed

16 files changed

+140
-154
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

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import time
1919
import unittest
20-
2120
from StringIO import StringIO
2221
from imp import load_source
2322

benchmark/scripts/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import logging
2626
import sys
27-
2827
from StringIO import StringIO
2928
from contextlib import contextmanager
3029

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",
@@ -819,10 +815,14 @@ class BuildScriptInvocation(object):
819815
build_dir=self.workspace.build_dir(
820816
host_target, product_name))
821817
if product.should_build(host_target):
818+
print("--- Building %s ---" % product_name)
822819
product.build(host_target)
823820
if product.should_test(host_target):
821+
print("--- Running tests for %s ---" % product_name)
824822
product.test(host_target)
823+
print("--- Finished tests for %s ---" % product_name)
825824
if product.should_install(host_target):
825+
print("--- Installing %s ---" % product_name)
826826
product.install(host_target)
827827

828828
# 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)
@@ -2503,15 +2441,6 @@ for host in "${ALL_HOSTS[@]}"; do
25032441
call "${swiftpm_bootstrap_command[@]}"
25042442

25052443
# swiftpm installs itself with a bootstrap method. No further cmake building is performed.
2506-
continue
2507-
;;
2508-
swiftsyntax)
2509-
if [[ "${SKIP_SWIFTSYNTAX_SWIFTSIDE}" ]]; then
2510-
continue
2511-
fi
2512-
set_swiftsyntax_build_command
2513-
call "${swiftsyntax_build_command[@]}"
2514-
25152444
continue
25162445
;;
25172446
xctest)
@@ -3016,16 +2945,6 @@ for host in "${ALL_HOSTS[@]}"; do
30162945
# As swiftpm tests itself, we break early here.
30172946
continue
30182947
;;
3019-
swiftsyntax)
3020-
if [[ "${SKIP_TEST_SWIFTSYNTAX}" ]]; then
3021-
continue
3022-
fi
3023-
echo "--- Running tests for ${product} ---"
3024-
set_swiftsyntax_build_command
3025-
call "${swiftsyntax_build_command[@]}" -t
3026-
# As swiftSyntax tests itself, we break early here.
3027-
continue
3028-
;;
30292948
xctest)
30302949
if [[ "${SKIP_TEST_XCTEST}" ]]; then
30312950
continue
@@ -3310,11 +3229,6 @@ for host in "${ALL_HOSTS[@]}"; do
33103229
continue
33113230
fi
33123231
INSTALL_TARGETS=install-swift-components
3313-
# Swift syntax parser is currently a sub-product of Swift;
3314-
# We need to specify the install target separately here.
3315-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
3316-
INSTALL_TARGETS=tools/libSwiftSyntaxParser/install
3317-
fi
33183232
;;
33193233
llbuild)
33203234
if [[ -z "${INSTALL_LLBUILD}" ]] ; then
@@ -3345,43 +3259,6 @@ for host in "${ALL_HOSTS[@]}"; do
33453259
set_swiftpm_bootstrap_command
33463260
call "${swiftpm_bootstrap_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
33473261
# As swiftpm bootstraps the installation itself, we break early here.
3348-
continue
3349-
;;
3350-
swiftsyntax)
3351-
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
3352-
continue
3353-
fi
3354-
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
3355-
echo "--install-destdir is required to install products."
3356-
exit 1
3357-
fi
3358-
echo "--- Installing ${product} ---"
3359-
if [ "${BUILD_LIBPARSER_ONLY}" ]; then
3360-
# We don't have a toolchain so we should install to the specified dir
3361-
DYLIB_DIR="${INSTALL_DESTDIR}"
3362-
MODULE_DIR="${INSTALL_DESTDIR}/${product}.swiftmodule"
3363-
# Create the install dir if it doesn't exist
3364-
call mkdir -p "${INSTALL_DESTDIR}"
3365-
# Install libParser is necessary
3366-
rsync -a "$(build_directory ${host} swift)/lib/lib_InternalSwiftSyntaxParser.dylib" "${INSTALL_DESTDIR}"
3367-
# Install module map of libParser so client can import SwiftSyntax
3368-
rsync -a "${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser" "${INSTALL_DESTDIR}"
3369-
else
3370-
# We have a toolchain so install to the toolchain
3371-
DYLIB_DIR="${host_install_destdir}${host_install_prefix}/lib/swift/${SWIFT_HOST_VARIANT}"
3372-
MODULE_DIR="${DYLIB_DIR}/${product}.swiftmodule"
3373-
fi
3374-
if [[ "${SKIP_SWIFTSYNTAX_SWIFTSIDE}" ]]; then
3375-
continue
3376-
fi
3377-
set_swiftsyntax_build_command
3378-
if [[ -z "${SKIP_INSTALL_SWIFTSYNTAX_MODULE}" ]] ; then
3379-
mkdir -p "${MODULE_DIR}"
3380-
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --swiftmodule-base-name "${MODULE_DIR}/${SWIFT_HOST_VARIANT_ARCH}" --install
3381-
else
3382-
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --install
3383-
fi
3384-
33853262
continue
33863263
;;
33873264
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'),

0 commit comments

Comments
 (0)