Skip to content

Commit d5a3e74

Browse files
committed
[Build Script Helper] Make cleaning up build directory a separate "clean" action.
Instead of doing it automatically every time. This will allow callers (mostly `swift` `build-script`) decide/override whether or not cleanup should be done.
1 parent b590b0c commit d5a3e74

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Utilities/build-script-helper.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ def handle_invocation(toolchain_bin, args):
122122
if args.sysroot:
123123
env['SDKROOT'] = args.sysroot
124124

125-
print('Cleaning ' + args.build_path)
126-
shutil.rmtree(args.build_path, ignore_errors=True)
127-
128125
if args.action == 'build':
129126
swiftpm('build', swift_exec, swiftpm_args, env)
127+
elif args.action == 'clean':
128+
print('Cleaning ' + args.build_path)
129+
shutil.rmtree(args.build_path, ignore_errors=True)
130130
elif args.action == 'test':
131131
for tool in driver_toolchain_tools:
132132
tool_path = os.path.join(toolchain_bin, tool)
@@ -157,6 +157,9 @@ def add_common_args(parser):
157157
parser.add_argument('--verbose', '-v', action='store_true', help='enable verbose output')
158158

159159
subparsers = parser.add_subparsers(title='subcommands', dest='action', metavar='action')
160+
clean_parser = subparsers.add_parser('clean', help='clean the package')
161+
add_common_args(clean_parser)
162+
160163
build_parser = subparsers.add_parser('build', help='build the package')
161164
add_common_args(build_parser)
162165

0 commit comments

Comments
 (0)