Skip to content

Commit 60bf6b3

Browse files
authored
Parse args for build_swift_format in format.py
1 parent 61bac6a commit 60bf6b3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Utilities/format.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ def build_swift_format():
2323
run([
2424
"swift", "build", "-c", "release",
2525
"--package-path", package_path])
26-
return bin_path
26+
return [bin_path]
2727

2828

2929
def main():
30+
parser = argparse.ArgumentParser(
31+
prog='WasmKit codebase formatter',
32+
description='Ensures that codebase formatting is consistent')
33+
parser.add_argument('-b', '--build-swift-format', action='store_true')
34+
args = parser.parse_args()
35+
3036
targets = []
3137
for targets_dir in ["Sources", "Tests"]:
3238
targets_path = os.path.join(SOURCE_ROOT, targets_dir)
@@ -40,10 +46,13 @@ def main():
4046
# swift-format.
4147
targets.remove(os.path.join("Sources", "SystemExtras"))
4248

43-
# swift_format = build_swift_format()
49+
if args.build_swift_format:
50+
swift_format = build_swift_format()
51+
else:
52+
swift_format = ["swift", "format"]
4453

45-
arguments = [
46-
"swift", "format", "format", "--in-place", "--recursive", "--parallel"
54+
arguments = swift_format + [
55+
"format", "--in-place", "--recursive", "--parallel"
4756
]
4857
for target in targets:
4958
arguments.append(os.path.join(SOURCE_ROOT, target))

0 commit comments

Comments
 (0)