Skip to content

Commit c911f1a

Browse files
committed
tweaking
1 parent 7a321b8 commit c911f1a

File tree

17 files changed

+256
-141
lines changed

17 files changed

+256
-141
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"config":[{"name":"Plugin tests (6.0)","swift_version":"6.0","runner":"ubuntu-latest","image":"swift:6.0-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""},{"name":"Plugin tests (nightly-6.0)","swift_version":"nightly-6.0","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-6.0-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""},{"name":"Plugin tests (nightly-main)","swift_version":"nightly-main","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-main-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/rnro/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""}]}
1+
{"config":[{"name":"Plugin tests (6.0)","swift_version":"6.0","runner":"ubuntu-latest","image":"swift:6.0-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/grpc/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""},{"name":"Plugin tests (nightly-6.0)","swift_version":"nightly-6.0","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-6.0-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/grpc/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""},{"name":"Plugin tests (nightly-main)","swift_version":"nightly-main","runner":"ubuntu-latest","image":"swiftlang/swift:nightly-main-jammy","platform":"Linux","setup_command":"apt-get update -y -q && apt-get install -y -q curl","command":"curl -s https://raw.githubusercontent.com/grpc/grpc-swift-protobuf/package_plugins/dev/plugin-tests.sh | bash","command_arguments":""}]}
Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
// swift-tools-version: 6.0
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
2+
/*
3+
* Copyright 2024, gRPC Authors All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
import PackageDescription
519

620
let package = Package(
7-
name: "grpc-adopter",
8-
platforms: [
9-
.macOS(.v15),
10-
.iOS(.v18),
11-
.tvOS(.v18),
12-
.watchOS(.v11),
13-
.visionOS(.v2),
14-
],
15-
dependencies: [
16-
.package(
17-
path: "../../../../grpc-swift-protobuf"
18-
),
19-
.package(
20-
url: "https://github.com/grpc/grpc-swift.git",
21-
from: "1.28.2"
22-
)
23-
],
24-
targets: [
25-
.executableTarget(
26-
name: "grpc-adopter",
27-
dependencies: [
28-
.product(name: "GRPCCore", package: "grpc-swift"),
29-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
30-
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
31-
],
32-
plugins: [
33-
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
34-
]
35-
)
36-
]
21+
name: "grpc-adopter",
22+
platforms: [
23+
.macOS(.v15),
24+
.iOS(.v18),
25+
.tvOS(.v18),
26+
.watchOS(.v11),
27+
.visionOS(.v2),
28+
],
29+
dependencies: [
30+
.package(
31+
path: "../../../../grpc-swift-protobuf"
32+
),
33+
.package(
34+
url: "https://github.com/grpc/grpc-swift.git",
35+
exact: "2.0.0-beta.2"
36+
),
37+
],
38+
targets: [
39+
.executableTarget(
40+
name: "grpc-adopter",
41+
dependencies: [
42+
.product(name: "GRPCCore", package: "grpc-swift"),
43+
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
44+
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
45+
],
46+
plugins: [
47+
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
48+
]
49+
)
50+
]
3751
)

IntegrationTests/PluginTests/test_01_top_level_config_file/Sources/Protos/HelloWorld.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 gRPC authors.
1+
// Copyright 2015, gRPC Authors All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
// swift-tools-version: 6.0
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
2+
/*
3+
* Copyright 2024, gRPC Authors All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
import PackageDescription
519

620
let package = Package(
7-
name: "grpc-adopter",
8-
platforms: [
9-
.macOS(.v15),
10-
.iOS(.v18),
11-
.tvOS(.v18),
12-
.watchOS(.v11),
13-
.visionOS(.v2),
14-
],
15-
dependencies: [
16-
.package(
17-
path: "../../../../grpc-swift-protobuf"
18-
),
19-
.package(
20-
url: "https://github.com/grpc/grpc-swift.git",
21-
from: "1.28.2"
22-
)
23-
],
24-
targets: [
25-
.executableTarget(
26-
name: "grpc-adopter",
27-
dependencies: [
28-
.product(name: "GRPCCore", package: "grpc-swift"),
29-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
30-
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
31-
],
32-
plugins: [
33-
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
34-
]
35-
)
36-
]
21+
name: "grpc-adopter",
22+
platforms: [
23+
.macOS(.v15),
24+
.iOS(.v18),
25+
.tvOS(.v18),
26+
.watchOS(.v11),
27+
.visionOS(.v2),
28+
],
29+
dependencies: [
30+
.package(
31+
path: "../../../../grpc-swift-protobuf"
32+
),
33+
.package(
34+
url: "https://github.com/grpc/grpc-swift.git",
35+
exact: "2.0.0-beta.2"
36+
),
37+
],
38+
targets: [
39+
.executableTarget(
40+
name: "grpc-adopter",
41+
dependencies: [
42+
.product(name: "GRPCCore", package: "grpc-swift"),
43+
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
44+
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
45+
],
46+
plugins: [
47+
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
48+
]
49+
)
50+
]
3751
)

IntegrationTests/PluginTests/test_02_peer_config_file/Sources/Protos/HelloWorld.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 gRPC authors.
1+
// Copyright 2015, gRPC Authors All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
// swift-tools-version: 6.0
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
2+
/*
3+
* Copyright 2024, gRPC Authors All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
317

418
import PackageDescription
519

620
let package = Package(
7-
name: "grpc-adopter",
8-
platforms: [
9-
.macOS(.v15),
10-
.iOS(.v18),
11-
.tvOS(.v18),
12-
.watchOS(.v11),
13-
.visionOS(.v2),
14-
],
15-
dependencies: [
16-
.package(
17-
path: "../../../../grpc-swift-protobuf"
18-
),
19-
.package(
20-
url: "https://github.com/grpc/grpc-swift.git",
21-
from: "1.28.2"
22-
)
23-
],
24-
targets: [
25-
.executableTarget(
26-
name: "grpc-adopter",
27-
dependencies: [
28-
.product(name: "GRPCCore", package: "grpc-swift"),
29-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
30-
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
31-
],
32-
plugins: [
33-
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
34-
]
35-
)
36-
]
21+
name: "grpc-adopter",
22+
platforms: [
23+
.macOS(.v15),
24+
.iOS(.v18),
25+
.tvOS(.v18),
26+
.watchOS(.v11),
27+
.visionOS(.v2),
28+
],
29+
dependencies: [
30+
.package(
31+
path: "../../../../grpc-swift-protobuf"
32+
),
33+
.package(
34+
url: "https://github.com/grpc/grpc-swift.git",
35+
exact: "2.0.0-beta.2"
36+
),
37+
],
38+
targets: [
39+
.executableTarget(
40+
name: "grpc-adopter",
41+
dependencies: [
42+
.product(name: "GRPCCore", package: "grpc-swift"),
43+
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
44+
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
45+
],
46+
plugins: [
47+
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
48+
]
49+
)
50+
]
3751
)

IntegrationTests/PluginTests/test_03_separate_service_message_protos/Sources/Protos/Messages.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 gRPC authors.
1+
// Copyright 2015, gRPC Authors All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

IntegrationTests/PluginTests/test_03_separate_service_message_protos/Sources/Protos/Service.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 gRPC authors.
1+
// Copyright 2015, gRPC Authors All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

Package.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ let products: [Product] = [
2626
name: "protoc-gen-grpc-swift",
2727
targets: ["protoc-gen-grpc-swift"]
2828
),
29+
.plugin(
30+
name: "GRPCGeneratorPlugin",
31+
targets: ["GRPCGeneratorPlugin"]
32+
),
33+
.plugin(
34+
name: "GRPCGeneratorCommand",
35+
targets: ["GRPCGeneratorCommand"]
36+
),
2937
]
3038

3139
let dependencies: [Package.Dependency] = [
@@ -101,6 +109,36 @@ let targets: [Target] = [
101109
],
102110
swiftSettings: defaultSwiftSettings
103111
),
112+
113+
// Code generator build plugin
114+
.plugin(
115+
name: "GRPCGeneratorPlugin",
116+
capability: .buildTool(),
117+
dependencies: [
118+
"protoc-gen-grpc-swift",
119+
.product(name: "protoc-gen-swift", package: "swift-protobuf"),
120+
]
121+
),
122+
123+
// // Code generator SwiftPM command
124+
.plugin(
125+
name: "GRPCGeneratorCommand",
126+
capability: .command(
127+
intent: .custom(
128+
verb: "generate-grpc-code-from-protos",
129+
description: "Generate Swift code for gRPC services from protobuf definitions."
130+
),
131+
permissions: [
132+
.writeToPackageDirectory(
133+
reason: "To write the generated Swift files back into the source directory of the package."
134+
)
135+
]
136+
),
137+
dependencies: [
138+
"protoc-gen-grpc-swift",
139+
.product(name: "protoc-gen-swift", package: "swift-protobuf"),
140+
]
141+
),
104142
]
105143

106144
let package = Package(

Plugins/GRPCGeneratorCommand/ConfigurationArguments.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ extension CommandConfiguration {
7777
case .useAccessLevelOnImports:
7878
self.common.useAccessLevelOnImports = .init(value)
7979
case .importPath:
80-
self.common.importPaths!.append(value) // ! is safe because we set it to an empty array at the top of the method
80+
// ! is safe because we set it to an empty array at the top of the method
81+
self.common.importPaths!.append(value)
8182
case .protocPath:
8283
self.common.protocPath = value
8384
case .output:
@@ -134,7 +135,7 @@ enum Flag: CaseIterable {
134135

135136
case dryRun
136137

137-
init (_ argument: String) throws {
138+
init(_ argument: String) throws {
138139
switch argument {
139140
case "--visibility":
140141
self = .visibility
@@ -179,7 +180,8 @@ extension Flag {
179180
case .message:
180181
return "--message Whether message code is generated."
181182
case .fileNaming:
182-
return "--file-naming The naming of output files with respect to the path of the source file."
183+
return
184+
"--file-naming The naming of output files with respect to the path of the source file."
183185
case .protoPathModuleMappings:
184186
return "--proto-path-module-mappings Path to module map .asciipb file."
185187
case .useAccessLevelOnImports:
@@ -191,7 +193,8 @@ extension Flag {
191193
case .dryRun:
192194
return "--dry-run Print but do not execute the protoc commands."
193195
case .output:
194-
return "--output The path into which the generated source files are created."
196+
return
197+
"--output The path into which the generated source files are created."
195198
}
196199
}
197200

0 commit comments

Comments
 (0)