Skip to content

Commit eee45f7

Browse files
authored
Merge pull request #69516 from ahoppen/ahoppen/lint-sourcekit-lsp
[build] Verify that Sourcekit-LSP is correctly formatted
2 parents 8f466f7 + 04f950c commit eee45f7

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
@@ -1878,6 +1878,7 @@ assertions
18781878
swiftsyntax
18791879
swiftformat
18801880
swiftsyntax-lint
1881+
sourcekit-lsp-lint
18811882

18821883
[preset: buildbot_swiftformat_linux]
18831884
mixin-preset=mixin_swiftpm_package_linux_platform
@@ -1907,6 +1908,8 @@ mixin-preset=mixin_swiftpm_package_macos_platform
19071908
release
19081909
assertions
19091910
sourcekit-lsp
1911+
swiftformat
1912+
sourcekit-lsp-lint
19101913

19111914
[preset: buildbot_sourcekitlsp_linux,no_sanitize]
19121915
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
@@ -705,6 +705,9 @@ def create_argument_parser():
705705
option('--test-sourcekit-lsp-sanitize-all',
706706
toggle_true('test_sourcekitlsp_sanitize_all'),
707707
help='run sourcekit-lsp tests under all sanitizers')
708+
option('--sourcekit-lsp-lint',
709+
toggle_true('sourcekitlsp_lint'),
710+
help='verify that sourcekit-lsp Source code is formatted correctly')
708711
option('--install-swiftsyntax', toggle_true('install_swiftsyntax'),
709712
help='install SwiftSyntax')
710713
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
@@ -103,6 +103,7 @@
103103
'test_indexstoredb_sanitize_all': False,
104104
'test_sourcekitlsp_sanitize_all': False,
105105
'build_sourcekitlsp': False,
106+
'sourcekitlsp_lint': False,
106107
'install_llvm': False,
107108
'install_swiftpm': False,
108109
'install_swiftsyntax': False,
@@ -605,6 +606,8 @@ class BuildScriptImplOption(_BaseOption):
605606
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
606607
EnableOption('--test-sourcekit-lsp-sanitize-all',
607608
dest='test_sourcekitlsp_sanitize_all'),
609+
EnableOption('--sourcekit-lsp-lint',
610+
dest='sourcekitlsp_lint'),
608611
EnableOption('--install-llvm', dest='install_llvm'),
609612
EnableOption('--install-swiftsyntax', dest='install_swiftsyntax'),
610613
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_sourcekitlsp()
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)