Skip to content

Commit

Permalink
tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
rnro committed Dec 24, 2024
1 parent 7a321b8 commit c911f1a
Show file tree
Hide file tree
Showing 17 changed files with 256 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/matrices/plugin-tests.json
Original file line number Diff line number Diff line change
@@ -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":""}]}
{"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":""}]}
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
/*
* Copyright 2024, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
exact: "2.0.0-beta.2"
),
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 gRPC authors.
// Copyright 2015, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
76 changes: 45 additions & 31 deletions IntegrationTests/PluginTests/test_02_peer_config_file/Package.swift
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
/*
* Copyright 2024, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
exact: "2.0.0-beta.2"
),
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 gRPC authors.
// Copyright 2015, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
/*
* Copyright 2024, gRPC Authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import PackageDescription

let package = Package(
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
from: "1.28.2"
)
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
name: "grpc-adopter",
platforms: [
.macOS(.v15),
.iOS(.v18),
.tvOS(.v18),
.watchOS(.v11),
.visionOS(.v2),
],
dependencies: [
.package(
path: "../../../../grpc-swift-protobuf"
),
.package(
url: "https://github.com/grpc/grpc-swift.git",
exact: "2.0.0-beta.2"
),
],
targets: [
.executableTarget(
name: "grpc-adopter",
dependencies: [
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
],
plugins: [
.plugin(name: "GRPCGeneratorPlugin", package: "grpc-swift-protobuf")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 gRPC authors.
// Copyright 2015, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 gRPC authors.
// Copyright 2015, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
38 changes: 38 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ let products: [Product] = [
name: "protoc-gen-grpc-swift",
targets: ["protoc-gen-grpc-swift"]
),
.plugin(
name: "GRPCGeneratorPlugin",
targets: ["GRPCGeneratorPlugin"]
),
.plugin(
name: "GRPCGeneratorCommand",
targets: ["GRPCGeneratorCommand"]
),
]

let dependencies: [Package.Dependency] = [
Expand Down Expand Up @@ -101,6 +109,36 @@ let targets: [Target] = [
],
swiftSettings: defaultSwiftSettings
),

// Code generator build plugin
.plugin(
name: "GRPCGeneratorPlugin",
capability: .buildTool(),
dependencies: [
"protoc-gen-grpc-swift",
.product(name: "protoc-gen-swift", package: "swift-protobuf"),
]
),

// // Code generator SwiftPM command
.plugin(
name: "GRPCGeneratorCommand",
capability: .command(
intent: .custom(
verb: "generate-grpc-code-from-protos",
description: "Generate Swift code for gRPC services from protobuf definitions."
),
permissions: [
.writeToPackageDirectory(
reason: "To write the generated Swift files back into the source directory of the package."
)
]
),
dependencies: [
"protoc-gen-grpc-swift",
.product(name: "protoc-gen-swift", package: "swift-protobuf"),
]
),
]

let package = Package(
Expand Down
11 changes: 7 additions & 4 deletions Plugins/GRPCGeneratorCommand/ConfigurationArguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ extension CommandConfiguration {
case .useAccessLevelOnImports:
self.common.useAccessLevelOnImports = .init(value)
case .importPath:
self.common.importPaths!.append(value) // ! is safe because we set it to an empty array at the top of the method
// ! is safe because we set it to an empty array at the top of the method
self.common.importPaths!.append(value)
case .protocPath:
self.common.protocPath = value
case .output:
Expand Down Expand Up @@ -134,7 +135,7 @@ enum Flag: CaseIterable {

case dryRun

init (_ argument: String) throws {
init(_ argument: String) throws {
switch argument {
case "--visibility":
self = .visibility
Expand Down Expand Up @@ -179,7 +180,8 @@ extension Flag {
case .message:
return "--message Whether message code is generated."
case .fileNaming:
return "--file-naming The naming of output files with respect to the path of the source file."
return
"--file-naming The naming of output files with respect to the path of the source file."
case .protoPathModuleMappings:
return "--proto-path-module-mappings Path to module map .asciipb file."
case .useAccessLevelOnImports:
Expand All @@ -191,7 +193,8 @@ extension Flag {
case .dryRun:
return "--dry-run Print but do not execute the protoc commands."
case .output:
return "--output The path into which the generated source files are created."
return
"--output The path into which the generated source files are created."
}
}

Expand Down
Loading

0 comments on commit c911f1a

Please sign in to comment.