Skip to content

Commit 9eb1cf0

Browse files
committed
tweaking
1 parent a15d9bd commit 9eb1cf0

File tree

16 files changed

+216
-139
lines changed

16 files changed

+216
-139
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+
from: "1.28.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+
from: "1.28.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+
from: "1.28.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.

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

Plugins/GRPCGeneratorCommand/Plugin.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import PackagePlugin
1817
import Foundation
18+
import PackagePlugin
1919

2020
@main
2121
struct GRPCGeneratorCommandPlugin: CommandPlugin {
@@ -28,7 +28,7 @@ struct GRPCGeneratorCommandPlugin: CommandPlugin {
2828
commandConfig = try CommandConfiguration(arguments: arguments)
2929
} catch PluginError.helpRequested {
3030
Flag.printHelp()
31-
return // don't throw, the user requested this
31+
return // don't throw, the user requested this
3232
} catch {
3333
Flag.printHelp()
3434
throw error
@@ -42,18 +42,19 @@ struct GRPCGeneratorCommandPlugin: CommandPlugin {
4242
let protocGenGRPCSwiftPath = try context.tool(named: "protoc-gen-grpc-swift").url
4343
let protocGenSwiftPath = try context.tool(named: "protoc-gen-swift").url
4444

45-
let outputDirectory = config.outputPath.map{ URL(fileURLWithPath:$0) } ?? context.pluginWorkDirectoryURL
45+
let outputDirectory =
46+
config.outputPath.map { URL(fileURLWithPath: $0) } ?? context.pluginWorkDirectoryURL
4647
print("Generated files will be written to: '\(outputDirectory.formatted())'")
4748

48-
let inputFileURLs = inputFiles.map{ URL(fileURLWithPath: $0) }
49+
let inputFileURLs = inputFiles.map { URL(fileURLWithPath: $0) }
4950

5051
// MARK: proto-gen-grpc-swift
5152
if config.client != false || config.server != false {
5253
let arguments = constructProtocGenGRPCSwiftArguments(
5354
config: config,
5455
using: config.fileNaming,
5556
inputFiles: inputFileURLs,
56-
protoDirectoryPaths: inputFileURLs.map{ $0.deletingLastPathComponent() },
57+
protoDirectoryPaths: inputFileURLs.map { $0.deletingLastPathComponent() },
5758
protocGenGRPCSwiftPath: protocGenGRPCSwiftPath,
5859
outputDirectory: outputDirectory
5960
)
@@ -78,7 +79,7 @@ struct GRPCGeneratorCommandPlugin: CommandPlugin {
7879
config: config,
7980
using: config.fileNaming,
8081
inputFiles: inputFileURLs,
81-
protoDirectoryPaths: inputFileURLs.map{ $0.deletingLastPathComponent() },
82+
protoDirectoryPaths: inputFileURLs.map { $0.deletingLastPathComponent() },
8283
protocGenSwiftPath: protocGenSwiftPath,
8384
outputDirectory: outputDirectory
8485
)
@@ -113,4 +114,3 @@ func printProtocInvocation(_ executableURL: URL, _ arguments: [String]) {
113114
print(" \(lastArgument)")
114115
}
115116
}
116-

0 commit comments

Comments
 (0)