Skip to content

Commit 8794dd1

Browse files
committed
[build-script] Add an option for cleaning the install destdir
Useful to make sure that one is not hitting weird behavior due to a stale just built toolchain.
1 parent 8cba09a commit 8794dd1

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

utils/build-script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,10 @@ def main_normal():
664664
".build_script_log")
665665
open(build_script_log, 'w').close()
666666

667+
if args.clean_install_destdir:
668+
sys.stdout.write("Cleaning install destdir!\n")
669+
shell.rmtree(args.install_destdir)
670+
667671
# Build ninja if required, which will update the toolchain.
668672
if args.build_ninja:
669673
invocation.build_ninja()

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ def create_argument_parser():
698698
option(['-c', '--clean'], store_true,
699699
help='do a clean build')
700700

701+
option(['--clean-install-destdir'], store_true,
702+
help='Clean the install destroot before building.')
703+
701704
option('--export-compile-commands', toggle_true,
702705
help='generate compilation databases in addition to building')
703706

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
'watchos': False,
270270
'watchos_all': False,
271271
'llvm_install_components': defaults.llvm_install_components(),
272+
'clean_install_destdir': False,
272273
}
273274

274275

@@ -484,6 +485,7 @@ class BuildScriptImplOption(_BaseOption):
484485
dest='install_backdeployconcurrency'),
485486
SetTrueOption('--benchmark'),
486487
SetTrueOption('--clean'),
488+
SetTrueOption('--clean-install-destdir'),
487489
SetTrueOption('--dry-run'),
488490
SetTrueOption('--dump-config'),
489491
SetTrueOption('--disable-guaranteed-normal-arguments'),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# REQUIRES: standalone_build
2+
# REQUIRES: OS=macosx
3+
4+
# RUN: %empty-directory(%t)
5+
# RUN: mkdir -p %t
6+
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --dry-run --cmake %cmake --clean-install-destdir --verbose-build 2>&1 | %FileCheck %s
7+
8+
# CHECK: Cleaning install destdir!
9+
# CHECK-NEXT: rm -rf
10+

0 commit comments

Comments
 (0)