Which component is responsible to launch a build?

I’m working on Swift support for JetBrains IDEs.
This post is about Swift PM support, but custom integrations via BSP will be similar, I suppose.

What’s the recommended way to launch a build of a package?

I’m asking because sourcekit-lsp is supporting it’s own background build and background indexing.
When I now launch a new swift build outside of sourcekit-lsp, I’m worried that the build result could be out-of-sync with the options used by sourcekit-lsp.

I couldn’t find a custom LSP request to trigger a build.

Commands like swift run would be similar, as they’re also running a build first, as far as I understand.

Thank you!

What’s the recommended way to launch a build of a package?

With the regular build system today, so eg. SwiftPM for a package.

I’m worried that the build result could be out-of-sync with the options used by sourcekit-lsp

It depends on whether you expect an outside build to impact sourcekit-lsp. In the integrated SwiftPM case, the background build is isolated from the actual build via a separate arena (.build/index-build ) - it does not use any regular build artifacts. So eg. building for release has no impact on what sourcekit-lsp sees (which by default, will be debug).

We currently expect any required custom command line arguments to be added to .sourcekit-lsp/config.json for SwiftPM. If an editor has its own settings for a build and wants them to be used by LSP as well, my suggestion would be to update .sourcekit-lsp/config.json as part of saving those settings.

Are there any plans to support SDK bundles, like the official static linux or Wasm SDKs or the upcoming Android SDK? It would be great to see such cross-platform support too. :smiley:

@Finagolfin Is this about sourcekit-lsp or the JetBrains support I’m working on?

As far as I understand, sourcekit-lsp of Swift 6.2 is supporting to select an SDK like the WASM sdk. The setup of .sourcekit-lsp/config.json is explained at Visual Studio Code - Swift and WebAssembly

For my work, I’m planning to support cross-platform development eventually. This will probably include the setup of the config.json files and adding the invocation of Swift PM tools like swift run or swift build.

@jansorg, I'm unsure how much sourcekit-lsp currently supports these SDK bundles, but I was asking about your Jetbrains IDEs, great to hear that is planned also. :grinning_face:

It should work as long as swiftSDK is set to the equivalent of --swift-sdk in .sourcekit-lsp/config.json. If you find it doesn’t, please file an issue :slight_smile:

2 Likes