Skip to content

[build-script] Add a default-enabled "clean" step for swift-driver and swiftpm products #33563

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 24, 2020
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
3 changes: 3 additions & 0 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,9 @@ class BuildScriptInvocation(object):
toolchain=self.toolchain,
source_dir=self.workspace.source_dir(product_source),
build_dir=build_dir)
if product.should_clean(host_target):
print("--- Cleaning %s ---" % product_name)
product.clean(host_target)
if product.should_build(host_target):
print("--- Building %s ---" % product_name)
product.build(host_target)
Expand Down
4 changes: 4 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,10 @@ def create_argument_parser():
help='skip testing Android device targets on the host machine (the '
'phone itself)')

option('--skip-clean-swiftpm', toggle_false('clean_swiftpm'),
help='skip cleaning up swiftpm')
option('--skip-clean-swift-driver', toggle_false('clean_swift_driver'),
help='skip cleaning up Swift driver')
option('--skip-test-swiftpm', toggle_false('test_swiftpm'),
help='skip testing swiftpm')
option('--skip-test-swift-driver', toggle_false('test_swift_driver'),
Expand Down
4 changes: 4 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
defaults.SWIFT_MAX_PARALLEL_LTO_LINK_JOBS,
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
'symbols_package': None,
'clean_swiftpm': True,
'clean_swift_driver': True,
'test': None,
'test_android': False,
'test_android_host': False,
Expand Down Expand Up @@ -567,6 +569,8 @@ class BuildScriptImplOption(_BaseOption):
dest='build_watchos_device'),
DisableOption('--skip-build-watchos-simulator',
dest='build_watchos_simulator'),
DisableOption('--skip-clean-swiftpm', dest='clean_swiftpm'),
DisableOption('--skip-clean-swift-driver', dest='clean_swift_driver'),
DisableOption('--skip-test-android', dest='test_android'),
DisableOption('--skip-test-android-host', dest='test_android_host'),
DisableOption('--skip-test-cygwin', dest='test_cygwin'),
Expand Down
14 changes: 14 additions & 0 deletions utils/swift_build_support/swift_build_support/products/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ def get_dependencies(cls):
"""Return a list of products that this product depends upon"""
raise NotImplementedError

def should_clean(self, host_target):
"""should_clean() -> Bool

Whether or not this product should be cleaned before being built
"""
return False

def clean(self, host_target):
"""clean() -> void

Perform the clean, for a non-build-script-impl product.
"""
raise NotImplementedError

def should_build(self, host_target):
"""should_build() -> Bool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def get_dependencies(cls):
xctest.XCTest,
llbuild.LLBuild]

def should_clean(self, host_target):
return self.args.clean_swift_driver

def clean(self, host_target):
indexstoredb.run_build_script_helper(
'clean', host_target, self, self.args)

def build(self, host_target):
indexstoredb.run_build_script_helper(
'build', host_target, self, self.args)
Expand Down
11 changes: 11 additions & 0 deletions utils/swift_build_support/swift_build_support/products/swiftpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def run_bootstrap_script(self, action, host_target, additional_params=[]):

helper_cmd = [script_path, action]

if action == 'clean':
helper_cmd += ["--build-dir", self.build_dir]
shell.call(helper_cmd)
return

if self.is_release():
helper_cmd.append("--release")

Expand Down Expand Up @@ -94,6 +99,12 @@ def should_test(self, host_target):
def test(self, host_target):
self.run_bootstrap_script('test', host_target)

def should_clean(self, host_target):
return self.args.clean_swiftpm

def clean(self, host_target):
self.run_bootstrap_script('clean', host_target)

def should_install(self, host_target):
return self.args.install_swiftpm

Expand Down