Skip to content

Commit 5545cc3

Browse files
authored
Add protoc v25.6 plugins (#1747)
The protobuf 26.x release broke compatibility for C++, Java, Kotlin, PHP, Python, and Ruby. Most users have upgraded by now, however it may take some time for Java/Kotlin libraries and ecosystem to be updated to support the latest protobuf-java runtime. Backfill v25.6 which is the latest release on the 25.x line. This also includes a security fix for the Java runtime in GHSA-735f-pc8j-v9w8. Fixes #1746.
1 parent 72d1b8e commit 5545cc3

File tree

66 files changed

+658
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+658
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!BUILD
3+
!cpp.cc
4+
!disable_cpp_editions.patch
5+
!Dockerfile
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cc_binary(
2+
name = "protoc-gen-cpp",
3+
srcs = ["cpp.cc"],
4+
deps = [
5+
"//:protoc_lib",
6+
],
7+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# syntax=docker/dockerfile:1.12
2+
FROM debian:bookworm-20250224 AS build
3+
4+
ENV USE_BAZEL_VERSION=7.4.1
5+
ARG TARGETARCH
6+
ARG BAZEL_OPTS="--host_jvm_args=-Djava.net.preferIPv4Stack=true"
7+
8+
RUN apt-get update \
9+
&& apt-get install -y curl git cmake build-essential autoconf clang libc++-dev libtool pkg-config unzip zip
10+
RUN curl -fsSL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-${TARGETARCH} \
11+
&& chmod +x /usr/local/bin/bazelisk \
12+
&& mkdir /build \
13+
&& chown nobody:nogroup /build \
14+
&& usermod --home /build nobody
15+
16+
USER nobody
17+
WORKDIR /build
18+
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v25.6/protobuf-25.6.tar.gz \
19+
&& tar --strip-components=1 -zxf protoc.tar.gz \
20+
&& rm protoc.tar.gz
21+
RUN bazelisk ${BAZEL_OPTS} build '//:protoc_lib'
22+
COPY --link BUILD cpp.cc plugins/
23+
COPY --link disable_cpp_editions.patch .
24+
RUN git apply < disable_cpp_editions.patch \
25+
&& bazelisk ${BAZEL_OPTS} build '//plugins:protoc-gen-cpp.stripped'
26+
27+
FROM gcr.io/distroless/cc-debian12:latest@sha256:b7550f0b15838de14c564337eef2b804ba593ae55d81ca855421bd52f19bb480 AS base
28+
29+
FROM scratch
30+
COPY --from=base --link / /
31+
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
32+
USER nobody
33+
ENTRYPOINT ["/protoc-gen-cpp"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: v1
2+
name: buf.build/protocolbuffers/cpp
3+
plugin_version: v25.6
4+
source_url: https://github.com/protocolbuffers/protobuf
5+
description: Base types for C++. Generates message and enum types.
6+
output_languages:
7+
- cpp
8+
spdx_license_id: BSD-3-Clause
9+
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.6/LICENSE
10+
registry:
11+
cmake: {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <google/protobuf/compiler/cpp/generator.h>
2+
#include <google/protobuf/compiler/plugin.h>
3+
4+
int main(int argc, char *argv[]) {
5+
google::protobuf::compiler::cpp::CppGenerator generator;
6+
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/src/google/protobuf/compiler/cpp/generator.h b/src/google/protobuf/compiler/cpp/generator.h
2+
index 64f334d5b..fd6e08e84 100644
3+
--- a/src/google/protobuf/compiler/cpp/generator.h
4+
+++ b/src/google/protobuf/compiler/cpp/generator.h
5+
@@ -70,14 +70,7 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
6+
std::string* error) const override;
7+
8+
uint64_t GetSupportedFeatures() const override {
9+
- return FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS;
10+
- }
11+
-
12+
- Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
13+
- Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
14+
-
15+
- std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
16+
- return {GetExtensionReflection(pb::cpp)};
17+
+ return FEATURE_PROTO3_OPTIONAL;
18+
}
19+
20+
private:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!BUILD
3+
!csharp.cc
4+
!Dockerfile
5+
!build.csproj
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cc_binary(
2+
name = "protoc-gen-csharp",
3+
srcs = ["csharp.cc"],
4+
deps = [
5+
"//:protoc_lib",
6+
],
7+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# syntax=docker/dockerfile:1.12
2+
FROM debian:bookworm-20250224 AS build
3+
4+
ENV USE_BAZEL_VERSION=7.4.1
5+
ARG TARGETARCH
6+
ARG BAZEL_OPTS="--host_jvm_args=-Djava.net.preferIPv4Stack=true"
7+
8+
RUN apt-get update \
9+
&& apt-get install -y curl git cmake build-essential autoconf clang libc++-dev libtool pkg-config unzip zip
10+
RUN curl -fsSL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-${TARGETARCH} \
11+
&& chmod +x /usr/local/bin/bazelisk \
12+
&& mkdir /build \
13+
&& chown nobody:nogroup /build \
14+
&& usermod --home /build nobody
15+
16+
USER nobody
17+
WORKDIR /build
18+
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v25.6/protobuf-25.6.tar.gz \
19+
&& tar --strip-components=1 -zxf protoc.tar.gz \
20+
&& rm protoc.tar.gz
21+
RUN bazelisk ${BAZEL_OPTS} build '//:protoc_lib'
22+
COPY --link BUILD csharp.cc plugins/
23+
RUN bazelisk ${BAZEL_OPTS} build '//plugins:protoc-gen-csharp.stripped'
24+
25+
FROM mcr.microsoft.com/dotnet/sdk:8.0.406-bookworm-slim@sha256:483d6f3faa583c93d522c4ca9ee54e08e535cb112dceb252b2fbb7ef94839cc8 AS dotnetrestore
26+
WORKDIR /build
27+
COPY --link ./build.csproj /build/build.csproj
28+
RUN mkdir /nuget && dotnet restore --packages /nuget
29+
30+
FROM gcr.io/distroless/cc-debian12:latest@sha256:b7550f0b15838de14c564337eef2b804ba593ae55d81ca855421bd52f19bb480 AS base
31+
32+
FROM scratch
33+
COPY --from=base --link / /
34+
COPY --link --from=dotnetrestore /nuget /nuget
35+
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-csharp .
36+
USER nobody
37+
ENTRYPOINT ["/protoc-gen-csharp"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: v1
2+
name: buf.build/protocolbuffers/csharp
3+
plugin_version: v25.6
4+
source_url: https://github.com/protocolbuffers/protobuf
5+
description: Base types for C#. Generates message and enum types.
6+
output_languages:
7+
- csharp
8+
spdx_license_id: BSD-3-Clause
9+
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.6/LICENSE
10+
registry:
11+
opts:
12+
- base_namespace=
13+
nuget:
14+
target_frameworks:
15+
- netstandard2.0
16+
deps:
17+
- name: Google.Protobuf
18+
version: 3.25.6

0 commit comments

Comments
 (0)