Skip to content

Rename "extension" to "plugin" in the implementation of SE-0303 to align with the proposal #3311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import PackageDescription
let package = Package(
name: "MySourceGenClient",
dependencies: [
.package(path: "../MySourceGenExtension")
.package(path: "../MySourceGenPlugin")
],
targets: [
// A tool that uses an extension.
// A tool that uses an plugin.
.executableTarget(
name: "MyTool",
dependencies: [
.product(name: "MySourceGenExt", package: "MySourceGenExtension")
.product(name: "MySourceGenPlugin", package: "MySourceGenPlugin")
]
),
// A unit that uses the extension.
// A unit that uses the plugin.
.testTarget(
name: "MyTests",
dependencies: [
.product(name: "MySourceGenExt", package: "MySourceGenExtension")
.product(name: "MySourceGenPlugin", package: "MySourceGenPlugin")
]
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
import PackageDescription

let package = Package(
name: "MySourceGenExtension",
name: "MySourceGenPlugin",
products: [
// The product that vends MySourceGenExt to client packages.
.extension(
name: "MySourceGenExt",
targets: ["MySourceGenExt"]
// The product that vends MySourceGenPlugin to client packages.
.plugin(
name: "MySourceGenPlugin",
targets: ["MySourceGenPlugin"]
),
.executable(
name: "MySourceGenTool",
targets: ["MySourceGenTool"]
)
],
targets: [
// A local tool that uses an extension.
// A local tool that uses a plugin.
.executableTarget(
name: "MyLocalTool",
dependencies: [
"MySourceGenExt",
"MySourceGenPlugin",
]
),
// The target that implements the extension and generates commands to invoke MySourceGenTool.
.extension(
name: "MySourceGenExt",
// The target that implements the plugin and generates commands to invoke MySourceGenTool.
.plugin(
name: "MySourceGenPlugin",
capability: .buildTool(),
dependencies: [
"MySourceGenTool"
Expand All @@ -45,11 +45,11 @@ let package = Package(
.target(
name: "MySourceGenRuntimeLib"
),
// Unit tests for the extension.
// Unit tests for the plugin.
.testTarget(
name: "MySourceGenExtTests",
name: "MySourceGenPluginTests",
dependencies: [
"MySourceGenExt",
"MySourceGenPlugin",
"MySourceGenRuntimeLib"
]
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PackageExtension
import PackagePlugin

for inputPath in targetBuildContext.otherFiles {
guard inputPath.suffix == ".dat" else { continue }
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ let package = Package(
),

.library(
name: "PackageExtension",
name: "PackagePlugin",
type: .dynamic,
targets: ["PackageExtension"]
targets: ["PackagePlugin"]
),

.library(
Expand Down Expand Up @@ -125,7 +125,7 @@ let package = Package(
]),

.target(
name: "PackageExtension"),
name: "PackagePlugin"),

// MARK: SwiftPM specific support libraries

Expand Down
18 changes: 9 additions & 9 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

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

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

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

/// The llbuild build delegate reference.
private var buildSystemDelegate: BuildOperationBuildSystemDelegateHandler?
Expand Down Expand Up @@ -63,14 +63,14 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
buildParameters: BuildParameters,
cacheBuildManifest: Bool,
packageGraphLoader: @escaping () throws -> PackageGraph,
extensionEvaluator: @escaping (PackageGraph) throws -> [ResolvedTarget: [ExtensionEvaluationResult]],
pluginInvoker: @escaping (PackageGraph) throws -> [ResolvedTarget: [PluginInvocationResult]],
diagnostics: DiagnosticsEngine,
stdoutStream: OutputByteStream
) {
self.buildParameters = buildParameters
self.cacheBuildManifest = cacheBuildManifest
self.packageGraphLoader = packageGraphLoader
self.extensionEvaluator = extensionEvaluator
self.pluginInvoker = pluginInvoker
self.diagnostics = diagnostics
self.stdoutStream = stdoutStream
}
Expand All @@ -81,8 +81,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
}
}

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

/// Compute and return the latest build description.
Expand Down Expand Up @@ -166,11 +166,11 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
/// Create the build plan and return the build description.
private func plan() throws -> BuildDescription {
let graph = try getPackageGraph()
let extensionEvaluationResults = try getExtensionEvaluationResults(for: graph)
let pluginInvocationResults = try getPluginInvocationResults(for: graph)
let plan = try BuildPlan(
buildParameters: buildParameters,
graph: graph,
extensionEvaluationResults: extensionEvaluationResults,
pluginInvocationResults: pluginInvocationResults,
diagnostics: diagnostics
)
self.buildPlan = plan
Expand Down
42 changes: 21 additions & 21 deletions Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,14 @@ public final class SwiftTargetBuildDescription {
/// The modulemap file for this target, if any.
private(set) var moduleMap: AbsolutePath?

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

/// Create a new target description with target and build parameters.
init(
target: ResolvedTarget,
buildParameters: BuildParameters,
extensionEvaluationResults: [ExtensionEvaluationResult] = [],
pluginInvocationResults: [PluginInvocationResult] = [],
isTestTarget: Bool? = nil,
testDiscoveryTarget: Bool = false,
fs: FileSystem = localFileSystem
Expand All @@ -562,12 +562,12 @@ public final class SwiftTargetBuildDescription {
self.fs = fs
self.tempsPath = buildParameters.buildPath.appending(component: target.c99name + ".build")
self.derivedSources = Sources(paths: [], root: tempsPath.appending(component: "DerivedSources"))
self.extensionEvaluationResults = extensionEvaluationResults
self.pluginInvocationResults = pluginInvocationResults

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

case .executable, .systemModule, .binary, .extension:
case .executable, .systemModule, .binary, .plugin:
do { }
}

Expand Down Expand Up @@ -1133,8 +1133,8 @@ public final class ProductBuildDescription {
}
}
args += ["-emit-executable"]
case .extension:
throw InternalError("unexpectedly asked to generate linker arguments for an extension product")
case .plugin:
throw InternalError("unexpectedly asked to generate linker arguments for a plugin product")
}

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

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

/// The filesystem to operate on.
let fileSystem: FileSystem
Expand Down Expand Up @@ -1357,13 +1357,13 @@ public class BuildPlan {
public init(
buildParameters: BuildParameters,
graph: PackageGraph,
extensionEvaluationResults: [ResolvedTarget: [ExtensionEvaluationResult]] = [:],
pluginInvocationResults: [ResolvedTarget: [PluginInvocationResult]] = [:],
diagnostics: DiagnosticsEngine,
fileSystem: FileSystem = localFileSystem
) throws {
self.buildParameters = buildParameters
self.graph = graph
self.extensionEvaluationResults = extensionEvaluationResults
self.pluginInvocationResults = pluginInvocationResults
self.diagnostics = diagnostics
self.fileSystem = fileSystem

Expand All @@ -1388,15 +1388,15 @@ public class BuildPlan {
targetMap[target] = try .swift(SwiftTargetBuildDescription(
target: target,
buildParameters: buildParameters,
extensionEvaluationResults: extensionEvaluationResults[target] ?? [],
pluginInvocationResults: pluginInvocationResults[target] ?? [],
fs: fileSystem))
case is ClangTarget:
targetMap[target] = try .clang(ClangTargetBuildDescription(
target: target,
buildParameters: buildParameters,
fileSystem: fileSystem,
diagnostics: diagnostics))
case is SystemLibraryTarget, is BinaryTarget, is ExtensionTarget:
case is SystemLibraryTarget, is BinaryTarget, is PluginTarget:
break
default:
fatalError("unhandled \(target.underlyingTarget)")
Expand Down Expand Up @@ -1424,8 +1424,8 @@ public class BuildPlan {

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

// For a product dependency, we only include its content only if we
// need to statically link it or if it's an extension.
// need to statically link it or if it's a plugin.
case .product(let product, _):
switch product.type {
case .library(.automatic), .library(.static), .extension:
case .library(.automatic), .library(.static), .plugin:
return product.targets.map { .target($0, conditions: []) }
case .library(.dynamic), .test, .executable:
return []
Expand Down Expand Up @@ -1640,7 +1640,7 @@ public class BuildPlan {
let tools = try self.parseArtifactsArchive(for: binaryTarget)
tools.forEach { availableTools[$0.name] = $0.executablePath }
}
case .extension:
case .plugin:
continue
}

Expand Down
18 changes: 9 additions & 9 deletions Sources/Build/ManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ extension LLBuildManifestBuilder {
if target.underlyingTarget is SystemLibraryTarget { return }
// Ignore Binary Modules.
if target.underlyingTarget is BinaryTarget { return }
// Ignore Extension Targets.
if target.underlyingTarget is ExtensionTarget { return }
// Ignore Plugin Targets.
if target.underlyingTarget is PluginTarget { return }

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

// For automatic and static libraries, and extensions, add their targets as static input.
case .library(.automatic), .library(.static), .extension:
// For automatic and static libraries, and plugins, add their targets as static input.
case .library(.automatic), .library(.static), .plugin:
for target in product.targets {
try addStaticTargetInputs(target)
}
Expand All @@ -575,8 +575,8 @@ extension LLBuildManifestBuilder {
}
}

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

case .library(.automatic), .library(.static), .extension:
case .library(.automatic), .library(.static), .plugin:
for target in product.targets {
addStaticTargetInputs(target)
}
Expand Down Expand Up @@ -847,8 +847,8 @@ extension ResolvedProduct {
throw InternalError("automatic library not supported")
case .executable:
return "\(name)-\(config).exe"
case .extension:
throw InternalError("unexpectedly asked for the llbuild target name of an extension product")
case .plugin:
throw InternalError("unexpectedly asked for the llbuild target name of a plugin product")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ add_subdirectory(PackageCollections)
add_subdirectory(PackageCollectionsModel)
add_subdirectory(PackageCollectionsSigning)
add_subdirectory(PackageDescription)
add_subdirectory(PackageExtension)
add_subdirectory(PackageGraph)
add_subdirectory(PackageLoading)
add_subdirectory(PackageModel)
add_subdirectory(PackagePlugin)
add_subdirectory(SPMBuildCore)
add_subdirectory(SPMLLBuild)
add_subdirectory(SourceControl)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Commands/APIDigester.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct APIDigesterBaselineDumper {
buildParameters: buildParameters,
cacheBuildManifest: false,
packageGraphLoader: { graph },
extensionEvaluator: { _ in [:] },
pluginInvoker: { _ in [:] },
diagnostics: diags,
stdoutStream: stdoutStream
)
Expand Down
Loading