Skip to content

Commit 668ce2b

Browse files
CI: Add --sourcekit-lsp-verify-generated-files build-script option
To verify that autogenerated files in the source tree match the ones that would be generated from source.
1 parent dd97862 commit 668ce2b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

utils/build-presets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,7 @@ sourcekit-lsp
20552055
swiftformat
20562056
install-swiftformat
20572057
sourcekit-lsp-lint
2058+
sourcekit-lsp-verify-generated-files
20582059

20592060
[preset: buildbot_sourcekitlsp_linux,no_sanitize]
20602061
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/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)