Skip to content

Support macro targets in plugin context #6483

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 1 commit into from
Apr 26, 2023
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
3 changes: 3 additions & 0 deletions Sources/PackagePlugin/PackageModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public enum ModuleKind {
case snippet
/// A module that contains unit tests.
case test
/// A module that contains code for a macro.
@available(_PackageDescription, introduced: 5.9)
case macro // FIXME: This should really come from `CompilerPluginSupport` somehow, but we lack the infrastructure to allow that currently.
}

/// Represents a target consisting of a source code module compiled using Swift.
Expand Down
2 changes: 2 additions & 0 deletions Sources/PackagePlugin/PluginContextDeserializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ fileprivate extension ModuleKind {
self = .snippet
case .test:
self = .test
case .macro:
self = .macro
}
}
}
1 change: 1 addition & 0 deletions Sources/PackagePlugin/PluginMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ enum HostToPluginMessage: Codable {
case executable
case snippet
case test
case macro
}

enum BinaryArtifactKind: Codable {
Expand Down
4 changes: 3 additions & 1 deletion Sources/SPMBuildCore/PluginContextSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ fileprivate extension WireInput.Target.TargetInfo.SourceModuleKind {
self = .snippet
case .test:
self = .test
case .binary, .plugin, .systemModule, .macro:
case .macro:
self = .macro
case .binary, .plugin, .systemModule:
throw StringError("unexpected target kind \(kind) for source module")
}
}
Expand Down