From 9d1736c12306bec9c53a0e81a97c28c1b398743a Mon Sep 17 00:00:00 2001 From: Butta Date: Thu, 29 Jul 2021 00:17:04 +0530 Subject: [PATCH] [build] Add flags to allow skipping rebuilding the corelibs Add three new flags, '--skip-clean-libdispatch', '--skip-clean-foundation', and '--skip-clean-xctest', that leave the previous builds of those products in place. --- utils/build-script-impl | 43 ++++++++++++------- .../build_swift/driver_arguments.py | 6 +++ utils/build_swift/tests/expected_options.py | 6 +++ .../build_script_invocation.py | 15 +++++++ .../BuildSystem/skip_clean_corelibs.test | 23 ++++++++++ ...ld.test => skip_clean_xctest_llbuild.test} | 8 +++- 6 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 validation-test/BuildSystem/skip_clean_corelibs.test rename validation-test/BuildSystem/{skip_clean_llbuild.test => skip_clean_xctest_llbuild.test} (50%) diff --git a/utils/build-script-impl b/utils/build-script-impl index c74b27d46f410..ddff525dfc210 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -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" @@ -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 @@ -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}" @@ -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 @@ -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 diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index 850c30dce3d86..4adae6d6c59b8 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -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'), diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index bc0041beea192..61eb0aee7db81 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -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, @@ -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'), diff --git a/utils/swift_build_support/swift_build_support/build_script_invocation.py b/utils/swift_build_support/swift_build_support/build_script_invocation.py index 0e98b953df8e0..5ea9a997d7379 100644 --- a/utils/swift_build_support/swift_build_support/build_script_invocation.py +++ b/utils/swift_build_support/swift_build_support/build_script_invocation.py @@ -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" diff --git a/validation-test/BuildSystem/skip_clean_corelibs.test b/validation-test/BuildSystem/skip_clean_corelibs.test new file mode 100644 index 0000000000000..68aa5b268d79e --- /dev/null +++ b/validation-test/BuildSystem/skip_clean_corelibs.test @@ -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-[^/]*}} diff --git a/validation-test/BuildSystem/skip_clean_llbuild.test b/validation-test/BuildSystem/skip_clean_xctest_llbuild.test similarity index 50% rename from validation-test/BuildSystem/skip_clean_llbuild.test rename to validation-test/BuildSystem/skip_clean_xctest_llbuild.test index 20af0a47c0357..7a8dcfc106370 100644 --- a/validation-test/BuildSystem/skip_clean_llbuild.test +++ b/validation-test/BuildSystem/skip_clean_xctest_llbuild.test @@ -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-[^/]*}}