Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/apple/swift/v1.35.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!extramoduleimports.patch
19 changes: 19 additions & 0 deletions plugins/apple/swift/v1.35.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:1.19
FROM swift:6.2.3-bookworm AS build

RUN apt-get update \
&& apt-get install -y libstdc++-12-dev unzip
COPY --link extramoduleimports.patch /app/extramoduleimports.patch
WORKDIR /app
RUN git clone --depth 1 --branch 1.35.1 https://github.com/apple/swift-protobuf --recursive
WORKDIR /app/swift-protobuf
RUN git apply /app/extramoduleimports.patch
RUN swift build -c release --static-swift-stdlib -Xlinker -s

FROM gcr.io/distroless/cc-debian12:latest@sha256:329e54034ce498f9c6b345044e8f530c6691f99e94a92446f68c0adf9baa8464 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build /app/swift-protobuf/.build/release/protoc-gen-swift .
USER nobody
ENTRYPOINT [ "/protoc-gen-swift" ]
21 changes: 21 additions & 0 deletions plugins/apple/swift/v1.35.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: v1
name: buf.build/apple/swift
plugin_version: v1.35.1
source_url: https://github.com/apple/swift-protobuf
integration_guide_url: https://github.com/apple/swift-protobuf#getting-started
description: Base types for Swift. Generates message and enum types.
output_languages:
- swift
registry:
swift:
deps:
- source: https://github.com/apple/swift-protobuf.git
package: swift-protobuf
swift_versions: [ ".v5", ".v6" ]
products: [ SwiftProtobuf ]
version: 1.35.1
opts:
- Visibility=Public
- FileNaming=PathToUnderscores
spdx_license_id: Apache-2.0
license_url: https://github.com/apple/swift-protobuf/blob/1.35.1/LICENSE.txt
63 changes: 63 additions & 0 deletions plugins/apple/swift/v1.35.1/extramoduleimports.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff --git a/Sources/protoc-gen-swift/FileGenerator.swift b/Sources/protoc-gen-swift/FileGenerator.swift
index f0cddb24..e5864211 100644
--- a/Sources/protoc-gen-swift/FileGenerator.swift
+++ b/Sources/protoc-gen-swift/FileGenerator.swift
@@ -149,6 +149,14 @@ class FileGenerator {
return
}

+ let neededCustomImports = generatorOptions.extraModuleImports
+ if !neededCustomImports.isEmpty {
+ p.print()
+ for i in neededCustomImports {
+ p.print("import \(i)\n")
+ }
+ }
+
p.print()
generateVersionCheck(printer: &p)

diff --git a/Sources/protoc-gen-swift/GeneratorOptions.swift b/Sources/protoc-gen-swift/GeneratorOptions.swift
index 3224e138..8bfc1ce5 100644
--- a/Sources/protoc-gen-swift/GeneratorOptions.swift
+++ b/Sources/protoc-gen-swift/GeneratorOptions.swift
@@ -64,6 +64,7 @@ class GeneratorOptions {
}
}

+ let extraModuleImports: [String]
let outputNaming: OutputNaming
let protoToModuleMappings: ProtoFileToModuleMappings
let visibility: Visibility
@@ -74,6 +75,7 @@ class GeneratorOptions {
let visibilitySourceSnippet: String

init(parameter: any CodeGeneratorParameter) throws {
+ var externalModuleImports: [String] = []
var outputNaming: OutputNaming = .fullPath
var moduleMapPath: String?
var visibility: Visibility = .internal
@@ -146,6 +148,15 @@ class GeneratorOptions {
value: pair.value
)
}
+ case "ExtraModuleImports":
+ if !pair.value.isEmpty {
+ externalModuleImports.append(pair.value)
+ } else {
+ throw GenerationError.invalidParameterValue(
+ name: pair.key,
+ value: pair.value
+ )
+ }
default:
throw GenerationError.unknownParameter(name: pair.key)
}
@@ -179,6 +190,7 @@ class GeneratorOptions {
visibilitySourceSnippet = "package "
}

+ self.extraModuleImports = externalModuleImports
self.experimentalStripNonfunctionalCodegen = experimentalStripNonfunctionalCodegen

switch (implementationOnlyImports, useAccessLevelOnImports) {
2 changes: 2 additions & 0 deletions plugins/grpc/swift/v1.27.3/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!Dockerfile
17 changes: 17 additions & 0 deletions plugins/grpc/swift/v1.27.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1.19
FROM swift:6.2.3-bookworm AS build

RUN apt-get update \
&& apt-get install -y libstdc++-12-dev
WORKDIR /app
RUN git clone --depth 1 --branch 1.27.3 https://github.com/grpc/grpc-swift --recursive
WORKDIR /app/grpc-swift
RUN swift build -c release --static-swift-stdlib --product protoc-gen-grpc-swift -Xlinker -s

FROM gcr.io/distroless/cc-debian12:latest@sha256:329e54034ce498f9c6b345044e8f530c6691f99e94a92446f68c0adf9baa8464 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build /app/grpc-swift/.build/release/protoc-gen-grpc-swift .
USER nobody
ENTRYPOINT [ "/protoc-gen-grpc-swift" ]
23 changes: 23 additions & 0 deletions plugins/grpc/swift/v1.27.3/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: v1
name: buf.build/grpc/swift
plugin_version: v1.27.3
source_url: https://github.com/grpc/grpc-swift
description: Generates Swift client and server stubs for the gRPC framework.
deps:
- plugin: buf.build/apple/swift:v1.35.1
output_languages:
- swift
registry:
swift:
deps:
- source: https://github.com/grpc/grpc-swift.git
package: grpc-swift
version: 1.27.3
products:
- GRPC
opts:
- Visibility=Public
- FileNaming=PathToUnderscores
spdx_license_id: Apache-2.0
license_url: https://github.com/grpc/grpc-swift/blob/1.27.3/LICENSE
integration_guide_url: https://github.com/grpc/grpc-swift#getting-grpc-swift
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/js/v4.0.2/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!Dockerfile
21 changes: 21 additions & 0 deletions plugins/protocolbuffers/js/v4.0.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1.19
FROM debian:bookworm-20260223 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; elif [ "${arch}" = "arm64" ]; then arch="aarch_64"; fi; \
curl -fsSL -o /tmp/protobuf-javascript.tar.gz https://github.com/protocolbuffers/protobuf-javascript/releases/download/v4.0.2/protobuf-javascript-4.0.2-linux-${arch}.tar.gz \
&& cd /tmp \
&& tar zxf protobuf-javascript.tar.gz bin/protoc-gen-js \
&& rm -f protobuf-javascript.tar.gz

FROM gcr.io/distroless/cc-debian12:latest@sha256:329e54034ce498f9c6b345044e8f530c6691f99e94a92446f68c0adf9baa8464 AS base

FROM scratch
COPY --from=base --link / /
COPY --from=build --link --chmod=0755 /tmp/bin/protoc-gen-js .
USER nobody
ENTRYPOINT ["/protoc-gen-js"]
18 changes: 18 additions & 0 deletions plugins/protocolbuffers/js/v4.0.2/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: v1
name: buf.build/protocolbuffers/js
plugin_version: v4.0.2
source_url: https://github.com/protocolbuffers/protobuf-javascript
description: Base types for JavaScript. Generates message and enum types.
output_languages:
- javascript
registry:
npm:
deps:
- package: 'google-protobuf'
version: ^4.0.2
import_style: commonjs
opts:
- import_style=commonjs
- binary
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf-javascript/blob/v4.0.2/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:ep7eRBaCZYegnNuYt01ISHnPmoQQfYD3cOiayRryTIU=
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:o+/kvnlzpyklvikaJbtQBh4B02JI/Nk5DJU5q12mlZw=
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:klAEUf7WFX/+TSOOUy7F75AMxFT6Xb3LNOx6aL9DYn0=
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:tVvtyf7StUea61DCqt0D6mKsji3dVZxna8snGt78kEA=
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:wQIMUPRiJej5NUylVzlJbZQuoWOEyQAVFqDMcAL1rqw=
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1:RhtraNu9zMktIcNrBU+024jXoSx9/BsG/oK3VnPLgSc=