Skip to content

Commit 4a123f1

Browse files
committed
Fix the build-script --skip-build option.
This option configures the build directories without building any targets. Splitting configuration from build allows for the decoupling of build products. This decoupling is essential for the enlightened way of developing Swift where the build-script is never actually used to build anything, and build products can be independently configured. When fully supported, this avoids many unnecessary full/clean rebuilds and enables debugging by mixing-and-matching configurations and rebuilding only select products after a change. Sadly, the option has degraded, and a recent commit rendered it fully broken: commit 34848e6 Author: Alex Langford <[email protected]> Date: Wed Jan 22 19:27:44 2020 [build] Unify logic to skip building projects in build-script-impl The breaking commit was itself a reasonable cleanup. The underlying problem was the original --skip-build was implemented using hacks that conflated configuration with build. This fix reinstates a reasonable situation: --skip-build has no effect on configuration, as documented. It merely skips building the targets. This is how it must behave to work as intended. --skip-build-{product} and its inverse --build-{product} controls which products will be configured. These options are in heavy use throughout the scripts, so changing the name (e.g. to --skip-config) would be disruptive and of questionable benefit. None of this changes the fact that any required build logic that people have dumped into build-script-impl still effectively breaks the enlightened way of building Swift, particularly when building toolchain components.
1 parent efa526e commit 4a123f1

File tree

4 files changed

+28
-72
lines changed

4 files changed

+28
-72
lines changed

utils/build-script

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,7 @@ class BuildScriptInvocation(object):
464464
]
465465

466466
if args.skip_build:
467-
impl_args += ["--skip-build-cmark",
468-
"--skip-build-llvm",
469-
"--skip-build-swift"]
467+
impl_args += ["--skip-build"]
470468
if not args.build_benchmarks:
471469
impl_args += ["--skip-build-benchmarks"]
472470
# Currently we do not build external benchmarks by default.

utils/build-script-impl

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ umask 0022
3030
# A default value of "" indicates that the corresponding variable
3131
# will remain unset unless set explicitly.
3232
#
33-
# skip-* parameters do not affect the configuration (CMake parameters).
34-
# You can turn them on and off in different invocations of the script for the
35-
# same build directory.
33+
# The --skip-build parameter, with no product name, does not affect the
34+
# configuration (CMake parameters). You can turn this option on and
35+
# off in different invocations of the script for the same build
36+
# directory without affecting configutation.
3637
#
37-
# build-* parameters affect the CMake configuration (enable/disable those
38-
# components).
38+
# skip-build-* and build-* parameters affect the CMake configuration
39+
# (enable/disable those components).
3940
#
4041
# Each variable name is re-exported into this script in uppercase, where dashes
4142
# are substituted by underscores. For example, `swift-install-components` is
@@ -118,6 +119,7 @@ KNOWN_SETTINGS=(
118119
swift-stdlib-build-type "Debug" "the CMake build variant for Swift"
119120

120121
## Skip Build ...
122+
skip-build "" "set to configure as usual while skipping the build step"
121123
skip-build-android "" "set to skip building Swift stdlibs for Android"
122124
skip-build-benchmarks "" "set to skip building Swift Benchmark Suite"
123125
skip-build-clang-tools-extra "" "set to skip building clang-tools-extra as part of llvm"
@@ -1041,13 +1043,10 @@ if [[ ! "${SKIP_BUILD_PLAYGROUNDSUPPORT}" && ! -d ${PLAYGROUNDSUPPORT_SOURCE_DIR
10411043
exit 1
10421044
fi
10431045

1044-
# We cannot currently apply the normal rules of skipping here for LLVM. Even if
1045-
# we are skipping building LLVM, we still need to at least build several tools
1046-
# that swift relies on for building and testing. See the LLVM configure rules.
1047-
PRODUCTS=(llvm)
10481046
[[ "${SKIP_BUILD_CMARK}" ]] || PRODUCTS+=(cmark)
10491047
[[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx)
10501048
[[ "${SKIP_BUILD_LIBICU}" ]] || PRODUCTS+=(libicu)
1049+
[[ "${SKIP_BUILD_LLVM}" ]] || PRODUCTS+=(llvm)
10511050
[[ "${SKIP_BUILD_SWIFT}" ]] || PRODUCTS+=(swift)
10521051
[[ "${SKIP_BUILD_LLDB}" ]] || PRODUCTS+=(lldb)
10531052
[[ "${SKIP_BUILD_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch)
@@ -1406,7 +1405,6 @@ for host in "${ALL_HOSTS[@]}"; do
14061405
for product in "${PRODUCTS[@]}"; do
14071406
[[ $(should_execute_action "${host}-${product/_static}-build") ]] || continue
14081407

1409-
unset skip_build
14101408
source_dir_var="$(toupper ${product})_SOURCE_DIR"
14111409
source_dir=${!source_dir_var}
14121410
build_dir=$(build_directory ${host} ${product})
@@ -1436,7 +1434,7 @@ for host in "${ALL_HOSTS[@]}"; do
14361434
if [ "${BUILD_LLVM}" == "0" ] ; then
14371435
build_targets=(clean)
14381436
fi
1439-
if [ "${SKIP_BUILD_LLVM}" ] ; then
1437+
if [ "${SKIP_BUILD}" ] ; then
14401438
# We can't skip the build completely because the standalone
14411439
# build of Swift depend on these for building and testing.
14421440
build_targets=(llvm-tblgen clang-resource-headers intrinsics_gen clang-tablegen-targets)
@@ -2207,18 +2205,25 @@ for host in "${ALL_HOSTS[@]}"; do
22072205
fi
22082206

22092207
# Build.
2210-
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
2211-
# Xcode generator uses "ALL_BUILD" instead of "all".
2212-
# Also, xcodebuild uses -target instead of bare names.
2213-
build_targets=("${build_targets[@]/all/ALL_BUILD}")
2214-
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }")
2215-
2216-
# Xcode can't restart itself if it turns out we need to reconfigure.
2217-
# Do an advance build to handle that.
2218-
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product})
2219-
fi
2208+
#
2209+
# Even if builds are skipped, Swift configuration relies on
2210+
# some LLVM tools like TableGen. In the LLVM configure rules
2211+
# above, a small subset of LLVM build_targets are selected
2212+
# when SKIP_BUILD is set.
2213+
if [[ $(not ${SKIP_BUILD}) || "${product}" == "llvm" ]]; then
2214+
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
2215+
# Xcode generator uses "ALL_BUILD" instead of "all".
2216+
# Also, xcodebuild uses -target instead of bare names.
2217+
build_targets=("${build_targets[@]/all/ALL_BUILD}")
2218+
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }")
2219+
2220+
# Xcode can't restart itself if it turns out we need to reconfigure.
2221+
# Do an advance build to handle that.
2222+
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product})
2223+
fi
22202224

2221-
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
2225+
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
2226+
fi
22222227

22232228
# When we are building LLVM copy over the compiler-rt
22242229
# builtins for iOS/tvOS/watchOS to ensure that Swift's

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,6 @@ def _apply_default_arguments(args):
131131
raise ValueError('error: --watchos-all is unavailable in open-source '
132132
'Swift.\nUse --watchos to skip watchOS device tests.')
133133

134-
# Propagate global --skip-build
135-
if args.skip_build:
136-
args.build_linux = False
137-
args.build_freebsd = False
138-
args.build_cygwin = False
139-
args.build_osx = False
140-
args.build_ios = False
141-
args.build_tvos = False
142-
args.build_watchos = False
143-
args.build_android = False
144-
args.build_benchmarks = False
145-
args.build_external_benchmarks = False
146-
args.build_lldb = False
147-
args.build_llbuild = False
148-
args.build_libcxx = False
149-
args.build_swiftpm = False
150-
args.build_xctest = False
151-
args.build_foundation = False
152-
args.build_libdispatch = False
153-
args.build_libicu = False
154-
args.build_playgroundsupport = False
155-
args.build_pythonkit = False
156-
157134
# --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
158135
# merely shorthands for --skip-build-{**os}-{device,simulator}
159136
if not args.ios or not args.build_ios:

utils/build_swift/tests/build_swift/test_driver_arguments.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -540,30 +540,6 @@ def test_implied_defaults_build_variant(self):
540540
self.assertEqual(namespace.swift_build_variant, 'Debug')
541541
self.assertEqual(namespace.swift_stdlib_build_variant, 'Debug')
542542

543-
def test_implied_defaults_skip_build(self):
544-
namespace = self.parse_default_args(['--skip-build'])
545-
546-
self.assertFalse(namespace.build_benchmarks)
547-
548-
self.assertFalse(namespace.build_linux)
549-
self.assertFalse(namespace.build_android)
550-
self.assertFalse(namespace.build_freebsd)
551-
self.assertFalse(namespace.build_cygwin)
552-
self.assertFalse(namespace.build_osx)
553-
self.assertFalse(namespace.build_ios)
554-
self.assertFalse(namespace.build_tvos)
555-
self.assertFalse(namespace.build_watchos)
556-
557-
self.assertFalse(namespace.build_foundation)
558-
self.assertFalse(namespace.build_libdispatch)
559-
self.assertFalse(namespace.build_libicu)
560-
self.assertFalse(namespace.build_lldb)
561-
self.assertFalse(namespace.build_llbuild)
562-
self.assertFalse(namespace.build_libcxx)
563-
self.assertFalse(namespace.build_playgroundsupport)
564-
self.assertFalse(namespace.build_swiftpm)
565-
self.assertFalse(namespace.build_xctest)
566-
567543
def test_implied_defaults_skip_build_ios(self):
568544
namespace = self.parse_default_args(['--skip-build-ios'])
569545
self.assertFalse(namespace.build_ios_device)

0 commit comments

Comments
 (0)