Skip to content

Commit 0ad8cd5

Browse files
committed
[Plugins] Provide plugin invocation and serialization with underlying modules graph
1 parent a52aeb3 commit 0ad8cd5

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

Sources/Commands/PackageCommands/PluginCommand.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ struct PluginCommand: SwiftCommand {
371371
pkgConfigDirectories: swiftCommandState.options.locations.pkgConfigDirectories,
372372
sdkRootPath: buildParameters.toolchain.sdkRootPath,
373373
fileSystem: swiftCommandState.fileSystem,
374+
modulesGraph: packageGraph,
374375
observabilityScope: swiftCommandState.observabilityScope,
375376
callbackQueue: delegateQueue,
376377
delegate: pluginDelegate,

Sources/SPMBuildCore/Plugins/PluginContextSerializer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ typealias WireInput = HostToPluginMessage.InputContext
2222
/// the input information to a plugin.
2323
internal struct PluginContextSerializer {
2424
let fileSystem: FileSystem
25+
let modulesGraph: ModulesGraph
2526
let buildEnvironment: BuildEnvironment
2627
let pkgConfigDirectories: [AbsolutePath]
2728
let sdkRootPath: AbsolutePath?

Sources/SPMBuildCore/Plugins/PluginInvocation.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extension PluginTarget {
4343
pkgConfigDirectories: [AbsolutePath],
4444
sdkRootPath: AbsolutePath?,
4545
fileSystem: FileSystem,
46+
modulesGraph: ModulesGraph,
4647
observabilityScope: ObservabilityScope,
4748
callbackQueue: DispatchQueue,
4849
delegate: PluginInvocationDelegate
@@ -62,6 +63,7 @@ extension PluginTarget {
6263
pkgConfigDirectories: pkgConfigDirectories,
6364
sdkRootPath: sdkRootPath,
6465
fileSystem: fileSystem,
66+
modulesGraph: modulesGraph,
6567
observabilityScope: observabilityScope,
6668
callbackQueue: callbackQueue,
6769
delegate: delegate,
@@ -107,6 +109,7 @@ extension PluginTarget {
107109
pkgConfigDirectories: [AbsolutePath],
108110
sdkRootPath: AbsolutePath?,
109111
fileSystem: FileSystem,
112+
modulesGraph: ModulesGraph,
110113
observabilityScope: ObservabilityScope,
111114
callbackQueue: DispatchQueue,
112115
delegate: PluginInvocationDelegate,
@@ -125,6 +128,7 @@ extension PluginTarget {
125128
do {
126129
var serializer = PluginContextSerializer(
127130
fileSystem: fileSystem,
131+
modulesGraph: modulesGraph,
128132
buildEnvironment: buildEnvironment,
129133
pkgConfigDirectories: pkgConfigDirectories,
130134
sdkRootPath: sdkRootPath
@@ -571,6 +575,7 @@ extension ModulesGraph {
571575
pkgConfigDirectories: pkgConfigDirectories,
572576
sdkRootPath: buildParameters.toolchain.sdkRootPath,
573577
fileSystem: fileSystem,
578+
modulesGraph: self,
574579
observabilityScope: observabilityScope,
575580
callbackQueue: delegateQueue,
576581
delegate: delegate,

Tests/FunctionalTests/PluginTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ final class PluginTests: XCTestCase {
548548
pkgConfigDirectories: [],
549549
sdkRootPath: nil,
550550
fileSystem: localFileSystem,
551+
modulesGraph: packageGraph,
551552
observabilityScope: observability.topScope,
552553
callbackQueue: delegateQueue,
553554
delegate: delegate,
@@ -825,6 +826,7 @@ final class PluginTests: XCTestCase {
825826
pkgConfigDirectories: [],
826827
sdkRootPath: try UserToolchain.default.sdkRootPath,
827828
fileSystem: localFileSystem,
829+
modulesGraph: packageGraph,
828830
observabilityScope: observability.topScope,
829831
callbackQueue: delegateQueue,
830832
delegate: delegate

0 commit comments

Comments
 (0)