Skip to content

Commit

Permalink
Merge pull request #78341 from kateinoigakukun/katei/add-sourcekit-ls…
Browse files Browse the repository at this point in the history
…p-verify

CI: Add `--sourcekit-lsp-verify-generated-files` build-script option
  • Loading branch information
kateinoigakukun authored Jan 15, 2025
2 parents dd11207 + 57cc7c2 commit c68db65
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ sourcekit-lsp
swiftformat
install-swiftformat
sourcekit-lsp-lint
sourcekit-lsp-verify-generated-files

[preset: buildbot_sourcekitlsp_linux,no_sanitize]
mixin-preset=mixin_swiftpm_package_linux_platform
Expand Down
4 changes: 4 additions & 0 deletions utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ def create_argument_parser():
option('--test-sourcekit-lsp-sanitize-all',
toggle_true('test_sourcekitlsp_sanitize_all'),
help='run sourcekit-lsp tests under all sanitizers')
option('--sourcekit-lsp-verify-generated-files',
toggle_true('sourcekitlsp_verify_generated_files'),
help='set to verify that the generated files in the source tree ' +
'match the ones that would be generated from current main')
option('--sourcekit-lsp-lint',
toggle_true('sourcekitlsp_lint'),
help='verify that sourcekit-lsp Source code is formatted correctly')
Expand Down
3 changes: 3 additions & 0 deletions utils/build_swift/tests/expected_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
'test_indexstoredb_sanitize_all': False,
'test_sourcekitlsp_sanitize_all': False,
'build_sourcekitlsp': False,
'sourcekitlsp_verify_generated_files': False,
'sourcekitlsp_lint': False,
'install_llvm': False,
'install_static_linux_config': False,
Expand Down Expand Up @@ -650,6 +651,8 @@ class BuildScriptImplOption(_BaseOption):
EnableOption('--sourcekit-lsp', dest='build_sourcekitlsp'),
EnableOption('--test-sourcekit-lsp-sanitize-all',
dest='test_sourcekitlsp_sanitize_all'),
EnableOption('--sourcekit-lsp-verify-generated-files',
dest='sourcekitlsp_verify_generated_files'),
EnableOption('--sourcekit-lsp-lint',
dest='sourcekitlsp_lint'),
EnableOption('--install-llvm', dest='install_llvm'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ def is_swiftpm_unified_build_product(cls):
def should_build(self, host_target):
return True

def _run_swift_syntax_dev_utils(self, host_target, command, arguments=[]):
sourcekit_lsp_dev_utils = os.path.join(self.source_dir, 'SourceKitLSPDevUtils')

run_cmd = [
os.path.join(self.install_toolchain_path(host_target), "bin", "swift"),
'run',
'--package-path', sourcekit_lsp_dev_utils,
'sourcekit-lsp-dev-utils',
command,
] + arguments

env = dict(os.environ)
env["SWIFTCI_USE_LOCAL_DEPS"] = "1"

shell.call(run_cmd, env=env)

def _for_each_host_target(self, base_target, body):
body(base_target)

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

def build(self, host_target):
if self.args.sourcekitlsp_verify_generated_files:
self._run_swift_syntax_dev_utils(
host_target, 'verify-config-schema')

self._for_each_host_target(
host_target,
lambda target: self.run_build_script_helper('build', host_target, target)
Expand Down

0 comments on commit c68db65

Please sign in to comment.