Skip to content

Commit c68db65

Browse files
Merge pull request #78341 from kateinoigakukun/katei/add-sourcekit-lsp-verify
CI: Add `--sourcekit-lsp-verify-generated-files` build-script option
2 parents dd11207 + 57cc7c2 commit c68db65

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,7 @@ sourcekit-lsp
20622062
swiftformat
20632063
install-swiftformat
20642064
sourcekit-lsp-lint
2065+
sourcekit-lsp-verify-generated-files
20652066

20662067
[preset: buildbot_sourcekitlsp_linux,no_sanitize]
20672068
mixin-preset=mixin_swiftpm_package_linux_platform

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ def create_argument_parser():
766766
option('--test-sourcekit-lsp-sanitize-all',
767767
toggle_true('test_sourcekitlsp_sanitize_all'),
768768
help='run sourcekit-lsp tests under all sanitizers')
769+
option('--sourcekit-lsp-verify-generated-files',
770+
toggle_true('sourcekitlsp_verify_generated_files'),
771+
help='set to verify that the generated files in the source tree ' +
772+
'match the ones that would be generated from current main')
769773
option('--sourcekit-lsp-lint',
770774
toggle_true('sourcekitlsp_lint'),
771775
help='verify that sourcekit-lsp Source code is formatted correctly')

utils/build_swift/tests/expected_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
'test_indexstoredb_sanitize_all': False,
110110
'test_sourcekitlsp_sanitize_all': False,
111111
'build_sourcekitlsp': False,
112+
'sourcekitlsp_verify_generated_files': False,
112113
'sourcekitlsp_lint': False,
113114
'install_llvm': False,
114115
'install_static_linux_config': False,
@@ -650,6 +651,8 @@ class BuildScriptImplOption(_BaseOption):
650651
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
651652
EnableOption('--test-sourcekit-lsp-sanitize-all',
652653
dest='test_sourcekitlsp_sanitize_all'),
654+
EnableOption('--sourcekit-lsp-verify-generated-files',
655+
dest='sourcekitlsp_verify_generated_files'),
653656
EnableOption('--sourcekit-lsp-lint',
654657
dest='sourcekitlsp_lint'),
655658
EnableOption('--install-llvm', dest='install_llvm'),

utils/swift_build_support/swift_build_support/products/sourcekitlsp.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ def is_swiftpm_unified_build_product(cls):
4848
def should_build(self, host_target):
4949
return True
5050

51+
def _run_swift_syntax_dev_utils(self, host_target, command, arguments=[]):
52+
sourcekit_lsp_dev_utils = os.path.join(self.source_dir, 'SourceKitLSPDevUtils')
53+
54+
run_cmd = [
55+
os.path.join(self.install_toolchain_path(host_target), "bin", "swift"),
56+
'run',
57+
'--package-path', sourcekit_lsp_dev_utils,
58+
'sourcekit-lsp-dev-utils',
59+
command,
60+
] + arguments
61+
62+
env = dict(os.environ)
63+
env["SWIFTCI_USE_LOCAL_DEPS"] = "1"
64+
65+
shell.call(run_cmd, env=env)
66+
5167
def _for_each_host_target(self, base_target, body):
5268
body(base_target)
5369

@@ -58,6 +74,10 @@ def _for_each_host_target(self, base_target, body):
5874
body(target)
5975

6076
def build(self, host_target):
77+
if self.args.sourcekitlsp_verify_generated_files:
78+
self._run_swift_syntax_dev_utils(
79+
host_target, 'verify-config-schema')
80+
6181
self._for_each_host_target(
6282
host_target,
6383
lambda target: self.run_build_script_helper('build', host_target, target)

0 commit comments

Comments
 (0)