Skip to content

Commit

Permalink
Add cmake support to protocolbuffers/cpp plugins to v25 (#1577)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
8 people authored Nov 27, 2024
1 parent 19c561a commit 00c92ec
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 22 deletions.
1 change: 1 addition & 0 deletions plugins/protocolbuffers/cpp/v25.0/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!BUILD
!cpp.cc
!disable_cpp_editions.patch
!Dockerfile
15 changes: 10 additions & 5 deletions plugins/protocolbuffers/cpp/v25.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20231030 AS build
# syntax=docker/dockerfile:1.10
FROM debian:bookworm-20241111 AS build

ARG TARGETARCH

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

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
USER nobody
ENTRYPOINT ["/protoc-gen-cpp"]
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/cpp/v25.0/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.0/LICENSE
registry:
cmake: {}
20 changes: 20 additions & 0 deletions plugins/protocolbuffers/cpp/v25.0/disable_cpp_editions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/google/protobuf/compiler/cpp/generator.h b/src/google/protobuf/compiler/cpp/generator.h
index 64f334d5b..fd6e08e84 100644
--- a/src/google/protobuf/compiler/cpp/generator.h
+++ b/src/google/protobuf/compiler/cpp/generator.h
@@ -70,14 +70,7 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
std::string* error) const override;

uint64_t GetSupportedFeatures() const override {
- return FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS;
- }
-
- Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
- Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
-
- std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
- return {GetExtensionReflection(pb::cpp)};
+ return FEATURE_PROTO3_OPTIONAL;
}

private:
1 change: 1 addition & 0 deletions plugins/protocolbuffers/cpp/v25.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!BUILD
!cpp.cc
!disable_cpp_editions.patch
!Dockerfile
15 changes: 10 additions & 5 deletions plugins/protocolbuffers/cpp/v25.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20231030 AS build
# syntax=docker/dockerfile:1.10
FROM debian:bookworm-20241111 AS build

ARG TARGETARCH

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

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
USER nobody
ENTRYPOINT ["/protoc-gen-cpp"]
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/cpp/v25.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.1/LICENSE
registry:
cmake: {}
20 changes: 20 additions & 0 deletions plugins/protocolbuffers/cpp/v25.1/disable_cpp_editions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/google/protobuf/compiler/cpp/generator.h b/src/google/protobuf/compiler/cpp/generator.h
index 64f334d5b..fd6e08e84 100644
--- a/src/google/protobuf/compiler/cpp/generator.h
+++ b/src/google/protobuf/compiler/cpp/generator.h
@@ -70,14 +70,7 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
std::string* error) const override;

uint64_t GetSupportedFeatures() const override {
- return FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS;
- }
-
- Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
- Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
-
- std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
- return {GetExtensionReflection(pb::cpp)};
+ return FEATURE_PROTO3_OPTIONAL;
}

private:
1 change: 1 addition & 0 deletions plugins/protocolbuffers/cpp/v25.2/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!BUILD
!cpp.cc
!disable_cpp_editions.patch
!Dockerfile
15 changes: 10 additions & 5 deletions plugins/protocolbuffers/cpp/v25.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5
FROM debian:bookworm-20231218 AS build
# syntax=docker/dockerfile:1.10
FROM debian:bookworm-20241111 AS build

ARG TARGETARCH

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

FROM gcr.io/distroless/cc-debian12:latest@sha256:6714977f9f02632c31377650c15d89a7efaebf43bab0f37c712c30fc01edb973
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
USER nobody
ENTRYPOINT ["/protoc-gen-cpp"]
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/cpp/v25.2/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.2/LICENSE
registry:
cmake: {}
20 changes: 20 additions & 0 deletions plugins/protocolbuffers/cpp/v25.2/disable_cpp_editions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/google/protobuf/compiler/cpp/generator.h b/src/google/protobuf/compiler/cpp/generator.h
index 64f334d5b..fd6e08e84 100644
--- a/src/google/protobuf/compiler/cpp/generator.h
+++ b/src/google/protobuf/compiler/cpp/generator.h
@@ -70,14 +70,7 @@ class PROTOC_EXPORT CppGenerator : public CodeGenerator {
std::string* error) const override;

uint64_t GetSupportedFeatures() const override {
- return FEATURE_PROTO3_OPTIONAL | FEATURE_SUPPORTS_EDITIONS;
- }
-
- Edition GetMinimumEdition() const override { return Edition::EDITION_PROTO2; }
- Edition GetMaximumEdition() const override { return Edition::EDITION_2023; }
-
- std::vector<const FieldDescriptor*> GetFeatureExtensions() const override {
- return {GetExtensionReflection(pb::cpp)};
+ return FEATURE_PROTO3_OPTIONAL;
}

private:
6 changes: 3 additions & 3 deletions plugins/protocolbuffers/cpp/v25.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.7
FROM debian:bookworm-20240211 AS build
# syntax=docker/dockerfile:1.10
FROM debian:bookworm-20241111 AS build

ARG TARGETARCH

Expand All @@ -20,7 +20,7 @@ COPY --link disable_cpp_editions.patch .
RUN git apply < disable_cpp_editions.patch \
&& bazel build '//plugins:protoc-gen-cpp.stripped'

FROM gcr.io/distroless/cc-debian12:latest@sha256:e1065a1d58800a7294f74e67c32ec4146d09d6cbe471c1fa7ed456b2d2bf06e0 AS base
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base

FROM scratch
COPY --link --from=base / /
Expand Down
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/cpp/v25.3/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v25.3/LICENSE
registry:
cmake: {}
11 changes: 7 additions & 4 deletions plugins/protocolbuffers/cpp/v26.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.5
FROM debian:bookworm-20240311 AS build
# syntax=docker/dockerfile:1.10
FROM debian:bookworm-20241111 AS build

ARG TARGETARCH

Expand All @@ -18,7 +18,10 @@ RUN bazel build '//:protoc_lib'
COPY --link BUILD cpp.cc plugins/
RUN bazel build '//plugins:protoc-gen-cpp.stripped'

FROM gcr.io/distroless/cc-debian12:latest@sha256:e6ae66a5a343d7112167f9117c4e630cfffcd80db44e44302759ec13ddd2d22b
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
FROM gcr.io/distroless/cc-debian12:latest@sha256:2fb69596e692931f909c4c69ab09e50608959eaf8898c44fa64db741a23588b0 AS base

FROM scratch
COPY --link --from=base / /
COPY --link --from=build --chmod=0755 /build/bazel-bin/plugins/protoc-gen-cpp .
USER nobody
ENTRYPOINT ["/protoc-gen-cpp"]
2 changes: 2 additions & 0 deletions plugins/protocolbuffers/cpp/v26.0/buf.plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v26.0/LICENSE
registry:
cmake: {}

0 comments on commit 00c92ec

Please sign in to comment.