Skip to content

Commit 6eec455

Browse files
authored
Clean up remaining uses of "extension" terminology (it's now "plugin"). (#3329)
1 parent 037a616 commit 6eec455

File tree

5 files changed

+22
-82
lines changed

5 files changed

+22
-82
lines changed

Sources/PackageGraph/PackageGraph+Loading.swift

Lines changed: 3 additions & 3 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 (c) 2014 - 2020 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 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
@@ -30,7 +30,7 @@ extension PackageGraph {
3030
diagnostics: DiagnosticsEngine,
3131
fileSystem: FileSystem = localFileSystem,
3232
shouldCreateMultipleTestProducts: Bool = false,
33-
allowExtensionTargets: Bool = false,
33+
allowPluginTargets: Bool = false,
3434
createREPLProduct: Bool = false
3535
) throws -> PackageGraph {
3636

@@ -114,7 +114,7 @@ extension PackageGraph {
114114
fileSystem: fileSystem,
115115
diagnostics: diagnostics,
116116
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
117-
allowPluginTargets: allowExtensionTargets,
117+
allowPluginTargets: allowPluginTargets,
118118
createREPLProduct: manifest.packageKind == .root ? createREPLProduct : false
119119
)
120120
let package = try builder.construct()

Sources/SPMBuildCore/PluginInvocation.swift

Lines changed: 7 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ extension PackageGraph {
6060
// Evaluate each plugin in turn, creating a list of results (one for each plugin used by the target).
6161
var evalResults: [PluginInvocationResult] = []
6262
for pluginTarget in pluginTargets {
63-
// Give each invocation of an extension a separate output directory.
64-
let extOutputDir = outputDir.appending(components: package.name, target.name, pluginTarget.name)
63+
// Give each invocation of a plugin a separate output directory.
64+
let pluginOutputDir = outputDir.appending(components: package.name, target.name, pluginTarget.name)
6565
do {
66-
try fileSystem.createDirectory(extOutputDir, recursive: true)
66+
try fileSystem.createDirectory(pluginOutputDir, recursive: true)
6767
}
6868
catch {
69-
throw PluginEvaluationError.outputDirectoryCouldNotBeCreated(path: extOutputDir, underlyingError: error)
69+
throw PluginEvaluationError.outputDirectoryCouldNotBeCreated(path: pluginOutputDir, underlyingError: error)
7070
}
7171

7272
// Create the input context to pass to the plugin.
@@ -81,7 +81,7 @@ extension PackageGraph {
8181
dependencies: dependencyTargets.map {
8282
.init(targetName: $0.name, moduleName: $0.c99name, targetDir: $0.sources.root.pathString)
8383
},
84-
outputDir: extOutputDir.pathString,
84+
outputDir: pluginOutputDir.pathString,
8585
toolsDir: execsDir.pathString
8686
)
8787

@@ -165,24 +165,6 @@ extension PackageGraph {
165165
return evalResultsByTarget
166166
}
167167

168-
@available(*, deprecated, message: "used evaluationPlugins() instead")
169-
public func evaluateExtensions(
170-
buildEnvironment: BuildEnvironment,
171-
execsDir: AbsolutePath,
172-
outputDir: AbsolutePath,
173-
extensionRunner: PluginScriptRunner,
174-
diagnostics: DiagnosticsEngine,
175-
fileSystem: FileSystem
176-
) throws -> [ResolvedTarget: [PluginInvocationResult]] {
177-
return try self.invokePlugins(
178-
buildEnvironment: buildEnvironment,
179-
execsDir: execsDir,
180-
outputDir: outputDir,
181-
pluginScriptRunner: extensionRunner,
182-
diagnostics: diagnostics,
183-
fileSystem: fileSystem)
184-
}
185-
186168

187169
/// Private helper function that serializes a PluginEvaluationInput as input JSON, calls the plugin runner to invoke the plugin, and finally deserializes the output JSON it emits to a PluginEvaluationOutput. Adds any errors or warnings to `diagnostics`, and throws an error if there was a failure.
188170
/// FIXME: This should be asynchronous, taking a queue and a completion closure.
@@ -282,7 +264,6 @@ public struct PluginInvocationResult {
282264
/// Any textual output emitted by the plugin.
283265
public var textOutput: String
284266
}
285-
public typealias ExtensionEvaluationResult = PluginInvocationResult
286267

287268

288269
/// An error in plugin evaluation.
@@ -291,7 +272,6 @@ public enum PluginEvaluationError: Swift.Error {
291272
case runningPluginFailed(underlyingError: Error)
292273
case decodingPluginOutputFailed(json: Data, underlyingError: Error)
293274
}
294-
public typealias ExtensionEvaluationError = PluginEvaluationError
295275

296276

297277
/// Implements the mechanics of running a plugin script (implemented as a set of Swift source files) as a process.
@@ -315,50 +295,10 @@ public protocol PluginScriptRunner {
315295
diagnostics: DiagnosticsEngine,
316296
fileSystem: FileSystem
317297
) throws -> (outputJSON: Data, stdoutText: Data)
318-
319-
@available(*, deprecated, message: "use runPluginScript() instead")
320-
func runExtension(
321-
sources: Sources,
322-
inputJSON: Data,
323-
toolsVersion: ToolsVersion,
324-
diagnostics: DiagnosticsEngine,
325-
fileSystem: FileSystem
326-
) throws -> (outputJSON: Data, stdoutText: Data)
327-
}
328-
extension PluginScriptRunner {
329-
public func runPluginScript(
330-
sources: Sources,
331-
inputJSON: Data,
332-
toolsVersion: ToolsVersion,
333-
diagnostics: DiagnosticsEngine,
334-
fileSystem: FileSystem
335-
) throws -> (outputJSON: Data, stdoutText: Data) {
336-
return try self.runExtension(
337-
sources: sources,
338-
inputJSON: inputJSON,
339-
toolsVersion: toolsVersion,
340-
diagnostics: diagnostics,
341-
fileSystem: fileSystem)
342-
}
343-
public func runExtension(
344-
sources: Sources,
345-
inputJSON: Data,
346-
toolsVersion: ToolsVersion,
347-
diagnostics: DiagnosticsEngine,
348-
fileSystem: FileSystem
349-
) throws -> (outputJSON: Data, stdoutText: Data) {
350-
return try self.runPluginScript(
351-
sources: sources,
352-
inputJSON: inputJSON,
353-
toolsVersion: toolsVersion,
354-
diagnostics: diagnostics,
355-
fileSystem: fileSystem)
356-
}
357298
}
358-
public typealias ExtensionRunner = PluginScriptRunner
359299

360300

361-
/// Serializable context that's passed as input to the evaluation of the extension.
301+
/// Serializable context that's passed as input to the invocation of the plugin.
362302
struct PluginScriptRunnerInput: Codable {
363303
var targetName: String
364304
var moduleName: String
@@ -378,7 +318,7 @@ struct PluginScriptRunnerInput: Codable {
378318
}
379319

380320

381-
/// Deserializable result that's received as output from the evaluation of the extension.
321+
/// Deserializable result that's received as output from the invocation of the plugin.
382322
struct PluginScriptRunnerOutput: Codable {
383323
var version: Int
384324
var diagnostics: [Diagnostic]

Sources/SPMTestSupport/misc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public func loadPackageGraph(
226226
binaryArtifacts: [BinaryArtifact] = [],
227227
explicitProduct: String? = nil,
228228
shouldCreateMultipleTestProducts: Bool = false,
229-
allowExtensionTargets: Bool = false,
229+
allowPluginTargets: Bool = false,
230230
createREPLProduct: Bool = false
231231
) throws -> PackageGraph {
232232
let rootManifests = manifests.filter { $0.packageKind == .root }
@@ -243,7 +243,7 @@ public func loadPackageGraph(
243243
diagnostics: diagnostics,
244244
fileSystem: fs,
245245
shouldCreateMultipleTestProducts: shouldCreateMultipleTestProducts,
246-
allowExtensionTargets: allowExtensionTargets,
246+
allowPluginTargets: allowPluginTargets,
247247
createREPLProduct: createREPLProduct
248248
)
249249
}

Sources/Workspace/Workspace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ extension Workspace {
647647
createREPLProduct: Bool = false,
648648
forceResolvedVersions: Bool = false,
649649
diagnostics: DiagnosticsEngine,
650-
allowExtensionTargets: Bool = false,
650+
allowPluginTargets: Bool = false,
651651
xcTestMinimumDeploymentTargets: [PackageModel.Platform:PlatformVersion]? = nil
652652
) throws -> PackageGraph {
653653

@@ -685,7 +685,7 @@ extension Workspace {
685685
diagnostics: diagnostics,
686686
fileSystem: fileSystem,
687687
shouldCreateMultipleTestProducts: createMultipleTestProducts,
688-
allowExtensionTargets: allowExtensionTargets,
688+
allowPluginTargets: allowPluginTargets,
689689
createREPLProduct: createREPLProduct
690690
)
691691
}

Tests/SPMBuildCoreTests/PluginInvocationTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SPMTestSupport
2020
class PluginInvocationTests: XCTestCase {
2121

2222
func testBasics() throws {
23-
// Construct a canned file system and package graph with a single package and a library that uses an extension that uses a tool.
23+
// Construct a canned file system and package graph with a single package and a library that uses a plugin that uses a tool.
2424
let fileSystem = InMemoryFileSystem(emptyFiles:
2525
"/Foo/Sources/Foo/source.swift",
2626
"/Foo/Sources/Foo/SomeFile.abc",
@@ -62,7 +62,7 @@ class PluginInvocationTests: XCTestCase {
6262
]
6363
)
6464
],
65-
allowExtensionTargets: true
65+
allowPluginTargets: true
6666
)
6767

6868
// Check the basic integrity before running plugins.
@@ -82,9 +82,9 @@ class PluginInvocationTests: XCTestCase {
8282
}
8383
}
8484

85-
// A fake ExtensionRunner that just checks the input conditions and returns canned output.
86-
struct MockExtensionRunner: ExtensionRunner {
87-
func runExtension(
85+
// A fake PluginScriptRunner that just checks the input conditions and returns canned output.
86+
struct MockPluginScriptRunner: PluginScriptRunner {
87+
func runPluginScript(
8888
sources: Sources,
8989
inputJSON: Data,
9090
toolsVersion: ToolsVersion,
@@ -130,12 +130,12 @@ class PluginInvocationTests: XCTestCase {
130130
}
131131
}
132132

133-
// Construct a canned input and run plugins using our MockExtensionRunner().
133+
// Construct a canned input and run plugins using our MockPluginScriptRunner().
134134
let buildEnv = BuildEnvironment(platform: .macOS, configuration: .debug)
135135
let execsDir = AbsolutePath("/Foo/.build/debug")
136136
let outputDir = AbsolutePath("/Foo/.build")
137-
let extRunner = MockExtensionRunner()
138-
let results = try graph.evaluateExtensions(buildEnvironment: buildEnv, execsDir: execsDir, outputDir: outputDir, extensionRunner: extRunner, diagnostics: diagnostics, fileSystem: fileSystem)
137+
let pluginRunner = MockPluginScriptRunner()
138+
let results = try graph.invokePlugins(buildEnvironment: buildEnv, execsDir: execsDir, outputDir: outputDir, pluginScriptRunner: pluginRunner, diagnostics: diagnostics, fileSystem: fileSystem)
139139

140140
// Check the canned output to make sure nothing was lost in transport.
141141
XCTAssertNoDiagnostics(diagnostics)

0 commit comments

Comments
 (0)