Skip to content

Commit 974c7a8

Browse files
authored
Update plugins (#1342)
1 parent f66b33a commit 974c7a8

File tree

17 files changed

+184
-0
lines changed

17 files changed

+184
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!Dockerfile
3+
!extramoduleimports.patch
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1.8
2+
FROM swift:5.10.1-bookworm AS build
3+
4+
RUN apt-get update \
5+
&& apt-get install -y libstdc++-12-dev
6+
COPY --link extramoduleimports.patch /app/extramoduleimports.patch
7+
WORKDIR /app
8+
RUN git clone --depth 1 --branch 1.27.0 https://github.com/apple/swift-protobuf --recursive
9+
WORKDIR /app/swift-protobuf
10+
RUN git apply /app/extramoduleimports.patch
11+
RUN swift build -c release --static-swift-stdlib -Xlinker -s
12+
13+
FROM gcr.io/distroless/cc-debian12:latest@sha256:3b75fdd33932d16e53a461277becf57c4f815c6cee5f6bc8f52457c095e004c8 AS base
14+
15+
FROM scratch
16+
COPY --link --from=base / /
17+
COPY --link --from=build /app/swift-protobuf/.build/release/protoc-gen-swift .
18+
USER nobody
19+
ENTRYPOINT [ "/protoc-gen-swift" ]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: v1
2+
name: buf.build/apple/swift
3+
plugin_version: v1.27.0
4+
source_url: https://github.com/apple/swift-protobuf
5+
integration_guide_url: https://github.com/apple/swift-protobuf#getting-started
6+
description: Base types for Swift. Generates message and enum types.
7+
output_languages:
8+
- swift
9+
registry:
10+
swift:
11+
deps:
12+
- source: https://github.com/apple/swift-protobuf.git
13+
package: swift-protobuf
14+
swift_versions: [ ".v5" ]
15+
products: [ SwiftProtobuf ]
16+
version: 1.27.0
17+
opts:
18+
- Visibility=Public
19+
- FileNaming=PathToUnderscores
20+
spdx_license_id: Apache-2.0
21+
license_url: https://github.com/apple/swift-protobuf/blob/1.27.0/LICENSE.txt
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
diff --git a/Sources/protoc-gen-swift/FileGenerator.swift b/Sources/protoc-gen-swift/FileGenerator.swift
2+
index ebbbdca6..0e21fa95 100644
3+
--- a/Sources/protoc-gen-swift/FileGenerator.swift
4+
+++ b/Sources/protoc-gen-swift/FileGenerator.swift
5+
@@ -113,6 +113,14 @@ class FileGenerator {
6+
p.print(neededImports)
7+
}
8+
9+
+ let neededCustomImports = generatorOptions.extraModuleImports
10+
+ if !neededCustomImports.isEmpty {
11+
+ p.print()
12+
+ for i in neededCustomImports {
13+
+ p.print("import \(i)\n")
14+
+ }
15+
+ }
16+
+
17+
p.print()
18+
generateVersionCheck(printer: &p)
19+
20+
diff --git a/Sources/protoc-gen-swift/GeneratorOptions.swift b/Sources/protoc-gen-swift/GeneratorOptions.swift
21+
index 2635cb8d..58a75681 100644
22+
--- a/Sources/protoc-gen-swift/GeneratorOptions.swift
23+
+++ b/Sources/protoc-gen-swift/GeneratorOptions.swift
24+
@@ -49,6 +49,7 @@ class GeneratorOptions {
25+
}
26+
}
27+
28+
+ let extraModuleImports: [String]
29+
let outputNaming: OutputNaming
30+
let protoToModuleMappings: ProtoFileToModuleMappings
31+
let visibility: Visibility
32+
@@ -59,6 +60,7 @@ class GeneratorOptions {
33+
let visibilitySourceSnippet: String
34+
35+
init(parameter: any CodeGeneratorParameter) throws {
36+
+ var externalModuleImports: [String] = []
37+
var outputNaming: OutputNaming = .fullPath
38+
var moduleMapPath: String?
39+
var visibility: Visibility = .internal
40+
@@ -111,6 +113,12 @@ class GeneratorOptions {
41+
throw GenerationError.invalidParameterValue(name: pair.key,
42+
value: pair.value)
43+
}
44+
+ case "ExtraModuleImports":
45+
+ if !pair.value.isEmpty {
46+
+ externalModuleImports.append(pair.value)
47+
+ } else {
48+
+ throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
49+
+ }
50+
default:
51+
throw GenerationError.unknownParameter(name: pair.key)
52+
}
53+
@@ -140,6 +148,7 @@ class GeneratorOptions {
54+
visibilitySourceSnippet = "package "
55+
}
56+
57+
+ self.extraModuleImports = externalModuleImports
58+
self.implementationOnlyImports = implementationOnlyImports
59+
self.experimentalStripNonfunctionalCodegen = experimentalStripNonfunctionalCodegen
60+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!Dockerfile
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# syntax=docker/dockerfile:1.8
2+
FROM --platform=$BUILDPLATFORM golang:1.22.5-bookworm AS build
3+
4+
ARG TARGETOS TARGETARCH
5+
ENV CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH
6+
7+
RUN --mount=type=cache,target=/go/pkg/mod \
8+
go install -ldflags="-s -w" -trimpath github.com/mercari/grpc-federation/cmd/[email protected] \
9+
&& mv /go/bin/${GOOS}_${GOARCH}/protoc-gen-grpc-federation /go/bin/protoc-gen-grpc-federation || true
10+
11+
FROM scratch
12+
COPY --from=build --link --chown=root:root /etc/passwd /etc/passwd
13+
COPY --from=build --link --chown=root:root /go/bin/protoc-gen-grpc-federation .
14+
ENV GOROOT /
15+
USER nobody
16+
ENTRYPOINT [ "/protoc-gen-grpc-federation" ]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: v1
2+
name: buf.build/community/mercari-grpc-federation
3+
plugin_version: v1.0.3
4+
source_url: https://github.com/mercari/grpc-federation
5+
integration_guide_url: https://github.com/mercari/grpc-federation/blob/main/docs/getting_started.md
6+
description: Generates a gRPC server by writing a custom option in Protocol Buffers
7+
output_languages:
8+
- go
9+
spdx_license_id: MIT
10+
license_url: https://github.com/mercari/grpc-federation/blob/v1.0.3/LICENSE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!Dockerfile
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# syntax=docker/dockerfile:1.8
2+
FROM debian:bookworm-20240701 AS build
3+
4+
RUN apt-get update \
5+
&& apt-get install -y curl
6+
WORKDIR /app
7+
RUN curl -fsSL -o /app/protoc-gen-connect-kotlin.jar https://repo1.maven.org/maven2/com/connectrpc/protoc-gen-connect-kotlin/0.7.0/protoc-gen-connect-kotlin-0.7.0.jar
8+
9+
FROM gcr.io/distroless/java17-debian12:latest@sha256:c8c2c236c63d7652b707a05b02d0259db91d5feb357e9dc53942f73c2e001088 as base
10+
11+
FROM scratch
12+
COPY --from=base --link / /
13+
COPY --from=build --link --chmod=0755 --chown=root:root /app/protoc-gen-connect-kotlin.jar .
14+
USER nobody
15+
ENTRYPOINT [ "/usr/bin/java", "-jar", "/protoc-gen-connect-kotlin.jar"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: v1
2+
name: buf.build/connectrpc/kotlin
3+
plugin_version: v0.7.0
4+
source_url: https://github.com/connectrpc/connect-kotlin
5+
integration_guide_url: https://connectrpc.com/docs/kotlin/getting-started
6+
description: Idiomatic gRPC & Connect RPCs for Kotlin.
7+
deps:
8+
- plugin: buf.build/protocolbuffers/kotlin:v27.2
9+
output_languages:
10+
- kotlin
11+
spdx_license_id: Apache-2.0
12+
license_url: https://github.com/connectrpc/connect-kotlin/blob/v0.7.0/LICENSE
13+
registry:
14+
opts:
15+
- generateCallbackMethods=true
16+
maven:
17+
compiler:
18+
kotlin:
19+
version: 1.8.22
20+
deps:
21+
- com.connectrpc:connect-kotlin:0.7.0
22+
- com.connectrpc:connect-kotlin-google-java-ext:0.7.0
23+
- com.connectrpc:connect-kotlin-okhttp:0.7.0
24+
additional_runtimes:
25+
- name: lite
26+
deps:
27+
- com.connectrpc:connect-kotlin:0.7.0
28+
- com.connectrpc:connect-kotlin-google-javalite-ext:0.7.0
29+
- com.connectrpc:connect-kotlin-okhttp:0.7.0

0 commit comments

Comments
 (0)