Skip to content

Commit f628728

Browse files
committed
Move the usage of plugins from the dependencies parameter of targets in the package manifest to instead be in a separate plugins parameter.
Despite their similarity to dependencies we want users to consider them differently. This also leaves room to grow in the future, when plugin usage might support parameters, etc. We encode them separately in the manifest JSON, but merge them into regular dependencies to avoid duplicated implementation on the SwiftPM side. This can be changed later without affecting clients. For now it would just mean duplicate code. rdar://74663667
1 parent 28baaeb commit f628728

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,24 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
192192
}
193193
return outputPaths
194194
}
195+
195196
/// Create the build plan and return the build description.
196197
private func plan() throws -> BuildDescription {
198+
// Load the package graph.
197199
let graph = try getPackageGraph()
200+
201+
// Invoke any plugins in the graph, and get the results.
198202
let pluginInvocationResults = try getPluginInvocationResults(for: graph)
199203

200-
// Run any prebuild commands. We get here in the case where there was no build description or it needs to change.
204+
// Run any prebuild commands provided by plugins. Any failure stops the build.
201205
var prebuildOutputPaths: [ResolvedTarget: [AbsolutePath]] = [:]
202206
for target in graph.reachableTargets {
203207
if let results = pluginInvocationResults[target] {
204208
prebuildOutputPaths[target] = try runPrebuildCommands(for: results)
205209
}
206210
}
207-
211+
212+
// Create the build plan based, on the graph and any information from plugins.
208213
let plan = try BuildPlan(
209214
buildParameters: buildParameters,
210215
graph: graph,
@@ -213,7 +218,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
213218
diagnostics: diagnostics
214219
)
215220
self.buildPlan = plan
216-
221+
222+
// Finally create the llbuild manifest from the plan.
217223
return try BuildDescription.create(with: plan)
218224
}
219225

0 commit comments

Comments
 (0)