Skip to content

Commit b07fb55

Browse files
committed
Add command plugin to package products
Motivation: The command plugin needs to be a product in order for it to be used. Modifications: - Add it to the products - Give it the same name as the command, otherwise diagnostics (like SwiftPM asking for permission to write to the package dir) will use a different name which isn't obvious. - Fix a few build warnings. Result: - Command plugin can be used
1 parent 237ca5f commit b07fb55

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Package.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ let products: [Product] = [
3030
name: "GRPCProtobufGenerator",
3131
targets: ["GRPCProtobufGenerator"]
3232
),
33+
.plugin(
34+
name: "generate-grpc-code-from-protos",
35+
targets: ["generate-grpc-code-from-protos"]
36+
),
3337
]
3438

3539
let dependencies: [Package.Dependency] = [
@@ -118,7 +122,7 @@ let targets: [Target] = [
118122

119123
// Code generator SwiftPM command
120124
.plugin(
121-
name: "GRPCProtobufGeneratorCommand",
125+
name: "generate-grpc-code-from-protos",
122126
capability: .command(
123127
intent: .custom(
124128
verb: "generate-grpc-code-from-protos",
@@ -134,7 +138,8 @@ let targets: [Target] = [
134138
dependencies: [
135139
.target(name: "protoc-gen-grpc-swift"),
136140
.product(name: "protoc-gen-swift", package: "swift-protobuf"),
137-
]
141+
],
142+
path: "Plugins/GRPCProtobufGeneratorCommand"
138143
),
139144
]
140145

Plugins/GRPCProtobufGeneratorCommand/Plugin.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct GRPCProtobufGeneratorCommandPlugin {
145145
outputDirectory: outputDirectory
146146
)
147147

148-
let completionStatus = try executeProtocInvocation(
148+
try executeProtocInvocation(
149149
executableURL: protocPath,
150150
arguments: arguments,
151151
verbose: commandConfig.verbose,
@@ -229,8 +229,6 @@ func executeProtocInvocation(
229229
arguments: arguments,
230230
stdErr: stdErr
231231
)
232-
233-
return
234232
}
235233

236234
func printProtocOutput(_ stdOut: Pipe, verbose: Bool) throws {

0 commit comments

Comments
 (0)