Skip to content

Commit c2cb3b7

Browse files
committed
WIP: Rename "extension" to "plugin" to align with SE-0303
1 parent 6814c34 commit c2cb3b7

File tree

54 files changed

+493
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+493
-412
lines changed

Fixtures/Miscellaneous/Extensions/MySourceGenClient/Package.swift renamed to Fixtures/Miscellaneous/Plugins/MySourceGenClient/Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ import PackageDescription
44
let package = Package(
55
name: "MySourceGenClient",
66
dependencies: [
7-
.package(path: "../MySourceGenExtension")
7+
.package(path: "../MySourceGenPlugin")
88
],
99
targets: [
10-
// A tool that uses an extension.
10+
// A tool that uses an plugin.
1111
.executableTarget(
1212
name: "MyTool",
1313
dependencies: [
14-
.product(name: "MySourceGenExt", package: "MySourceGenExtension")
14+
.product(name: "MySourceGenPlugin", package: "MySourceGenPlugin")
1515
]
1616
),
17-
// A unit that uses the extension.
17+
// A unit that uses the plugin.
1818
.testTarget(
1919
name: "MyTests",
2020
dependencies: [
21-
.product(name: "MySourceGenExt", package: "MySourceGenExtension")
21+
.product(name: "MySourceGenPlugin", package: "MySourceGenPlugin")
2222
]
2323
)
2424
]

Fixtures/Miscellaneous/Extensions/MySourceGenExtension/Package.swift renamed to Fixtures/Miscellaneous/Plugins/MySourceGenPlugin/Package.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22
import PackageDescription
33

44
let package = Package(
5-
name: "MySourceGenExtension",
5+
name: "MySourceGenPlugin",
66
products: [
7-
// The product that vends MySourceGenExt to client packages.
8-
.extension(
9-
name: "MySourceGenExt",
10-
targets: ["MySourceGenExt"]
7+
// The product that vends MySourceGenPlugin to client packages.
8+
.plugin(
9+
name: "MySourceGenPlugin",
10+
targets: ["MySourceGenPlugin"]
1111
),
1212
.executable(
1313
name: "MySourceGenTool",
1414
targets: ["MySourceGenTool"]
1515
)
1616
],
1717
targets: [
18-
// A local tool that uses an extension.
18+
// A local tool that uses a plugin.
1919
.executableTarget(
2020
name: "MyLocalTool",
2121
dependencies: [
22-
"MySourceGenExt",
22+
"MySourceGenPlugin",
2323
]
2424
),
25-
// The target that implements the extension and generates commands to invoke MySourceGenTool.
26-
.extension(
27-
name: "MySourceGenExt",
25+
// The target that implements the plugin and generates commands to invoke MySourceGenTool.
26+
.plugin(
27+
name: "MySourceGenPlugin",
2828
capability: .buildTool(),
2929
dependencies: [
3030
"MySourceGenTool"
@@ -45,11 +45,11 @@ let package = Package(
4545
.target(
4646
name: "MySourceGenRuntimeLib"
4747
),
48-
// Unit tests for the extension.
48+
// Unit tests for the plugin.
4949
.testTarget(
50-
name: "MySourceGenExtTests",
50+
name: "MySourceGenPluginTests",
5151
dependencies: [
52-
"MySourceGenExt",
52+
"MySourceGenPlugin",
5353
"MySourceGenRuntimeLib"
5454
]
5555
)

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ let package = Package(
9292
),
9393

9494
.library(
95-
name: "PackageExtension",
95+
name: "PackagePlugin",
9696
type: .dynamic,
97-
targets: ["PackageExtension"]
97+
targets: ["PackagePlugin"]
9898
),
9999

100100
.library(
@@ -125,7 +125,7 @@ let package = Package(
125125
]),
126126

127127
.target(
128-
name: "PackageExtension"),
128+
name: "PackagePlugin"),
129129

130130
// MARK: SwiftPM specific support libraries
131131

Sources/Build/BuildOperation.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright 2015 - 2019 Apple Inc. and the Swift project authors
4+
Copyright 2015 - 2021 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -31,8 +31,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
3131
/// The closure for loading the package graph.
3232
let packageGraphLoader: () throws -> PackageGraph
3333

34-
/// The closure for evaluating extensions in the package graph.
35-
let extensionEvaluator: (PackageGraph) throws -> [ResolvedTarget: [ExtensionEvaluationResult]]
34+
/// The closure for invoking plugins in the package graph.
35+
let pluginInvoker: (PackageGraph) throws -> [ResolvedTarget: [PluginInvocationResult]]
3636

3737
/// The llbuild build delegate reference.
3838
private var buildSystemDelegate: BuildOperationBuildSystemDelegateHandler?
@@ -63,14 +63,14 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
6363
buildParameters: BuildParameters,
6464
cacheBuildManifest: Bool,
6565
packageGraphLoader: @escaping () throws -> PackageGraph,
66-
extensionEvaluator: @escaping (PackageGraph) throws -> [ResolvedTarget: [ExtensionEvaluationResult]],
66+
pluginInvoker: @escaping (PackageGraph) throws -> [ResolvedTarget: [PluginInvocationResult]],
6767
diagnostics: DiagnosticsEngine,
6868
stdoutStream: OutputByteStream
6969
) {
7070
self.buildParameters = buildParameters
7171
self.cacheBuildManifest = cacheBuildManifest
7272
self.packageGraphLoader = packageGraphLoader
73-
self.extensionEvaluator = extensionEvaluator
73+
self.pluginInvoker = pluginInvoker
7474
self.diagnostics = diagnostics
7575
self.stdoutStream = stdoutStream
7676
}
@@ -81,8 +81,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
8181
}
8282
}
8383

84-
public func getExtensionEvaluationResults(for graph: PackageGraph) throws -> [ResolvedTarget: [ExtensionEvaluationResult]] {
85-
return try self.extensionEvaluator(graph)
84+
public func getPluginInvocationResults(for graph: PackageGraph) throws -> [ResolvedTarget: [PluginInvocationResult]] {
85+
return try self.pluginInvoker(graph)
8686
}
8787

8888
/// Compute and return the latest build description.
@@ -166,11 +166,11 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
166166
/// Create the build plan and return the build description.
167167
private func plan() throws -> BuildDescription {
168168
let graph = try getPackageGraph()
169-
let extensionEvaluationResults = try getExtensionEvaluationResults(for: graph)
169+
let pluginInvocationResults = try getPluginInvocationResults(for: graph)
170170
let plan = try BuildPlan(
171171
buildParameters: buildParameters,
172172
graph: graph,
173-
extensionEvaluationResults: extensionEvaluationResults,
173+
pluginInvocationResults: pluginInvocationResults,
174174
diagnostics: diagnostics
175175
)
176176
self.buildPlan = plan

Sources/Build/BuildPlan.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,14 @@ public final class SwiftTargetBuildDescription {
541541
/// The modulemap file for this target, if any.
542542
private(set) var moduleMap: AbsolutePath?
543543

544-
/// The results of having applied any extensions to this target.
545-
public let extensionEvaluationResults: [ExtensionEvaluationResult]
544+
/// The results of applying any plugins to this target.
545+
public let pluginInvocationResults: [PluginInvocationResult]
546546

547547
/// Create a new target description with target and build parameters.
548548
init(
549549
target: ResolvedTarget,
550550
buildParameters: BuildParameters,
551-
extensionEvaluationResults: [ExtensionEvaluationResult] = [],
551+
pluginInvocationResults: [PluginInvocationResult] = [],
552552
isTestTarget: Bool? = nil,
553553
testDiscoveryTarget: Bool = false,
554554
fs: FileSystem = localFileSystem
@@ -562,12 +562,12 @@ public final class SwiftTargetBuildDescription {
562562
self.fs = fs
563563
self.tempsPath = buildParameters.buildPath.appending(component: target.c99name + ".build")
564564
self.derivedSources = Sources(paths: [], root: tempsPath.appending(component: "DerivedSources"))
565-
self.extensionEvaluationResults = extensionEvaluationResults
565+
self.pluginInvocationResults = pluginInvocationResults
566566

567-
// Add any derived source paths declared by build-tool extensions that were applied to this target. We do
567+
// Add any derived source paths declared by build-tool plugins that were applied to this target. We do
568568
// this here and not just in the LLBuildManifestBuilder because we need to include them in any situation
569569
// where sources are processed, e.g. when determining names of object files, etc.
570-
for command in extensionEvaluationResults.reduce([], { $0 + $1.commands }) {
570+
for command in pluginInvocationResults.reduce([], { $0 + $1.commands }) {
571571
// Prebuild and postbuild commands are handled outside the build system.
572572
if case .buildToolCommand(_, _, _, _, _, _, _, let derivedSourcePaths) = command {
573573
// TODO: What should we do if we find non-Swift sources here?
@@ -717,7 +717,7 @@ public final class SwiftTargetBuildDescription {
717717
case .library, .test:
718718
result.append("-parse-as-library")
719719

720-
case .executable, .systemModule, .binary, .extension:
720+
case .executable, .systemModule, .binary, .plugin:
721721
do { }
722722
}
723723

@@ -1133,8 +1133,8 @@ public final class ProductBuildDescription {
11331133
}
11341134
}
11351135
args += ["-emit-executable"]
1136-
case .extension:
1137-
throw InternalError("unexpectedly asked to generate linker arguments for an extension product")
1136+
case .plugin:
1137+
throw InternalError("unexpectedly asked to generate linker arguments for a plugin product")
11381138
}
11391139

11401140
// Set rpath such that dynamic libraries are looked up
@@ -1150,7 +1150,7 @@ public final class ProductBuildDescription {
11501150
// Embed the swift stdlib library path inside tests and executables on Darwin.
11511151
if containsSwiftTargets {
11521152
switch product.type {
1153-
case .library, .extension: break
1153+
case .library, .plugin: break
11541154
case .test, .executable:
11551155
if buildParameters.triple.isDarwin() {
11561156
let stdlib = buildParameters.toolchain.macosSwiftStdlib
@@ -1275,8 +1275,8 @@ public class BuildPlan {
12751275
return AnySequence(productMap.values)
12761276
}
12771277

1278-
/// The results of evaluating any extensions used by targets in this build.
1279-
public let extensionEvaluationResults: [ResolvedTarget: [ExtensionEvaluationResult]]
1278+
/// The results of invoking any plugins used by targets in this build.
1279+
public let pluginInvocationResults: [ResolvedTarget: [PluginInvocationResult]]
12801280

12811281
/// The filesystem to operate on.
12821282
let fileSystem: FileSystem
@@ -1357,13 +1357,13 @@ public class BuildPlan {
13571357
public init(
13581358
buildParameters: BuildParameters,
13591359
graph: PackageGraph,
1360-
extensionEvaluationResults: [ResolvedTarget: [ExtensionEvaluationResult]] = [:],
1360+
pluginInvocationResults: [ResolvedTarget: [PluginInvocationResult]] = [:],
13611361
diagnostics: DiagnosticsEngine,
13621362
fileSystem: FileSystem = localFileSystem
13631363
) throws {
13641364
self.buildParameters = buildParameters
13651365
self.graph = graph
1366-
self.extensionEvaluationResults = extensionEvaluationResults
1366+
self.pluginInvocationResults = pluginInvocationResults
13671367
self.diagnostics = diagnostics
13681368
self.fileSystem = fileSystem
13691369

@@ -1388,15 +1388,15 @@ public class BuildPlan {
13881388
targetMap[target] = try .swift(SwiftTargetBuildDescription(
13891389
target: target,
13901390
buildParameters: buildParameters,
1391-
extensionEvaluationResults: extensionEvaluationResults[target] ?? [],
1391+
pluginInvocationResults: pluginInvocationResults[target] ?? [],
13921392
fs: fileSystem))
13931393
case is ClangTarget:
13941394
targetMap[target] = try .clang(ClangTargetBuildDescription(
13951395
target: target,
13961396
buildParameters: buildParameters,
13971397
fileSystem: fileSystem,
13981398
diagnostics: diagnostics))
1399-
case is SystemLibraryTarget, is BinaryTarget, is ExtensionTarget:
1399+
case is SystemLibraryTarget, is BinaryTarget, is PluginTarget:
14001400
break
14011401
default:
14021402
fatalError("unhandled \(target.underlyingTarget)")
@@ -1424,8 +1424,8 @@ public class BuildPlan {
14241424

14251425
var productMap: [ResolvedProduct: ProductBuildDescription] = [:]
14261426
// Create product description for each product we have in the package graph except
1427-
// for automatic libraries and extension because they don't produce any output.
1428-
for product in graph.allProducts where product.type != .library(.automatic) && product.type != .extension {
1427+
// for automatic libraries and plugins, because they don't produce any output.
1428+
for product in graph.allProducts where product.type != .library(.automatic) && product.type != .plugin {
14291429
productMap[product] = ProductBuildDescription(
14301430
product: product, buildParameters: buildParameters,
14311431
fs: fileSystem,
@@ -1591,10 +1591,10 @@ public class BuildPlan {
15911591
return target.dependencies.filter { $0.satisfies(self.buildEnvironment) }
15921592

15931593
// For a product dependency, we only include its content only if we
1594-
// need to statically link it or if it's an extension.
1594+
// need to statically link it or if it's a plugin.
15951595
case .product(let product, _):
15961596
switch product.type {
1597-
case .library(.automatic), .library(.static), .extension:
1597+
case .library(.automatic), .library(.static), .plugin:
15981598
return product.targets.map { .target($0, conditions: []) }
15991599
case .library(.dynamic), .test, .executable:
16001600
return []
@@ -1640,7 +1640,7 @@ public class BuildPlan {
16401640
let tools = try self.parseArtifactsArchive(for: binaryTarget)
16411641
tools.forEach { availableTools[$0.name] = $0.executablePath }
16421642
}
1643-
case .extension:
1643+
case .plugin:
16441644
continue
16451645
}
16461646

Sources/Build/ManifestBuilder.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ extension LLBuildManifestBuilder {
510510
if target.underlyingTarget is SystemLibraryTarget { return }
511511
// Ignore Binary Modules.
512512
if target.underlyingTarget is BinaryTarget { return }
513-
// Ignore Extension Targets.
514-
if target.underlyingTarget is ExtensionTarget { return }
513+
// Ignore Plugin Targets.
514+
if target.underlyingTarget is PluginTarget { return }
515515

516516
// Depend on the binary for executable targets.
517517
if target.type == .executable {
@@ -554,8 +554,8 @@ extension LLBuildManifestBuilder {
554554
// Establish a dependency on binary of the product.
555555
inputs.append(file: planProduct.binary)
556556

557-
// For automatic and static libraries, and extensions, add their targets as static input.
558-
case .library(.automatic), .library(.static), .extension:
557+
// For automatic and static libraries, and plugins, add their targets as static input.
558+
case .library(.automatic), .library(.static), .plugin:
559559
for target in product.targets {
560560
try addStaticTargetInputs(target)
561561
}
@@ -575,8 +575,8 @@ extension LLBuildManifestBuilder {
575575
}
576576
}
577577

578-
// Add any build tool commands created by extensions for the target (prebuild and postbuild commands are handled outside the build).
579-
for command in target.extensionEvaluationResults.reduce([], { $0 + $1.commands }) {
578+
// Add any build tool commands created by plugins for the target (prebuild and postbuild commands are handled outside the build).
579+
for command in target.pluginInvocationResults.reduce([], { $0 + $1.commands }) {
580580
if case .buildToolCommand(let displayName, let executable, let arguments, _, _, let inputPaths, let outputPaths, _) = command {
581581
// Create a shell command to invoke the executable. We include the path of the executable as a dependency.
582582
// FIXME: We will need to extend the addShellCmd() function to also take working directory and environment.
@@ -674,7 +674,7 @@ extension LLBuildManifestBuilder {
674674
let binary = planProduct.binary
675675
inputs.append(file: binary)
676676

677-
case .library(.automatic), .library(.static), .extension:
677+
case .library(.automatic), .library(.static), .plugin:
678678
for target in product.targets {
679679
addStaticTargetInputs(target)
680680
}
@@ -847,8 +847,8 @@ extension ResolvedProduct {
847847
throw InternalError("automatic library not supported")
848848
case .executable:
849849
return "\(name)-\(config).exe"
850-
case .extension:
851-
throw InternalError("unexpectedly asked for the llbuild target name of an extension product")
850+
case .plugin:
851+
throw InternalError("unexpectedly asked for the llbuild target name of a plugin product")
852852
}
853853
}
854854

Sources/Commands/APIDigester.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct APIDigesterBaselineDumper {
112112
buildParameters: buildParameters,
113113
cacheBuildManifest: false,
114114
packageGraphLoader: { graph },
115-
extensionEvaluator: { _ in [:] },
115+
pluginInvoker: { _ in [:] },
116116
diagnostics: diags,
117117
stdoutStream: stdoutStream
118118
)

0 commit comments

Comments
 (0)