Skip to content

Commit 87586f1

Browse files
committed
[build] Verify that SwiftSyntax is correctly formatted
In sourcekit-lsp and swift-format, run swift-format on the sourcekit-lsp sources to make sure it’s correctly formatted.
1 parent 5a66b62 commit 87586f1

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

utils/build-presets.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@ assertions
18841884
swiftsyntax
18851885
swiftformat
18861886
swiftsyntax-lint
1887+
sourcekitlsp-lint
18871888

18881889
[preset: buildbot_swiftformat_linux]
18891890
mixin-preset=mixin_swiftpm_package_linux_platform
@@ -1915,6 +1916,8 @@ mixin-preset=mixin_swiftpm_package_macos_platform
19151916
release
19161917
assertions
19171918
sourcekit-lsp
1919+
swiftformat
1920+
sourcekit-lsp-lint
19181921

19191922
[preset: buildbot_sourcekitlsp_linux,no_sanitize]
19201923
mixin-preset=mixin_swiftpm_package_linux_platform

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,9 @@ def create_argument_parser():
709709
option('--test-sourcekit-lsp-sanitize-all',
710710
toggle_true('test_sourcekitlsp_sanitize_all'),
711711
help='run sourcekit-lsp tests under all sanitizers')
712+
option('--sourcekit-lsp-lint',
713+
toggle_true('sourcekitlsp_lint'),
714+
help='verify that sourcekit-lsp Source code is formatted correctly')
712715
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),
713716
help='install SwiftSyntax')
714717
option('--swiftsyntax-verify-generated-files',

utils/build_swift/tests/expected_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
'test_indexstoredb_sanitize_all': False,
105105
'test_sourcekitlsp_sanitize_all': False,
106106
'build_sourcekitlsp': False,
107+
'sourcekitlsp_lint': False,
107108
'install_llvm': False,
108109
'install_swiftpm': False,
109110
'install_swiftsyntax': False,
@@ -609,6 +610,8 @@ class BuildScriptImplOption(_BaseOption):
609610
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
610611
EnableOption('--test-sourcekit-lsp-sanitize-all',
611612
dest='test_sourcekitlsp_sanitize_all'),
613+
EnableOption('--sourcekit-lsp-lint',
614+
dest='sourcekitlsp_lint'),
612615
EnableOption('--install-llvm', dest='install_llvm'),
613616
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
614617
EnableOption('--swiftsyntax-verify-generated-files',

utils/swift_build_support/swift_build_support/products/swiftformat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def build(self, host_target):
8787
self.run_build_script_helper('build', host_target)
8888
if self.args.swiftsyntax_lint:
8989
self.lint_swiftsyntax()
90+
if self.args.sourcekitlsp_lint:
91+
self.lint_swiftsyntax()
9092

9193
def lint_swiftsyntax(self):
9294
linting_cmd = [
@@ -97,6 +99,17 @@ def lint_swiftsyntax(self):
9799
]
98100
shell.call(linting_cmd)
99101

102+
def lint_sourcekitlsp(self):
103+
linting_cmd = [
104+
os.path.join(self.build_dir, self.configuration(), 'swift-format'),
105+
'lint',
106+
'--parallel',
107+
'--strict',
108+
'--recursive',
109+
os.path.join(os.path.dirname(self.source_dir), 'sourcekit-lsp'),
110+
]
111+
shell.call(linting_cmd)
112+
100113
def should_test(self, host_target):
101114
return self.args.test_swiftformat
102115

0 commit comments

Comments
 (0)