Skip to content

Commit 00c92ec

Browse files
smaye81dependabot[bot]app-token-plugins[bot]mfridmansaquibmian
authored
Add cmake support to protocolbuffers/cpp plugins to v25 (#1577)
Also squash layers --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: app-token-plugins[bot] <116026991+app-token-plugins[bot]@users.noreply.github.com> Co-authored-by: mfridman <[email protected]> Co-authored-by: Saquib Mian <[email protected]> Co-authored-by: Philip K. Warren <[email protected]> Co-authored-by: Michael Fridman <[email protected]> Co-authored-by: Philip K. Warren <[email protected]>
1 parent 19c561a commit 00c92ec

File tree

16 files changed

+113
-22
lines changed

16 files changed

+113
-22
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*
22
!BUILD
33
!cpp.cc
4+
!disable_cpp_editions.patch
45
!Dockerfile

plugins/protocolbuffers/cpp/v25.0/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# syntax=docker/dockerfile:1.5
2-
FROM debian:bullseye-20231030 AS build
1+
# syntax=docker/dockerfile:1.10
2+
FROM debian:bookworm-20241111 AS build
33

44
ARG TARGETARCH
55

@@ -16,9 +16,14 @@ RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/rele
1616
&& rm protoc.tar.gz
1717
RUN bazel build '//:protoc_lib'
1818
COPY --link BUILD cpp.cc plugins/
19-
RUN bazel build '//plugins:protoc-gen-cpp.stripped'
19+
COPY --link disable_cpp_editions.patch .
20+
RUN git apply < disable_cpp_editions.patch \
21+
&& bazel build '//plugins:protoc-gen-cpp.stripped'
2022

21-
FROM gcr.io/distroless/cc-debian11
22-
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
23+
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base
24+
25+
FROM scratch
26+
COPY --link --from=base / /
27+
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
2328
USER nobody
2429
ENTRYPOINT ["/protoc-gen-cpp"]

plugins/protocolbuffers/cpp/v25.0/buf.plugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ output_languages:
77
- cpp
88
spdx_license_id: BSD-3-Clause
99
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.0/LICENSE
10+
registry:
11+
cmake: {}
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*
22
!BUILD
33
!cpp.cc
4+
!disable_cpp_editions.patch
45
!Dockerfile

plugins/protocolbuffers/cpp/v25.1/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# syntax=docker/dockerfile:1.5
2-
FROM debian:bullseye-20231030 AS build
1+
# syntax=docker/dockerfile:1.10
2+
FROM debian:bookworm-20241111 AS build
33

44
ARG TARGETARCH
55

@@ -16,9 +16,14 @@ RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/rele
1616
&& rm protoc.tar.gz
1717
RUN bazel build '//:protoc_lib'
1818
COPY --link BUILD cpp.cc plugins/
19-
RUN bazel build '//plugins:protoc-gen-cpp.stripped'
19+
COPY --link disable_cpp_editions.patch .
20+
RUN git apply < disable_cpp_editions.patch \
21+
&& bazel build '//plugins:protoc-gen-cpp.stripped'
2022

21-
FROM gcr.io/distroless/cc-debian11
22-
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
23+
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base
24+
25+
FROM scratch
26+
COPY --link --from=base / /
27+
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
2328
USER nobody
2429
ENTRYPOINT ["/protoc-gen-cpp"]

plugins/protocolbuffers/cpp/v25.1/buf.plugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ output_languages:
77
- cpp
88
spdx_license_id: BSD-3-Clause
99
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.1/LICENSE
10+
registry:
11+
cmake: {}
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*
22
!BUILD
33
!cpp.cc
4+
!disable_cpp_editions.patch
45
!Dockerfile

plugins/protocolbuffers/cpp/v25.2/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# syntax=docker/dockerfile:1.5
2-
FROM debian:bookworm-20231218 AS build
1+
# syntax=docker/dockerfile:1.10
2+
FROM debian:bookworm-20241111 AS build
33

44
ARG TARGETARCH
55

@@ -16,9 +16,14 @@ RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/rele
1616
&& rm protoc.tar.gz
1717
RUN bazel build '//:protoc_lib'
1818
COPY --link BUILD cpp.cc plugins/
19-
RUN bazel build '//plugins:protoc-gen-cpp.stripped'
19+
COPY --link disable_cpp_editions.patch .
20+
RUN git apply < disable_cpp_editions.patch \
21+
&& bazel build '//plugins:protoc-gen-cpp.stripped'
2022

21-
FROM gcr.io/distroless/cc-debian12:latest@sha256:6714977f9f02632c31377650c15d89a7efaebf43bab0f37c712c30fc01edb973
22-
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
23+
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base
24+
25+
FROM scratch
26+
COPY --link --from=base / /
27+
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
2328
USER nobody
2429
ENTRYPOINT ["/protoc-gen-cpp"]

0 commit comments

Comments
 (0)