Skip to content

[build] Add flags to allow skipping rebuilding the corelibs #38673

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
Aug 30, 2021
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
43 changes: 27 additions & 16 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ KNOWN_SETTINGS=(
build-swift-stdlib-unittest-extra "0" "set to 1 to build optional StdlibUnittest components"
build-swift-tools "1" "set to 1 to build Swift host tools"

## Skip cleaning build directories ...
skip-clean-libdispatch "0" "skip cleaning the libdispatch build"
skip-clean-foundation "0" "skip cleaning the foundation build"
skip-clean-xctest "0" "skip cleaning the xctest build"

## Test Options
llvm-include-tests "1" "Set to true to generate testing targets for LLVM. Set to true by default."
long-test "0" "set to run the long test suite"
Expand Down Expand Up @@ -2309,6 +2314,14 @@ for host in "${ALL_HOSTS[@]}"; do
FOUNDATION_BUILD_DIR=$(build_directory ${host} foundation)
SWIFT_BUILD_DIR=$(build_directory ${host} swift)

if [[ "${SKIP_CLEAN_XCTEST}" == "0" ]]
then
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the XCTest build directory"
call rm -rf "${XCTEST_BUILD_DIR}"
fi

case "${host}" in
macosx-*)
# Staging: require opt-in for building with dispatch
Expand Down Expand Up @@ -2336,12 +2349,6 @@ for host in "${ALL_HOSTS[@]}"; do
continue
;;
*)
# FIXME: Always re-build XCTest on non-darwin platforms.
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the XCTest build directory"
call rm -rf "${XCTEST_BUILD_DIR}"

cmake_options=(
${cmake_options[@]}
-DCMAKE_BUILD_TYPE:STRING="${XCTEST_BUILD_TYPE}"
Expand Down Expand Up @@ -2401,11 +2408,13 @@ for host in "${ALL_HOSTS[@]}"; do
LIBICU_BUILD_ARGS=()
fi

# FIXME: Always re-build XCTest on non-darwin platforms.
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the Foundation build directory"
call rm -rf "${build_dir}"
if [[ "${SKIP_CLEAN_FOUNDATION}" == "0" ]]
then
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the Foundation build directory"
call rm -rf "${build_dir}"
fi

# Set the PKG_CONFIG_PATH so that core-foundation can find the libraries and
# header files
Expand Down Expand Up @@ -2466,11 +2475,13 @@ for host in "${ALL_HOSTS[@]}"; do
exit 1
;;
*)
# FIXME: Always re-build XCTest on non-darwin platforms.
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the libdispatch build directory"
call rm -rf "${LIBDISPATCH_BUILD_DIR}"
if [[ "${SKIP_CLEAN_LIBDISPATCH}" == "0" ]]
then
# The Swift project might have been changed, but CMake might
# not be aware and will not rebuild.
echo "Cleaning the libdispatch build directory"
call rm -rf "${LIBDISPATCH_BUILD_DIR}"
fi

cmake_options=(
-DENABLE_SWIFT=YES
Expand Down
6 changes: 6 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,12 @@ def create_argument_parser():
toggle_false('test_android_host'),
help='skip testing Android device targets on the host machine (the '
'phone itself)')
option('--skip-clean-libdispatch', toggle_false('clean_libdispatch'),
help='skip cleaning up libdispatch')
option('--skip-clean-foundation', toggle_false('clean_foundation'),
help='skip cleaning up foundation')
option('--skip-clean-xctest', toggle_false('clean_xctest'),
help='skip cleaning up xctest')
option('--skip-clean-llbuild', toggle_false('clean_llbuild'),
help='skip cleaning up llbuild')
option('--clean-early-swift-driver', toggle_true('clean_early_swift_driver'),
Expand Down
6 changes: 6 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@
defaults.SWIFT_MAX_PARALLEL_LTO_LINK_JOBS,
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
'symbols_package': None,
'clean_libdispatch': True,
'clean_foundation': True,
'clean_xctest': True,
'clean_llbuild': True,
'clean_swiftpm': True,
'clean_swift_driver': True,
Expand Down Expand Up @@ -594,6 +597,9 @@ class BuildScriptImplOption(_BaseOption):
dest='build_watchos_device'),
DisableOption('--skip-build-watchos-simulator',
dest='build_watchos_simulator'),
DisableOption('--skip-clean-libdispatch', dest='clean_libdispatch'),
DisableOption('--skip-clean-foundation', dest='clean_foundation'),
DisableOption('--skip-clean-xctest', dest='clean_xctest'),
DisableOption('--skip-clean-llbuild', dest='clean_llbuild'),
DisableOption('--skip-early-swift-driver', dest='build_early_swift_driver'),
DisableOption('--skip-clean-swiftpm', dest='clean_swiftpm'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,21 @@ def convert_to_impl_arguments(self):
"--llvm-install-components=%s" % args.llvm_install_components
]

if not args.clean_libdispatch:
impl_args += [
"--skip-clean-libdispatch"
]

if not args.clean_foundation:
impl_args += [
"--skip-clean-foundation"
]

if not args.clean_xctest:
impl_args += [
"--skip-clean-xctest"
]

if not args.clean_llbuild:
impl_args += [
"--skip-clean-llbuild"
Expand Down
23 changes: 23 additions & 0 deletions validation-test/BuildSystem/skip_clean_corelibs.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# REQUIRES: standalone_build
# UNSUPPORTED: OS=macosx
# UNSUPPORTED: OS=ios
# UNSUPPORTED: OS=tvos
# UNSUPPORTED: OS=watchos

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --foundation --cmake %cmake 2>&1 | %FileCheck --check-prefix=CLEAN-CORELIBS-CHECK %s

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --foundation --skip-clean-libdispatch --skip-clean-foundation --cmake %cmake 2>&1 | %FileCheck --check-prefix=SKIP-CLEAN-CORELIBS-CHECK %s

# CLEAN-CORELIBS-CHECK: Cleaning the libdispatch build directory
# CLEAN-CORELIBS-CHECK-NEXT: rm -rf
# CLEAN-CORELIBS-CHECK: Cleaning the Foundation build directory
# CLEAN-CORELIBS-CHECK-NEXT: rm -rf

# SKIP-CLEAN-CORELIBS-CHECK-NOT: Cleaning the libdispatch build directory
# SKIP-CLEAN-CORELIBS-CHECK-NOT: rm -rf {{.*/libdispatch-[^/]*}}
# SKIP-CLEAN-CORELIBS-CHECK-NOT: Cleaning the Foundation build directory
# SKIP-CLEAN-CORELIBS-CHECK-NOT: rm -rf {{.*/foundation-[^/]*}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=CLEAN-LLBUILD-CHECK %s
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --xctest --llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=CLEAN-LLBUILD-CHECK %s

# RUN: %empty-directory(%t)
# RUN: mkdir -p %t
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --llbuild --skip-clean-llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=SKIP-CLEAN-LLBUILD-CHECK %s
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --xctest --llbuild --skip-clean-xctest --skip-clean-llbuild --cmake %cmake 2>&1 | %FileCheck --check-prefix=SKIP-CLEAN-LLBUILD-CHECK %s

# CLEAN-LLBUILD-CHECK: Cleaning the XCTest build directory
# CLEAN-LLBUILD-CHECK-NEXT: rm -rf
# CLEAN-LLBUILD-CHECK: Cleaning the llbuild build directory
# CLEAN-LLBUILD-CHECK-NEXT: rm -rf

# SKIP-CLEAN-LLBUILD-CHECK-NOT: Cleaning the XCTest build directory
# SKIP-CLEAN-LLBUILD-CHECK-NOT: rm -rf {{.*/xctest-[^/]*}}
# SKIP-CLEAN-LLBUILD-CHECK-NOT: Cleaning the llbuild build directory
# SKIP-CLEAN-LLBUILD-CHECK-NOT: rm -rf {{.*/llbuild-[^/]*}}