Skip to content

Commit 55b3369

Browse files
committed
[SwiftSyntax] Clean build script
swiftlang/swift-syntax#458
1 parent ed88700 commit 55b3369

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

utils/swift_build_support/swift_build_support/products/swiftsyntax.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,46 +49,55 @@ def is_before_build_script_impl_product(cls):
4949
def is_swiftpm_unified_build_product(cls):
5050
return True
5151

52-
def run_swiftsyntax_build_script(self, target, additional_params=[]):
52+
def run_swiftsyntax_build_script(self, target, command, additional_params=[]):
5353
llvm_build_dir = os.path.join(self.build_dir, '..', 'llvm-' + target)
5454
llvm_build_dir = os.path.realpath(llvm_build_dir)
5555

5656
script_path = os.path.join(self.source_dir, 'build-script.py')
5757

5858
build_cmd = [
5959
script_path,
60+
]
61+
62+
# Verbose need to come before the command, as it is on the root parser
63+
if self.args.verbose_build:
64+
build_cmd.append('--verbose')
65+
66+
build_cmd.extend([
67+
command,
6068
'--build-dir', self.build_dir,
6169
'--multiroot-data-file', MULTIROOT_DATA_FILE_PATH,
62-
'--toolchain', self.install_toolchain_path(target),
63-
'--filecheck-exec', os.path.join(llvm_build_dir, 'bin',
64-
'FileCheck'),
65-
]
70+
'--toolchain', self.install_toolchain_path(target)
71+
])
6672

6773
if self.is_release():
6874
build_cmd.append('--release')
6975

70-
if self.args.swiftsyntax_verify_generated_files:
71-
build_cmd.append('--verify-generated-files')
72-
7376
build_cmd.extend(additional_params)
7477

75-
if self.args.verbose_build:
76-
build_cmd.append('--verbose')
77-
7878
shell.call(build_cmd)
7979

8080
def should_build(self, host_target):
8181
return True
8282

8383
def build(self, host_target):
84-
self.run_swiftsyntax_build_script(target=host_target)
84+
if self.args.swiftsyntax_verify_generated_files:
85+
self.run_swiftsyntax_build_script(target=host_target,
86+
command='verify-source-code')
87+
88+
self.run_swiftsyntax_build_script(target=host_target,
89+
command='build')
8590

8691
def should_test(self, host_target):
8792
return self.args.test_swiftsyntax
8893

89-
def test(self, host_target):
94+
def test(self, host_target):
9095
self.run_swiftsyntax_build_script(target=host_target,
91-
additional_params=['--test'])
96+
command='test',
97+
additional_params=[
98+
'--filecheck-exec', os.path.join(llvm_build_dir, 'bin',
99+
'FileCheck')
100+
])
92101

93102
def should_install(self, host_target):
94103
return self.args.install_swiftsyntax

0 commit comments

Comments
 (0)