Skip to content

Commit 1926da3

Browse files
committed
[build-script] Move building swiftevolve to swift_build_support
1 parent adbd96b commit 1926da3

File tree

9 files changed

+127
-106
lines changed

9 files changed

+127
-106
lines changed

utils/build-script

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ class BuildScriptInvocation(object):
305305
"--xctest-build-type", args.build_variant,
306306
"--swiftpm-build-type", args.build_variant,
307307
"--swiftsyntax-build-type", args.build_variant,
308-
"--swiftevolve-build-type", args.build_variant,
309308
"--llbuild-build-type", args.build_variant,
310309
"--swift-enable-assertions", str(args.swift_assertions).lower(),
311310
"--swift-stdlib-enable-assertions", str(
@@ -436,8 +435,6 @@ class BuildScriptInvocation(object):
436435
impl_args += ["--skip-build-swiftpm"]
437436
if not args.build_swiftsyntax:
438437
impl_args += ["--skip-build-swiftsyntax"]
439-
if not args.build_swiftevolve:
440-
impl_args += ["--skip-build-swiftevolve"]
441438
if not args.build_playgroundsupport:
442439
impl_args += ["--skip-build-playgroundsupport"]
443440
if args.build_swift_dynamic_stdlib:
@@ -482,7 +479,6 @@ class BuildScriptInvocation(object):
482479
"--skip-test-llbuild",
483480
"--skip-test-swiftpm",
484481
"--skip-test-swiftsyntax",
485-
"--skip-test-swiftevolve",
486482
"--skip-test-xctest",
487483
"--skip-test-foundation",
488484
"--skip-test-libdispatch",

utils/build-script-impl

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ KNOWN_SETTINGS=(
8383
# When this flag is set, the build-script will only build/install the swift-syntax parser
8484
# This is a temporary workaround of having a separate build product for swift-syntax parser
8585
skip-swiftsyntax-swiftside "" "skip building/installing the swift side of swiftsyntax"
86-
swiftevolve-build-type "Debug" "the build variant for the swift-evolve tool"
8786
llbuild-enable-assertions "1" "enable assertions in llbuild"
8887
enable-asan "" "enable Address Sanitizer"
8988
enable-ubsan "" "enable Undefined Behavior Sanitizer"
@@ -128,7 +127,6 @@ KNOWN_SETTINGS=(
128127
skip-build-libcxx "" "set to skip building libcxx"
129128
skip-build-swiftpm "" "set to skip building swiftpm"
130129
skip-build-swiftsyntax "" "set to skip building swiftSyntax"
131-
skip-build-swiftevolve "" "set to skip building the swift-evolve tool"
132130
skip-build-xctest "" "set to skip building xctest"
133131
skip-build-foundation "" "set to skip building foundation"
134132
skip-build-libdispatch "" "set to skip building libdispatch"
@@ -143,7 +141,6 @@ KNOWN_SETTINGS=(
143141
skip-test-llbuild "" "set to skip testing llbuild"
144142
skip-test-swiftpm "" "set to skip testing swiftpm"
145143
skip-test-swiftsyntax "" "set to skip testing swiftSyntax"
146-
skip-test-swiftevolve "" "set to skip testing the swift-evolve tool"
147144
skip-test-xctest "" "set to skip testing xctest"
148145
skip-test-foundation "" "set to skip testing foundation"
149146
skip-test-libdispatch "" "set to skip testing libdispatch"
@@ -203,7 +200,6 @@ KNOWN_SETTINGS=(
203200
install-swiftpm "" "whether to install swiftpm"
204201
install-swiftsyntax "" "whether to install swiftsyntax"
205202
skip-install-swiftsyntax-module "" "set to skip installing swiftsyntax modules"
206-
install-swiftevolve "" "whether to install the swift-evolve tool"
207203
install-xctest "" "whether to install xctest"
208204
install-foundation "" "whether to install foundation"
209205
install-libcxx "" "whether to install libc++"
@@ -1196,7 +1192,6 @@ LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild"
11961192
SWIFTPM_SOURCE_DIR="${WORKSPACE}/swiftpm"
11971193
SWIFTSYNTAX_SOURCE_DIR="${WORKSPACE}/swift-syntax"
11981194
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester"
1199-
SWIFTEVOLVE_SOURCE_DIR="${STRESSTEST_PACKAGE_DIR}/SwiftEvolve"
12001195
XCTEST_SOURCE_DIR="${WORKSPACE}/swift-corelibs-xctest"
12011196
FOUNDATION_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
12021197
FOUNDATION_STATIC_SOURCE_DIR="${WORKSPACE}/swift-corelibs-foundation"
@@ -1279,14 +1274,9 @@ fi
12791274
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
12801275
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
12811276
fi
1282-
# swift-evolve is dependent on SwiftSyntax, so it must be added to the list of
1283-
# build products first.
12841277
if [[ ! "${SKIP_BUILD_SWIFTSYNTAX}" ]] ; then
12851278
PRODUCTS=("${PRODUCTS[@]}" swiftsyntax)
12861279
fi
1287-
if [[ ! "${SKIP_BUILD_SWIFTEVOLVE}" ]] ; then
1288-
PRODUCTS=("${PRODUCTS[@]}" swiftevolve)
1289-
fi
12901280

12911281
# Checks if a given product is enabled (i.e. part of $PRODUCTS array)
12921282
function contains_product() {
@@ -1595,9 +1585,6 @@ function build_directory_bin() {
15951585
swiftsyntax)
15961586
echo "${root}/${SWIFTSYNTAX_BUILD_TYPE}/bin"
15971587
;;
1598-
swiftevolve)
1599-
echo "${root}/${SWIFTEVOLVE_BUILD_TYPE}/bin"
1600-
;;
16011588
xctest)
16021589
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
16031590
;;
@@ -1743,9 +1730,6 @@ function cmake_config_opt() {
17431730
swiftsyntax)
17441731
echo "--config ${SWIFTSYNTAX_BUILD_TYPE}"
17451732
;;
1746-
swiftevolve)
1747-
echo "--config ${SWIFTEVOLVE_BUILD_TYPE}"
1748-
;;
17491733
xctest)
17501734
echo "--config ${XCTEST_BUILD_TYPE}"
17511735
;;
@@ -1870,48 +1854,6 @@ function set_swiftsyntax_build_command() {
18701854
--filecheck-exec="$(build_directory_bin ${LOCAL_HOST} llvm)/FileCheck")
18711855
}
18721856

1873-
function set_stresstester_build_script_helper_command() {
1874-
local package_name="$1"
1875-
local package_build_type="$2"
1876-
local package_build_dir="$3"
1877-
1878-
if [ "${SKIP_BUILD_SWIFTSYNTAX}" ]; then
1879-
echo "Error: Cannot build $package_name without SwiftSyntax."
1880-
exit 1
1881-
fi
1882-
1883-
local swiftsyntax_config="debug"
1884-
if [[ $(is_cmake_release_build_type "${SWIFTSYNTAX_BUILD_TYPE}") ]] ; then
1885-
swiftsyntax_config="release"
1886-
fi
1887-
local config="debug"
1888-
if [[ $(is_cmake_release_build_type "${package_build_type}") ]] ; then
1889-
config="release"
1890-
fi
1891-
1892-
stresstester_build_script_helper_command=("${STRESSTEST_PACKAGE_DIR}/build-script-helper.py")
1893-
if [[ "${VERBOSE_BUILD}" ]] ; then
1894-
stresstester_build_script_helper_command+=(-v)
1895-
fi
1896-
1897-
stresstester_build_script_helper_command+=(
1898-
--package-dir="${package_name}"
1899-
--build-dir="${package_build_dir}"
1900-
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
1901-
--swift-build-exec="$(swiftpm_find_tool swift-build)"
1902-
--swift-test-exec="$(swiftpm_find_tool swift-test)"
1903-
--syntax-parser-header-dir="${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser"
1904-
--syntax-parser-lib-dir="$(build_directory ${host} swift)/lib"
1905-
--sourcekitd-dir="$(build_directory ${host} swift)/lib"
1906-
--swiftsyntax-dir="$(build_directory ${host} swiftsyntax)/${swiftsyntax_config}"
1907-
--config="${config}")
1908-
}
1909-
1910-
function set_swiftevolve_build_command() {
1911-
set_stresstester_build_script_helper_command SwiftEvolve "${SWIFTEVOLVE_BUILD_TYPE}" "$(build_directory ${host} swiftevolve)"
1912-
swiftevolve_build_command=("${stresstester_build_script_helper_command[@]}")
1913-
}
1914-
19151857
#
19161858
# Configure and build each product
19171859
#
@@ -2563,16 +2505,6 @@ for host in "${ALL_HOSTS[@]}"; do
25632505
set_swiftsyntax_build_command
25642506
call "${swiftsyntax_build_command[@]}"
25652507

2566-
continue
2567-
;;
2568-
swiftevolve)
2569-
if [[ "$(uname -s)" != "Darwin" ]]; then
2570-
echo "error: unable to build swift-evolve on this platform"
2571-
continue
2572-
fi
2573-
set_swiftevolve_build_command
2574-
call "${swiftevolve_build_command[@]}"
2575-
25762508
continue
25772509
;;
25782510
xctest)
@@ -3087,15 +3019,6 @@ for host in "${ALL_HOSTS[@]}"; do
30873019
# As swiftSyntax tests itself, we break early here.
30883020
continue
30893021
;;
3090-
swiftevolve)
3091-
if [[ "${SKIP_TEST_SWIFTEVOLVE}" ]]; then
3092-
continue
3093-
fi
3094-
echo "--- Running tests for ${product} ---"
3095-
set_swiftevolve_build_command
3096-
call "${swiftevolve_build_command[@]}" test
3097-
continue
3098-
;;
30993022
xctest)
31003023
if [[ "${SKIP_TEST_XCTEST}" ]]; then
31013024
continue
@@ -3452,24 +3375,6 @@ for host in "${ALL_HOSTS[@]}"; do
34523375
call "${swiftsyntax_build_command[@]}" --dylib-dir="${DYLIB_DIR}" --install
34533376
fi
34543377

3455-
continue
3456-
;;
3457-
swiftevolve)
3458-
if [[ -z "${INSTALL_SWIFTEVOLVE}" ]] ; then
3459-
continue
3460-
fi
3461-
if [[ -z "${INSTALL_DESTDIR}" ]] ; then
3462-
echo "--install-destdir is required to install products."
3463-
exit 1
3464-
fi
3465-
if [[ -z "${INSTALL_SWIFTSYNTAX}" ]] ; then
3466-
echo "--install-swiftsyntax is required to install swift-evolve"
3467-
exit 1
3468-
fi
3469-
3470-
echo "--- Installing ${product} ---"
3471-
set_swiftevolve_build_command
3472-
call "${swiftevolve_build_command[@]}" --prefix="${host_install_destdir}${host_install_prefix}" install
34733378
continue
34743379
;;
34753380
xctest)

utils/build_swift/driver_arguments.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def _apply_default_arguments(args):
206206
args.test_indexstoredb = False
207207
args.test_sourcekitlsp = False
208208
args.test_skstresstester = False
209+
args.test_swiftevolve = False
209210

210211
# --skip-test-ios is merely a shorthand for host and simulator tests.
211212
if not args.test_ios:
@@ -571,6 +572,8 @@ def create_argument_parser():
571572
help='install SourceKitLSP')
572573
option(['--install-skstresstester'], toggle_true('install_skstresstester'),
573574
help='install the SourceKit stress tester')
575+
option(['--install-swiftevolve'], toggle_true('install_swiftevolve'),
576+
help='install SwiftEvolve')
574577
option(['--toolchain-benchmarks'],
575578
toggle_true('build_toolchainbenchmarks'),
576579
help='build Swift Benchmarks using swiftpm against the just built '
@@ -960,6 +963,8 @@ def create_argument_parser():
960963
help='skip testing sourcekit-lsp')
961964
option('--skip-test-skstresstester', toggle_false('test_skstresstester'),
962965
help='skip testing the SourceKit Stress tester')
966+
option('--skip-test-swiftevolve', toggle_false('test_swiftevolve'),
967+
help='skip testing SwiftEvolve')
963968

964969
# -------------------------------------------------------------------------
965970
in_group('Build settings specific for LLVM')
@@ -1031,6 +1036,17 @@ def create_argument_parser():
10311036
option('--skip-test-optimize-none-with-implicit-dynamic', unsupported)
10321037
option('--skip-test-optimized', unsupported)
10331038

1039+
# -------------------------------------------------------------------------
1040+
in_group('Build-script-impl arguments (for disambiguation)')
1041+
# We need to list --skip-build-swift explicitly because otherwise argparse
1042+
# will auto-expand arguments like --skip-build-swift to the only known
1043+
# argument --skip-build-swiftevolve.
1044+
# These arguments are forwarded to impl_args in migration.py
1045+
1046+
option('--install-swift', toggle_true('impl_install_swift'))
1047+
option('--skip-test-swift', toggle_true('impl_skip_test_swift'))
1048+
1049+
10341050
# -------------------------------------------------------------------------
10351051
return builder.build()
10361052

@@ -1073,7 +1089,8 @@ def create_argument_parser():
10731089
10741090
10751091
Any arguments not listed are forwarded directly to Swift's
1076-
'build-script-impl'. See that script's help for details.
1092+
'build-script-impl'. See that script's help for details. The listed
1093+
build-script-impl arguments are only for disambiguation in the argument parser.
10771094
10781095
Environment variables
10791096
---------------------

utils/build_swift/tests/expected_options.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
'build_sourcekitlsp': False,
9191
'install_sourcekitlsp': False,
9292
'install_skstresstester': False,
93+
'install_swiftevolve': False,
9394
'build_toolchainbenchmarks': False,
9495
'build_tvos': True,
9596
'build_tvos_device': False,
@@ -207,6 +208,7 @@
207208
'test_indexstoredb': False,
208209
'test_sourcekitlsp': False,
209210
'test_skstresstester': False,
211+
'test_swiftevolve': False,
210212
'tvos': False,
211213
'tvos_all': False,
212214
'validation_test': None,
@@ -344,6 +346,14 @@ class IgnoreOption(_BaseOption):
344346
pass
345347

346348

349+
class BuildScriptImplOption(_BaseOption):
350+
"""Option that gets forwarded to build-script-impl by migration.py and is
351+
only listed for disambiguation by argparse.
352+
"""
353+
354+
pass
355+
356+
347357
# -----------------------------------------------------------------------------
348358

349359
EXPECTED_OPTIONS = [
@@ -467,6 +477,7 @@ class IgnoreOption(_BaseOption):
467477
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
468478
EnableOption('--install-sourcekit-lsp', dest='install_sourcekitlsp'),
469479
EnableOption('--install-skstresstester', dest='install_skstresstester'),
480+
EnableOption('--install-swiftevolve', dest='install_swiftevolve'),
470481
EnableOption('--toolchain-benchmarks', dest='build_toolchainbenchmarks'),
471482
EnableOption('--tsan-libdispatch-test'),
472483
EnableOption('--long-test'),
@@ -524,6 +535,7 @@ class IgnoreOption(_BaseOption):
524535
DisableOption('--skip-test-indexstore-db', dest='test_indexstoredb'),
525536
DisableOption('--skip-test-sourcekit-lsp', dest='test_sourcekitlsp'),
526537
DisableOption('--skip-test-skstresstester', dest='test_skstresstester'),
538+
DisableOption('--skip-test-swiftevolve', dest='test_swiftevolve'),
527539

528540
ChoicesOption('--android-ndk-gcc-version',
529541
choices=['4.8', '4.9']),
@@ -590,6 +602,10 @@ class IgnoreOption(_BaseOption):
590602
UnsupportedOption('--skip-test-optimize-none-with-implicit-dynamic'),
591603
UnsupportedOption('--skip-test-optimized'),
592604

605+
# Options forwared to build-script-impl
606+
BuildScriptImplOption('--skip-test-swift', dest='impl_skip_test_swift'),
607+
BuildScriptImplOption('--install-swift', dest='impl_install_swift'),
608+
593609
# NOTE: LTO flag is a special case that acts both as an option and has
594610
# valid choices
595611
SetOption('--lto', dest='lto_type'),

utils/build_swift/tests/test_driver_arguments.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,23 @@ def test(self):
313313

314314
return test
315315

316+
@classmethod
317+
def _generate_build_script_impl_option_test(cls, option):
318+
def test(self):
319+
with self.assertNotRaises(ParserError):
320+
namespace, unknown_args = self.parse_args_and_unknown_args([])
321+
self.assertFalse(hasattr(namespace, option.dest))
322+
self.assertEqual(unknown_args, [])
323+
324+
namespace, unknown_args = self.parse_args_and_unknown_args(
325+
[option.option_string])
326+
# The argument should never show up in the namespace
327+
self.assertFalse(hasattr(namespace, option.dest))
328+
# It should instead be forwareded to unkown_args
329+
self.assertEqual(unknown_args, [option.option_string])
330+
331+
return test
332+
316333
@classmethod
317334
def generate_option_test(cls, option):
318335
generate_test_funcs = {
@@ -328,6 +345,8 @@ def generate_option_test(cls, option):
328345
eo.PathOption: cls._generate_path_option_test,
329346
eo.AppendOption: cls._generate_append_option_test,
330347
eo.UnsupportedOption: cls._generate_unsupported_option_test,
348+
eo.BuildScriptImplOption:
349+
cls._generate_build_script_impl_option_test,
331350

332351
# IgnoreOptions should be manually tested
333352
eo.IgnoreOption: lambda self: None,
@@ -383,7 +402,7 @@ def _check_impl_args(self, namespace):
383402
raise ParserError('failed to parse impl arguments: ' +
384403
str(namespace.build_script_impl_args), e)
385404

386-
def parse_args(self, args, namespace=None):
405+
def parse_args_and_unknown_args(self, args, namespace=None):
387406
if namespace is None:
388407
namespace = argparse.Namespace()
389408

@@ -392,9 +411,18 @@ def parse_args(self, args, namespace=None):
392411
namespace, unknown_args =\
393412
super(self.parser.__class__, self.parser)\
394413
.parse_known_args(args, namespace)
414+
namespace, unknown_args =\
415+
migration.process_disambiguation_arguments(namespace,
416+
unknown_args)
395417
except (SystemExit, argparse.ArgumentError) as e:
396418
raise ParserError('failed to parse arguments: ' + str(args), e)
397419

420+
return namespace, unknown_args
421+
422+
def parse_args(self, args, namespace=None):
423+
namespace, unknown_args = self.parse_args_and_unknown_args(args,
424+
namespace)
425+
398426
if unknown_args:
399427
raise ParserError('unknown arguments: ' + str(unknown_args))
400428

@@ -452,6 +480,7 @@ def test_expected_options_have_default_values(self):
452480
eo.HelpOption,
453481
eo.IgnoreOption,
454482
eo.UnsupportedOption,
483+
eo.BuildScriptImplOption,
455484
]
456485

457486
missing_defaults = set()

0 commit comments

Comments
 (0)