Skip to content

WIP: build-script: add a flag to build libSwiftSyntaxParser only. #21901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ class BuildScriptInvocation(object):
if not args.test_watchos_host:
self.platforms_to_skip_test_host.add(
StdlibDeploymentTarget.AppleWatch)
self.build_libparser_only = args.build_libparser_only

def initialize_runtime_environment(self):
"""Change the program environment for building."""
Expand Down Expand Up @@ -697,7 +698,8 @@ class BuildScriptInvocation(object):
impl_args += ["--skip-test-optimized"]
if not args.test_optimize_for_size:
impl_args += ["--skip-test-optimize-for-size"]

if args.build_libparser_only:
impl_args += ["--build-libparser-only"]
if args.android:
impl_args += [
"--android-arch", args.android_arch,
Expand Down
18 changes: 15 additions & 3 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ KNOWN_SETTINGS=(
installable-package "" "the path to the archive of the installation directory"
test-installable-package "" "whether to run post-packaging tests on the produced package"
reconfigure "" "force a CMake configuration run even if CMakeCache.txt already exists"
build-libparser-only "" "only build libSwiftSyntaxParser"
skip-reconfigure "" "set to skip reconfigure"
swift-primary-variant-sdk "" "default SDK for target binaries"
swift-primary-variant-arch "" "default arch for target binaries"
Expand Down Expand Up @@ -1140,7 +1141,6 @@ function get_stdlib_targets_for_host() {
# and architecture of each stdlib target -- currently it only captures the SDK.
#
# We turn these targets in to SWIFT_SDKS in `calculate_targets_for_host()`

if [[ $(is_cross_tools_host $1) ]] ; then
echo "$1"
else
Expand Down Expand Up @@ -1824,6 +1824,16 @@ function set_swiftsyntax_build_command() {
SWIFT_TEST="$(build_directory_bin ${LOCAL_HOST} swiftpm)/swift-test"
fi

if [ "${BUILD_LIBPARSER_ONLY}" ]; then
# we don't have a compiler built so we have to use the one in the environment.
SWIFTC_BIN="$(xcrun_find_tool swiftc)"
# we don't have a swiftpm built so we have to use the one in the environment.
SWIFT_BUILD="$(xcrun_find_tool swift-build)"
SWIFT_TEST="$(xcrun_find_tool swift-test)"
else
SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
fi

swiftsyntax_build_command=("${SWIFTSYNTAX_SOURCE_DIR}/build-script.py")
# Add --release if we have to build in release mode.
if [[ $(is_cmake_release_build_type "${SWIFTSYNTAX_BUILD_TYPE}") ]] ; then
Expand All @@ -1836,7 +1846,7 @@ function set_swiftsyntax_build_command() {
--build-dir="${build_dir}"
--swift-build-exec="${SWIFT_BUILD}"
--swift-test-exec="${SWIFT_TEST}"
--swiftc-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
--swiftc-exec="${SWIFTC_BIN}"
--syntax-parser-header-dir="${SWIFT_SOURCE_DIR}/include/swift-c/SyntaxParser"
--syntax-parser-lib-dir="$(build_directory ${host} swift)/lib"
--swift-syntax-test-exec="$(build_directory_bin ${LOCAL_HOST} swift)/swift-syntax-test"
Expand Down Expand Up @@ -2388,7 +2398,9 @@ for host in "${ALL_HOSTS[@]}"; do
build_targets=("${build_targets[@]}"
"${SWIFT_BENCHMARK_TARGETS[@]}")
fi

if [ "${BUILD_LIBPARSER_ONLY}" ]; then
build_targets=(libSwiftSyntaxParser)
fi
skip_build=${SKIP_BUILD_SWIFT}
;;
lldb)
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ def create_argument_parser():
option('--build-ninja', toggle_true,
help='build the Ninja tool')

option(['--build-libparser-only'], store_true('build_libparser_only'),
help='build only libParser for SwiftSyntax')

# -------------------------------------------------------------------------
in_group('Extra actions to perform before or in addition to building')

Expand Down
2 changes: 2 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
'build_swift_stdlib_unittest_extra': False,
'build_swiftpm': False,
'build_swiftsyntax': False,
'build_libparser_only': False,
'build_skstresstester': False,
'build_swiftevolve': False,
'build_tvos': True,
Expand Down Expand Up @@ -400,6 +401,7 @@ class IgnoreOption(_BaseOption):
SetTrueOption('--skip-build'),
SetTrueOption('--swiftpm', dest='build_swiftpm'),
SetTrueOption('--swiftsyntax', dest='build_swiftsyntax'),
SetTrueOption('--build-libparser-only', dest='build_libparser_only'),
SetTrueOption('--skstresstester', dest='build_skstresstester'),
SetTrueOption('--swiftevolve', dest='build_swiftevolve'),
SetTrueOption('-B', dest='benchmark'),
Expand Down
6 changes: 6 additions & 0 deletions utils/build_swift/tests/test_driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,12 @@ def test_implied_defaults_host_test(self):
self.assertFalse(namespace.test_tvos_host)
self.assertFalse(namespace.test_watchos_host)
self.assertFalse(namespace.test_android_host)
self.assertFalse(namespace.build_libparser_only)

def test_build_lib_swiftsyntaxparser_only(self):
with self.assertNotRaises(ParserError):
namespace = self.parse_default_args(['--build-libparser-only'])
self.assertTrue(namespace.build_libparser_only)


if __name__ == '__main__':
Expand Down