Skip to content

Commit 81880fa

Browse files
bufdevcopybara-github
authored andcommitted
Add bazel targets for standalone plugin binaries (#23919)
Follow-up to #23736 and #13308 but with only Bazel targets added per feedback. This PR adds targets to build protoc plugins for all the built-in plugins. This will result in the following binaries being available: - protoc-gen-cpp - protoc-gen-csharp - protoc-gen-java - protoc-gen-kotlin - protoc-gen-objectivec - protoc-gen-php - protoc-gen-python - protoc-gen-pyi - protoc-gen-ruby - protoc-gen-rust Closes #23919 COPYBARA_INTEGRATE_REVIEW=#23919 from bufdev:standalone-plugins 45d44f6 PiperOrigin-RevId: 917373434
1 parent 0ba20ef commit 81880fa

17 files changed

Lines changed: 176 additions & 5 deletions

File tree

โ€Žsrc/google/protobuf/compiler/cpp/BUILD.bazelโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ load("//build_defs:cpp_opts.bzl", "COPTS")
1010

1111
cc_binary(
1212
name = "protoc-gen-cpp",
13-
srcs = ["main.cc"],
14-
visibility = ["//:__pkg__"],
13+
srcs = ["plugin_main.cc"],
14+
visibility = ["//visibility:public"],
1515
deps = [
1616
":cpp",
1717
"//src/google/protobuf/compiler:plugin",
File renamed without changes.

โ€Žsrc/google/protobuf/compiler/csharp/BUILD.bazelโ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
# Protocol Buffers Compiler - C# code generator
33
################################################################################
44

5+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
56
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
67
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
78
load("//build_defs:cpp_opts.bzl", "COPTS")
89

10+
cc_binary(
11+
name = "protoc-gen-csharp",
12+
srcs = ["plugin_main.cc"],
13+
visibility = ["//visibility:public"],
14+
deps = [
15+
":csharp",
16+
"//src/google/protobuf/compiler:plugin",
17+
],
18+
)
19+
920
cc_library(
1021
name = "names",
1122
srcs = ["names.cc"],
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
8+
#include "google/protobuf/compiler/csharp/csharp_generator.h"
9+
#include "google/protobuf/compiler/plugin.h"
10+
11+
int main(int argc, char* argv[]) {
12+
google::protobuf::compiler::csharp::Generator generator;
13+
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
14+
}

โ€Žsrc/google/protobuf/compiler/java/BUILD.bazelโ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Protocol Buffers Compiler - Java code generator
33
################################################################################
44

5+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
56
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
67
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
78
load("//build_defs:cpp_opts.bzl", "COPTS")
@@ -12,6 +13,16 @@ package(
1213
],
1314
)
1415

16+
cc_binary(
17+
name = "protoc-gen-java",
18+
srcs = ["plugin_main.cc"],
19+
visibility = ["//visibility:public"],
20+
deps = [
21+
":java",
22+
"//src/google/protobuf/compiler:plugin",
23+
],
24+
)
25+
1526
cc_library(
1627
name = "names",
1728
hdrs = ["names.h"],

โ€Žsrc/google/protobuf/compiler/kotlin/BUILD.bazelโ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12
load("@rules_cc//cc:cc_library.bzl", "cc_library")
23
load("//build_defs:cpp_opts.bzl", "COPTS")
34

5+
cc_binary(
6+
name = "protoc-gen-kotlin",
7+
srcs = ["plugin_main.cc"],
8+
visibility = ["//visibility:public"],
9+
deps = [
10+
":kotlin",
11+
"//src/google/protobuf/compiler:plugin",
12+
],
13+
)
14+
415
cc_library(
516
name = "kotlin",
617
srcs = ["generator.cc"],
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
8+
#include "google/protobuf/compiler/kotlin/generator.h"
9+
#include "google/protobuf/compiler/plugin.h"
10+
11+
int main(int argc, char* argv[]) {
12+
google::protobuf::compiler::kotlin::KotlinGenerator generator;
13+
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
14+
}

โ€Žsrc/google/protobuf/compiler/objectivec/BUILD.bazelโ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
# Protocol Buffers Compiler - ObjC code generator
33
################################################################################
44

5+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
56
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
67
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
78
load("//build_defs:cpp_opts.bzl", "COPTS")
89

10+
cc_binary(
11+
name = "protoc-gen-objectivec",
12+
srcs = ["plugin_main.cc"],
13+
visibility = ["//visibility:public"],
14+
deps = [
15+
":objectivec",
16+
"//src/google/protobuf/compiler:plugin",
17+
],
18+
)
19+
920
cc_library(
1021
name = "names",
1122
hdrs = ["names.h"],
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2008 Google Inc. All rights reserved.
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
8+
#include "google/protobuf/compiler/objectivec/generator.h"
9+
#include "google/protobuf/compiler/plugin.h"
10+
11+
int main(int argc, char* argv[]) {
12+
google::protobuf::compiler::objectivec::ObjectiveCGenerator generator;
13+
return google::protobuf::compiler::PluginMain(argc, argv, &generator);
14+
}

โ€Žsrc/google/protobuf/compiler/php/BUILDโ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,22 @@
77

88
# Public targets for PHP code generator.
99

10+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
1011
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1112
load("@rules_cc//cc:defs.bzl", "cc_library")
1213
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
1314
load("//build_defs:cpp_opts.bzl", "COPTS")
1415

16+
cc_binary(
17+
name = "protoc-gen-php",
18+
srcs = ["plugin_main.cc"],
19+
visibility = ["//visibility:public"],
20+
deps = [
21+
":php_generator",
22+
"//src/google/protobuf/compiler:plugin",
23+
],
24+
)
25+
1526
cc_library(
1627
name = "names",
1728
srcs = ["names.cc"],

0 commit comments

Comments
ย (0)