mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-06-24 12:21:58 +02:00
Fix spm API usage for appropriate trait configuration
The `WorkspaceConfiguration.default` was being used to populate the `Workspace`; there was an extra step here needed to assure that we are propagating the trait configuration to the workspace. The added test assures that non-default traits that are enabled are indeed processed as enabled.
This commit is contained in:
@@ -331,8 +331,17 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
|
||||
location.scratchDirectory = absProjectRoot.appending(components: ".build", "index-build")
|
||||
}
|
||||
|
||||
let enabledTraits: Set<String>? =
|
||||
if let traits = options.swiftPMOrDefault.traits {
|
||||
Set(traits)
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
self.traitConfiguration = TraitConfiguration(enabledTraits: enabledTraits)
|
||||
|
||||
var configuration = WorkspaceConfiguration.default
|
||||
configuration.skipDependenciesUpdates = !options.backgroundIndexingOrDefault
|
||||
configuration.traitConfiguration = self.traitConfiguration
|
||||
|
||||
self.swiftPMWorkspace = try Workspace(
|
||||
fileSystem: localFileSystem,
|
||||
@@ -394,14 +403,6 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
|
||||
disableSandbox: options.swiftPMOrDefault.disableSandbox ?? false
|
||||
)
|
||||
|
||||
let enabledTraits: Set<String>? =
|
||||
if let traits = options.swiftPMOrDefault.traits {
|
||||
Set(traits)
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
self.traitConfiguration = TraitConfiguration(enabledTraits: enabledTraits)
|
||||
|
||||
packageLoadingQueue.async {
|
||||
await orLog("Initial package loading") {
|
||||
// Schedule an initial generation of the build graph. Once the build graph is loaded, the build server will send
|
||||
@@ -499,7 +500,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
|
||||
}
|
||||
|
||||
let modulesGraph = try await self.swiftPMWorkspace.loadPackageGraph(
|
||||
rootInput: PackageGraphRootInput(packages: [AbsolutePath(validating: projectRoot.filePath)]),
|
||||
rootInput: PackageGraphRootInput(packages: [AbsolutePath(validating: projectRoot.filePath)], traitConfiguration: self.traitConfiguration),
|
||||
forceResolvedVersions: options.swiftPMOrDefault.forceResolvedVersions ?? !isForIndexBuild,
|
||||
observabilityScope: observabilitySystem.topScope.makeChildScope(description: "Load package graph")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user