Skip to content

Commit

Permalink
[Plugins] Fix build parameter handling during symbol graph entry poin…
Browse files Browse the repository at this point in the history
…t builds

Supersedes #7629
  • Loading branch information
xedin committed Jun 7, 2024
1 parent 09b3ed1 commit e89c2bc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Sources/Commands/Utilities/PluginDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,19 @@ final class PluginDelegate: PluginInvocationDelegate {
throw StringError("could not find a target named “\(targetName)")
}

// FIXME: This is currently necessary because `target(for:destination:)` can
// produce a module that is targeting host when `targetName`` corresponds to
// a macro, plugin, or a test. Ideally we'd ask a build system for a`BuildSubset`
// and get the destination from there but there are other places that need
// refactoring in that way as well.
let buildParameters = if target.buildTriple == .tools {
try buildSystem.buildPlan.toolsBuildParameters
} else {
try buildSystem.buildPlan.destinationBuildParameters
}

// Build the target, if needed.
try buildSystem.build(subset: .target(target.name))
try buildSystem.build(subset: .target(target.name, for: buildParameters.destination))

// Configure the symbol graph extractor.
var symbolGraphExtractor = try SymbolGraphExtract(
Expand Down Expand Up @@ -419,7 +430,7 @@ final class PluginDelegate: PluginInvocationDelegate {
guard let package = packageGraph.package(for: target) else {
throw StringError("could not determine the package for target “\(target.name)")
}
let outputDir = try buildSystem.buildPlan.toolsBuildParameters.dataPath.appending(
let outputDir = try buildParameters.dataPath.appending(
components: "extracted-symbols",
package.identity.description,
target.name
Expand All @@ -430,7 +441,7 @@ final class PluginDelegate: PluginInvocationDelegate {
let result = try symbolGraphExtractor.extractSymbolGraph(
module: target,
buildPlan: try buildSystem.buildPlan,
buildParameters: buildSystem.buildPlan.destinationBuildParameters,
buildParameters: buildParameters,
outputRedirection: .collect,
outputDirectory: outputDir,
verboseOutput: self.swiftCommandState.logLevel <= .info
Expand Down

0 comments on commit e89c2bc

Please sign in to comment.