Skip to content

Conversation

@owenv
Copy link
Contributor

@owenv owenv commented Dec 3, 2025

Depends on swiftlang/swift-package-manager#9129

Add a SourceKit-LSP option to allow opting in to use of the new SwiftPM build server, using the existing ExternalBuildServerAdapter with a pre-generated configuration. This allows us to integrate The Swift Build build system backend without having SourceKitLSP need to continue linking parts of SwiftPM directly

@owenv
Copy link
Contributor Author

owenv commented Dec 3, 2025

I haven't done much porting of tests yet, because I want to take a look at which ones should stay in sourcekit-lsp vs sink into SwiftPM.

}
return BuildServerConfig(
name: "SwiftPM Build Server",
version: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Swift version tag?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have it in sourcekit-lsp right now (we have no --version) and until we have a common version that all the projects can use, I'd prefer not to add it.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woooo 🥳 Thanks for working on this @owenv!

if options.swiftPMOrDefault.useExperimentalSwiftPMBuildServer == true {
expectArgumentsContain(
"-target",
// Account for differences in macOS naming canonicalization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is a built-in vs swift-build difference rather than a built-in SwiftPM support vs build server? Given this depends on PackageModel anyway, this will probably be one of the tests that will end up moving. For in sourcekit-lsp, checking we have -target/-sdk/-I/-F (and not their values) is probably enough. And to be clear, no need to block the PR on this/moving tests in general.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, one uses macosx, the other macos. It's pretty annoying but hard to easily align them.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool to see this start and come together. Looking forward to removing the SwiftPM dependency from SourceKit-LSP in the future 🤩

connectionToSourceKitLSP: connectionToSourceKitLSP,
testHooks: buildServerHooks.swiftPMTestHooks
)
if options.swiftPMOrDefault.useExperimentalSwiftPMBuildServer == true {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if options.swiftPMOrDefault.useExperimentalSwiftPMBuildServer == true {
if options.swiftPMOrDefault.useExperimentalSwiftPMBuildServer ?? false {

I just find this more readable because it specifies which value nil should default to and then you’re back to a normal boolean check.


@Test
func testBasicSwiftArgs() async throws {
@Test(arguments: [SourceKitLSPOptions(), .forTestingExperimentalSwiftPMBuildServer])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try running all tests that use SwiftPMTestProject with the new build server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't audited everything yet but I've gone through a decent number. Some failures due to tests making assumptions that don't hold under the new build system, and a few which look like bugs or bits of missing functionality that'll need to be fixed up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I’d like to find some way to run tests using both configurations at some point (maybe an environment variable and just run swift test twice 🤔) but that’s something for the future.

@owenv owenv force-pushed the owenv/bsp branch 2 times, most recently from 322248a to bc4e4c5 Compare December 4, 2025 22:09
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just #2378 (comment) and two nits, otherwise LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants