Skip to content

CI: Add --sourcekit-lsp-verify-generated-files build-script option #78341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,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 @@ -652,6 +653,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