Skip to content

Commit

Permalink
Add protoc v24.1 plugins (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
app-token-plugins[bot] committed Aug 21, 2023
1 parent 8730311 commit 5588ca6
Show file tree
Hide file tree
Showing 64 changed files with 573 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/protocolbuffers/cpp/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!BUILD
!cpp.cc
!Dockerfile
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/cpp/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-cpp",
srcs = ["cpp.cc"],
deps = [
"//:protoc_lib",
],
)
24 changes: 24 additions & 0 deletions plugins/protocolbuffers/cpp/v24.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20230814 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git cmake build-essential g++ unzip zip
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; fi; \
curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-${arch} \
&& chmod +x /usr/local/bin/bazel

WORKDIR /build
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v24.1/protobuf-24.1.tar.gz \
&& tar --strip-components=1 -zxf protoc.tar.gz \
&& rm protoc.tar.gz
RUN bazel build '//:protoc_lib'
COPY --link BUILD cpp.cc plugins/
RUN 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 .
USER nobody
ENTRYPOINT ["/protoc-gen-cpp"]
9 changes: 9 additions & 0 deletions plugins/protocolbuffers/cpp/v24.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: v1
name: buf.build/protocolbuffers/cpp
plugin_version: v24.1
source_url: https://github.com/protocolbuffers/protobuf
description: Base types for C++. Generates message and enum types.
output_languages:
- cpp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v24.1/LICENSE
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/cpp/v24.1/cpp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <google/protobuf/compiler/cpp/generator.h>
#include <google/protobuf/compiler/plugin.h>

int main(int argc, char *argv[]) {
google::protobuf::compiler::cpp::CppGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
4 changes: 4 additions & 0 deletions plugins/protocolbuffers/csharp/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!BUILD
!csharp.cc
!Dockerfile
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/csharp/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-csharp",
srcs = ["csharp.cc"],
deps = [
"//:protoc_lib",
],
)
24 changes: 24 additions & 0 deletions plugins/protocolbuffers/csharp/v24.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20230814 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git cmake build-essential g++ unzip zip
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; fi; \
curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-${arch} \
&& chmod +x /usr/local/bin/bazel

WORKDIR /build
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v24.1/protobuf-24.1.tar.gz \
&& tar --strip-components=1 -zxf protoc.tar.gz \
&& rm protoc.tar.gz
RUN bazel build '//:protoc_lib'
COPY --link BUILD csharp.cc plugins/
RUN bazel build '//plugins:protoc-gen-csharp.stripped'

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-csharp .
USER nobody
ENTRYPOINT ["/protoc-gen-csharp"]
9 changes: 9 additions & 0 deletions plugins/protocolbuffers/csharp/v24.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: v1
name: buf.build/protocolbuffers/csharp
plugin_version: v24.1
source_url: https://github.com/protocolbuffers/protobuf
description: Base types for C#. Generates message and enum types.
output_languages:
- csharp
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v24.1/LICENSE
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/csharp/v24.1/csharp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <google/protobuf/compiler/csharp/csharp_generator.h>
#include <google/protobuf/compiler/plugin.h>

int main(int argc, char *argv[]) {
google::protobuf::compiler::csharp::Generator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
4 changes: 4 additions & 0 deletions plugins/protocolbuffers/java/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!BUILD
!Dockerfile
!java.cc
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/java/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-java",
srcs = ["java.cc"],
deps = [
"//:protoc_lib",
],
)
24 changes: 24 additions & 0 deletions plugins/protocolbuffers/java/v24.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20230814 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git cmake build-essential g++ unzip zip
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; fi; \
curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-${arch} \
&& chmod +x /usr/local/bin/bazel

WORKDIR /build
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v24.1/protobuf-24.1.tar.gz \
&& tar --strip-components=1 -zxf protoc.tar.gz \
&& rm protoc.tar.gz
RUN bazel build '//:protoc_lib'
COPY --link BUILD java.cc plugins/
RUN bazel build '//plugins:protoc-gen-java.stripped'

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-java .
USER nobody
ENTRYPOINT ["/protoc-gen-java"]
19 changes: 19 additions & 0 deletions plugins/protocolbuffers/java/v24.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: v1
name: buf.build/protocolbuffers/java
plugin_version: v24.1
source_url: https://github.com/protocolbuffers/protobuf
description: Base types for Java. Generates message and enum types.
output_languages:
- java
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v24.1/LICENSE
registry:
maven:
deps:
- com.google.protobuf:protobuf-java:3.24.1
additional_runtimes:
- name: lite
deps:
- com.google.protobuf:protobuf-javalite:3.24.1
- build.buf:protobuf-javalite:3.24.1
opts: [lite]
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/java/v24.1/java.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <google/protobuf/compiler/java/generator.h>
#include <google/protobuf/compiler/plugin.h>

int main(int argc, char *argv[]) {
google::protobuf::compiler::java::JavaGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
5 changes: 5 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!BUILD
!Dockerfile
!escape-package-names.patch
!kotlin.cc
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-kotlin",
srcs = ["kotlin.cc"],
deps = [
"//:protoc_lib",
],
)
26 changes: 26 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20230814 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git cmake build-essential g++ unzip zip
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; fi; \
curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-${arch} \
&& chmod +x /usr/local/bin/bazel

WORKDIR /build
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v24.1/protobuf-24.1.tar.gz \
&& tar --strip-components=1 -zxf protoc.tar.gz \
&& rm protoc.tar.gz
COPY escape-package-names.patch .
RUN patch -p1 -u < escape-package-names.patch
RUN bazel build '//:protoc_lib'
COPY --link BUILD kotlin.cc plugins/
RUN bazel build '//plugins:protoc-gen-kotlin.stripped'

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-kotlin .
USER nobody
ENTRYPOINT ["/protoc-gen-kotlin"]
26 changes: 26 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: v1
name: buf.build/protocolbuffers/kotlin
plugin_version: v24.1
source_url: https://github.com/protocolbuffers/protobuf
description: Base types for Kotlin. Generates message and enum types.
deps:
- plugin: buf.build/protocolbuffers/java:v24.1
output_languages:
- kotlin
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v24.1/LICENSE
registry:
maven:
compiler:
kotlin:
version: 1.8.22
deps:
- com.google.protobuf:protobuf-kotlin:3.24.1
- org.jetbrains.kotlin:kotlin-stdlib:1.8.22
- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
additional_runtimes:
- name: lite
deps:
- com.google.protobuf:protobuf-kotlin-lite:3.24.1
- org.jetbrains.kotlin:kotlin-stdlib:1.8.22
opts: [lite]
64 changes: 64 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/escape-package-names.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/src/google/protobuf/compiler/java/message.cc b/src/google/protobuf/compiler/java/message.cc
index 3ef504526..3d46c2e43 100644
--- a/src/google/protobuf/compiler/java/message.cc
+++ b/src/google/protobuf/compiler/java/message.cc
@@ -1337,8 +1337,7 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
"message",
EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)),
"message_kt",
- EscapeKotlinKeywords(
- name_resolver_->GetKotlinExtensionsClassName(descriptor_)));
+ name_resolver_->GetKotlinExtensionsClassNameEscaped(descriptor_));

for (int i = 0; i < descriptor_->nested_type_count(); i++) {
if (IsMapEntry(descriptor_->nested_type(i))) continue;
diff --git a/src/google/protobuf/compiler/java/message_lite.cc b/src/google/protobuf/compiler/java/message_lite.cc
index b5fddc2a9..7321ed31f 100644
--- a/src/google/protobuf/compiler/java/message_lite.cc
+++ b/src/google/protobuf/compiler/java/message_lite.cc
@@ -859,8 +859,7 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
"message",
EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true)),
"message_kt",
- EscapeKotlinKeywords(
- name_resolver_->GetKotlinExtensionsClassName(descriptor_)));
+ name_resolver_->GetKotlinExtensionsClassNameEscaped(descriptor_));

for (int i = 0; i < descriptor_->nested_type_count(); i++) {
if (IsMapEntry(descriptor_->nested_type(i))) continue;
diff --git a/src/google/protobuf/compiler/java/name_resolver.cc b/src/google/protobuf/compiler/java/name_resolver.cc
index 0017e172a..b027865b1 100644
--- a/src/google/protobuf/compiler/java/name_resolver.cc
+++ b/src/google/protobuf/compiler/java/name_resolver.cc
@@ -358,6 +358,19 @@ std::string ClassNameResolver::GetKotlinExtensionsClassName(
descriptor->file(), true, true, true);
}

+std::string ClassNameResolver::GetKotlinExtensionsClassNameEscaped(
+ const Descriptor* descriptor) {
+ std::string name_without_package = ClassNameWithoutPackageKotlin(descriptor);
+ std::string full_name = GetClassFullName(name_without_package,
+ descriptor->file(), true, true, true);
+ std::string name_without_package_suffix = absl::StrCat(".", name_without_package, "Kt");
+ size_t package_end = full_name.rfind(name_without_package_suffix);
+ if (package_end != std::string::npos) {
+ return absl::StrCat("`", full_name.substr(0, package_end), "`", name_without_package_suffix);
+ }
+ return full_name;
+}
+
std::string ClassNameResolver::GetJavaMutableClassName(
const Descriptor* descriptor) {
return GetJavaClassFullName(ClassNameWithoutPackage(descriptor, false),
diff --git a/src/google/protobuf/compiler/java/name_resolver.h b/src/google/protobuf/compiler/java/name_resolver.h
index 205bdc6a4..c602c489c 100644
--- a/src/google/protobuf/compiler/java/name_resolver.h
+++ b/src/google/protobuf/compiler/java/name_resolver.h
@@ -124,6 +124,7 @@ class ClassNameResolver {
std::string GetJavaImmutableClassName(const EnumDescriptor* descriptor);
std::string GetKotlinFactoryName(const Descriptor* descriptor);
std::string GetKotlinExtensionsClassName(const Descriptor* descriptor);
+ std::string GetKotlinExtensionsClassNameEscaped(const Descriptor* descriptor);
std::string GetJavaMutableClassName(const Descriptor* descriptor);
std::string GetJavaMutableClassName(const EnumDescriptor* descriptor);
// Gets the outer class and the actual class for downgraded mutable messages.
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/kotlin/v24.1/kotlin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <google/protobuf/compiler/java/kotlin_generator.h>
#include <google/protobuf/compiler/plugin.h>

int main(int argc, char *argv[]) {
google::protobuf::compiler::java::KotlinGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
4 changes: 4 additions & 0 deletions plugins/protocolbuffers/objc/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!BUILD
!Dockerfile
!objectivec.cc
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/objc/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-objectivec",
srcs = ["objectivec.cc"],
deps = [
"//:protoc_lib",
],
)
24 changes: 24 additions & 0 deletions plugins/protocolbuffers/objc/v24.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.5
FROM debian:bullseye-20230814 AS build

ARG TARGETARCH

RUN apt-get update \
&& apt-get install -y curl git cmake build-essential g++ unzip zip
RUN arch=${TARGETARCH}; \
if [ "${arch}" = "amd64" ]; then arch="x86_64"; fi; \
curl -fsSL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazel/releases/download/6.3.2/bazel-6.3.2-linux-${arch} \
&& chmod +x /usr/local/bin/bazel

WORKDIR /build
RUN curl -fsSL -o protoc.tar.gz https://github.com/protocolbuffers/protobuf/releases/download/v24.1/protobuf-24.1.tar.gz \
&& tar --strip-components=1 -zxf protoc.tar.gz \
&& rm protoc.tar.gz
RUN bazel build '//:protoc_lib'
COPY --link BUILD objectivec.cc plugins/
RUN bazel build '//plugins:protoc-gen-objectivec.stripped'

FROM gcr.io/distroless/cc-debian11
COPY --from=build --link --chmod=0755 /build/bazel-bin/plugins/protoc-gen-objectivec .
USER nobody
ENTRYPOINT ["/protoc-gen-objectivec"]
9 changes: 9 additions & 0 deletions plugins/protocolbuffers/objc/v24.1/buf.plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: v1
name: buf.build/protocolbuffers/objc
plugin_version: v24.1
source_url: https://github.com/protocolbuffers/protobuf
description: Base types for Objective-C. Generates message and enum types.
output_languages:
- objective_c
spdx_license_id: BSD-3-Clause
license_url: https://github.com/protocolbuffers/protobuf/blob/v24.1/LICENSE
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/objc/v24.1/objectivec.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <google/protobuf/compiler/objectivec/generator.h>
#include <google/protobuf/compiler/plugin.h>

int main(int argc, char *argv[]) {
google::protobuf::compiler::objectivec::ObjectiveCGenerator generator;
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
}
4 changes: 4 additions & 0 deletions plugins/protocolbuffers/php/v24.1/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!BUILD
!Dockerfile
!php.cc
7 changes: 7 additions & 0 deletions plugins/protocolbuffers/php/v24.1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_binary(
name = "protoc-gen-php",
srcs = ["php.cc"],
deps = [
"//:protoc_lib",
],
)
Loading

0 comments on commit 5588ca6

Please sign in to comment.