Skip to content

Commit 4a233d7

Browse files
committed
[Plugins] NFC: Rename "prebuild command" into "command plugin" to better fit the proposal
1 parent ce2879f commit 4a233d7

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

Sources/Build/BuildDescription/ClangModuleBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import struct PackageGraph.ModulesGraph
1818
import struct PackageGraph.ResolvedModule
1919
import struct SPMBuildCore.BuildParameters
2020
import struct SPMBuildCore.BuildToolPluginInvocationResult
21-
import struct SPMBuildCore.PrebuildCommandResult
21+
import struct SPMBuildCore.CommandPluginResult
2222

2323
@available(*, deprecated, renamed: "ClangModuleBuildDescription")
2424
public typealias ClangTargetBuildDescription = ClangModuleBuildDescription
@@ -120,7 +120,7 @@ public final class ClangModuleBuildDescription {
120120
additionalFileRules: [FileRuleDescription] = [],
121121
buildParameters: BuildParameters,
122122
buildToolPluginInvocationResults: [BuildToolPluginInvocationResult] = [],
123-
prebuildCommandResults: [PrebuildCommandResult] = [],
123+
prebuildCommandResults: [CommandPluginResult] = [],
124124
fileSystem: FileSystem,
125125
observabilityScope: ObservabilityScope
126126
) throws {

Sources/Build/BuildDescription/SwiftModuleBuildDescription.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public final class SwiftModuleBuildDescription {
235235
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]
236236

237237
/// The results of running any prebuild commands for this target.
238-
public let prebuildCommandResults: [PrebuildCommandResult]
238+
public let prebuildCommandResults: [CommandPluginResult]
239239

240240
/// Any macro products that this target requires to build.
241241
public let requiredMacroProducts: [ProductBuildDescription]
@@ -257,7 +257,7 @@ public final class SwiftModuleBuildDescription {
257257
additionalFileRules: [FileRuleDescription] = [],
258258
buildParameters: BuildParameters,
259259
buildToolPluginInvocationResults: [BuildToolPluginInvocationResult] = [],
260-
prebuildCommandResults: [PrebuildCommandResult] = [],
260+
prebuildCommandResults: [CommandPluginResult] = [],
261261
requiredMacroProducts: [ProductBuildDescription] = [],
262262
testTargetRole: TestTargetRole? = nil,
263263
shouldGenerateTestObservation: Bool = false,

Sources/Build/BuildPlan/BuildPlan.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
220220

221221
/// The results of running any prebuild commands for the targets in this build. This includes any derived
222222
/// source files as well as directories to which any changes should cause us to reevaluate the build plan.
223-
public let prebuildCommandResults: [ResolvedModule.ID: [PrebuildCommandResult]]
223+
public let prebuildCommandResults: [ResolvedModule.ID: [CommandPluginResult]]
224224

225225
@_spi(SwiftPMInternal)
226226
public private(set) var derivedTestTargetsMap: [ResolvedProduct.ID: [ResolvedModule]] = [:]
@@ -283,7 +283,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
283283
self.observabilityScope = observabilityScope.makeChildScope(description: "Build Plan")
284284

285285
var buildToolPluginInvocationResults: [ResolvedModule.ID: [BuildToolPluginInvocationResult]] = [:]
286-
var prebuildCommandResults: [ResolvedModule.ID: [PrebuildCommandResult]] = [:]
286+
var prebuildCommandResults: [ResolvedModule.ID: [CommandPluginResult]] = [:]
287287

288288
var productMap: [ResolvedProduct.ID: (product: ResolvedProduct, buildDescription: ProductBuildDescription)] =
289289
[:]
@@ -378,7 +378,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
378378
}
379379

380380
buildToolPluginInvocationResults[target.id] = pluginInvocationResults
381-
prebuildCommandResults[target.id] = try Self.runPrebuildCommands(
381+
prebuildCommandResults[target.id] = try Self.runCommandPlugins(
382382
using: pluginConfiguration,
383383
for: pluginInvocationResults,
384384
fileSystem: fileSystem,
@@ -864,14 +864,14 @@ extension BuildPlan {
864864
return buildToolPluginResults
865865
}
866866

867-
/// Runs any prebuild commands associated with the given list of plugin invocation results,
867+
/// Runs any command plugins associated with the given list of plugin invocation results,
868868
/// in order, and returns the results of running those prebuild commands.
869-
fileprivate static func runPrebuildCommands(
869+
fileprivate static func runCommandPlugins(
870870
using pluginConfiguration: PluginConfiguration,
871871
for pluginResults: [BuildToolPluginInvocationResult],
872872
fileSystem: any FileSystem,
873873
observabilityScope: ObservabilityScope
874-
) throws -> [PrebuildCommandResult] {
874+
) throws -> [CommandPluginResult] {
875875
// Run through all the commands from all the plugin usages in the target.
876876
try pluginResults.map { pluginResult in
877877
// As we go we will collect a list of prebuild output directories whose contents should be input to the
@@ -916,7 +916,7 @@ extension BuildPlan {
916916
}
917917

918918
// Add the results of running any prebuild commands for this invocation.
919-
return PrebuildCommandResult(derivedFiles: derivedFiles, outputDirectories: prebuildOutputDirs)
919+
return CommandPluginResult(derivedFiles: derivedFiles, outputDirectories: prebuildOutputDirs)
920920
}
921921
}
922922
}

Sources/SPMBuildCore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ add_library(SPMBuildCore
2222
Plugins/PluginInvocation.swift
2323
Plugins/PluginMessages.swift
2424
Plugins/PluginScriptRunner.swift
25-
PrebuildCommandResult.swift
25+
CommandPluginResult.swift
2626
ResolvedPackage+Extensions.swift
2727
Triple+Extensions.swift
2828
XCFrameworkMetadata.swift)

Sources/SPMBuildCore/PrebuildCommandResult.swift renamed to Sources/SPMBuildCore/CommandPluginResult.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212

1313
import Basics
1414

15-
/// Represents the result of running prebuild commands for a single plugin invocation for a target.
16-
public struct PrebuildCommandResult {
15+
@available(*,
16+
deprecated,
17+
renamed: "CommandPluginResult",
18+
message: "renamed to unify terminology with the Swift Evolution proposal"
19+
)
20+
public typealias PrebuildCommandResult = CommandPluginResult
21+
22+
/// Represents the result of running a command plugin for a single plugin invocation for a target.
23+
public struct CommandPluginResult {
1724
/// Paths of any derived files that should be included in the build.
1825
public var derivedFiles: [AbsolutePath]
1926

Sources/SPMBuildCore/Plugins/PluginInvocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ extension ModulesGraph {
537537
additionalFileRules: [FileRuleDescription],
538538
buildParameters: BuildParameters,
539539
buildToolPluginInvocationResults: [BuildToolPluginInvocationResult],
540-
prebuildCommandResults: [PrebuildCommandResult],
540+
prebuildCommandResults: [CommandPluginResult],
541541
observabilityScope: ObservabilityScope
542542
) -> (pluginDerivedSources: Sources, pluginDerivedResources: [Resource]) {
543543
var pluginDerivedSources = Sources(paths: [], root: buildParameters.dataPath)

0 commit comments

Comments
 (0)