diff --git a/BUILD b/BUILD index 95d8f753e39..b5d7761a9a1 100644 --- a/BUILD +++ b/BUILD @@ -30,7 +30,6 @@ load( "//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_generate_one_off_targets", - "grpc_proto_plugin", ) config_setting( @@ -429,92 +428,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "grpc_plugin_support", - srcs = [ - "src/compiler/cpp_generator.cc", - "src/compiler/csharp_generator.cc", - "src/compiler/node_generator.cc", - "src/compiler/objective_c_generator.cc", - "src/compiler/php_generator.cc", - "src/compiler/python_generator.cc", - "src/compiler/ruby_generator.cc", - ], - hdrs = [ - "src/compiler/config.h", - "src/compiler/cpp_generator.h", - "src/compiler/cpp_generator_helpers.h", - "src/compiler/cpp_plugin.h", - "src/compiler/csharp_generator.h", - "src/compiler/csharp_generator_helpers.h", - "src/compiler/generator_helpers.h", - "src/compiler/node_generator.h", - "src/compiler/node_generator_helpers.h", - "src/compiler/objective_c_generator.h", - "src/compiler/objective_c_generator_helpers.h", - "src/compiler/php_generator.h", - "src/compiler/php_generator_helpers.h", - "src/compiler/protobuf_plugin.h", - "src/compiler/python_generator.h", - "src/compiler/python_generator_helpers.h", - "src/compiler/python_private_generator.h", - "src/compiler/ruby_generator.h", - "src/compiler/ruby_generator_helpers-inl.h", - "src/compiler/ruby_generator_map-inl.h", - "src/compiler/ruby_generator_string-inl.h", - "src/compiler/schema_interface.h", - ], - external_deps = [ - "protobuf_clib", - ], - language = "c++", - deps = [ - "grpc++_config_proto", - ], -) - -grpc_proto_plugin( - name = "grpc_cpp_plugin", - srcs = ["src/compiler/cpp_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_csharp_plugin", - srcs = ["src/compiler/csharp_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_node_plugin", - srcs = ["src/compiler/node_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_objective_c_plugin", - srcs = ["src/compiler/objective_c_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_php_plugin", - srcs = ["src/compiler/php_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_python_plugin", - srcs = ["src/compiler/python_plugin.cc"], - deps = [":grpc_plugin_support"], -) - -grpc_proto_plugin( - name = "grpc_ruby_plugin", - srcs = ["src/compiler/ruby_plugin.cc"], - deps = [":grpc_plugin_support"], -) - grpc_cc_library( name = "grpc_csharp_ext", srcs = [ diff --git a/BUILD.gn b/BUILD.gn index 0868b2dae5a..177f4082adf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1413,6 +1413,7 @@ config("grpc_config") { "include/grpc++/impl/codegen/config_protobuf.h", "include/grpcpp/impl/codegen/config_protobuf.h", "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.cc", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl index 572af756176..dea493eaf20 100644 --- a/bazel/cc_grpc_library.bzl +++ b/bazel/cc_grpc_library.bzl @@ -88,7 +88,7 @@ def cc_grpc_library( generate_cc( name = codegen_grpc_target, srcs = proto_targets, - plugin = "@com_github_grpc_grpc//:grpc_cpp_plugin", + plugin = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", well_known_protos = well_known_protos, generate_mocks = generate_mocks, **kwargs diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index be58c52b2b9..49def4f82c1 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -78,7 +78,7 @@ def grpc_deps(): native.bind( name = "grpc_cpp_plugin", - actual = "@com_github_grpc_grpc//:grpc_cpp_plugin", + actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin", ) native.bind( diff --git a/bazel/python_rules.bzl b/bazel/python_rules.bzl index d4ff77094cc..14550852a4a 100644 --- a/bazel/python_rules.bzl +++ b/bazel/python_rules.bzl @@ -163,7 +163,7 @@ def py_proto_library( _generate_py( name = codegen_grpc_target, deps = deps, - plugin = "//:grpc_python_plugin", + plugin = "//src/compiler:grpc_python_plugin", well_known_protos = well_known_protos, **kwargs ) diff --git a/build.yaml b/build.yaml index 4134ecd8880..5915b9ccd64 100644 --- a/build.yaml +++ b/build.yaml @@ -1969,6 +1969,7 @@ libs: language: c++ headers: - src/compiler/config.h + - src/compiler/config_protobuf.h - src/compiler/cpp_generator.h - src/compiler/cpp_generator_helpers.h - src/compiler/csharp_generator.h diff --git a/src/compiler/BUILD b/src/compiler/BUILD new file mode 100644 index 00000000000..9a38f942939 --- /dev/null +++ b/src/compiler/BUILD @@ -0,0 +1,120 @@ +# gRPC Bazel BUILD file. +# +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +licenses(["notice"]) # Apache v2 + +exports_files(["LICENSE"]) + +package( + default_visibility = ["//visibility:public"], + features = [ + "-layering_check", + "-parse_headers", + ], +) + +load( + "//bazel:grpc_build_system.bzl", + "grpc_cc_library", + "grpc_proto_plugin", +) + +grpc_cc_library( + name = "grpc_plugin_support", + srcs = [ + "cpp_generator.cc", + "csharp_generator.cc", + "node_generator.cc", + "objective_c_generator.cc", + "php_generator.cc", + "python_generator.cc", + "ruby_generator.cc", + ], + hdrs = [ + "config_protobuf.h", + "config.h", + "cpp_generator.h", + "cpp_generator_helpers.h", + "cpp_plugin.h", + "csharp_generator.h", + "csharp_generator_helpers.h", + "generator_helpers.h", + "node_generator.h", + "node_generator_helpers.h", + "objective_c_generator.h", + "objective_c_generator_helpers.h", + "php_generator.h", + "php_generator_helpers.h", + "protobuf_plugin.h", + "python_generator.h", + "python_generator_helpers.h", + "python_private_generator.h", + "ruby_generator.h", + "ruby_generator_helpers-inl.h", + "ruby_generator_map-inl.h", + "ruby_generator_string-inl.h", + "schema_interface.h", + ], + external_deps = [ + "protobuf_clib", + ], + language = "c++", + deps = [ + "//:grpc++_config_proto", + ], +) + +grpc_proto_plugin( + name = "grpc_cpp_plugin", + srcs = ["cpp_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_csharp_plugin", + srcs = ["csharp_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_node_plugin", + srcs = ["node_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_objective_c_plugin", + srcs = ["objective_c_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_php_plugin", + srcs = ["php_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_python_plugin", + srcs = ["python_plugin.cc"], + deps = [":grpc_plugin_support"], +) + +grpc_proto_plugin( + name = "grpc_ruby_plugin", + srcs = ["ruby_plugin.cc"], + deps = [":grpc_plugin_support"], +) diff --git a/src/compiler/config.h b/src/compiler/config.h index cfdc3036247..60772f2be68 100644 --- a/src/compiler/config.h +++ b/src/compiler/config.h @@ -19,35 +19,7 @@ #ifndef SRC_COMPILER_CONFIG_H #define SRC_COMPILER_CONFIG_H -#include - -#ifndef GRPC_CUSTOM_CODEGENERATOR -#include -#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator -#define GRPC_CUSTOM_GENERATORCONTEXT \ - ::google::protobuf::compiler::GeneratorContext -#endif - -#ifndef GRPC_CUSTOM_PRINTER -#include -#include -#include -#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer -#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream -#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ - ::google::protobuf::io::StringOutputStream -#endif - -#ifndef GRPC_CUSTOM_PLUGINMAIN -#include -#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain -#endif - -#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER -#include -#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ - ::google::protobuf::compiler::ParseGeneratorParameter -#endif +#include "src/compiler/config_protobuf.h" #ifndef GRPC_CUSTOM_STRING #include diff --git a/src/compiler/config_protobuf.h b/src/compiler/config_protobuf.h new file mode 100644 index 00000000000..06d5073f433 --- /dev/null +++ b/src/compiler/config_protobuf.h @@ -0,0 +1,52 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef SRC_COMPILER_CONFIG_PROTOBUF_H +#define SRC_COMPILER_CONFIG_PROTOBUF_H + +#include + +#ifndef GRPC_CUSTOM_CODEGENERATOR +#include +#define GRPC_CUSTOM_CODEGENERATOR ::google::protobuf::compiler::CodeGenerator +#define GRPC_CUSTOM_GENERATORCONTEXT \ + ::google::protobuf::compiler::GeneratorContext +#endif + +#ifndef GRPC_CUSTOM_PRINTER +#include +#include +#include +#define GRPC_CUSTOM_PRINTER ::google::protobuf::io::Printer +#define GRPC_CUSTOM_CODEDOUTPUTSTREAM ::google::protobuf::io::CodedOutputStream +#define GRPC_CUSTOM_STRINGOUTPUTSTREAM \ + ::google::protobuf::io::StringOutputStream +#endif + +#ifndef GRPC_CUSTOM_PLUGINMAIN +#include +#define GRPC_CUSTOM_PLUGINMAIN ::google::protobuf::compiler::PluginMain +#endif + +#ifndef GRPC_CUSTOM_PARSEGENERATORPARAMETER +#include +#define GRPC_CUSTOM_PARSEGENERATORPARAMETER \ + ::google::protobuf::compiler::ParseGeneratorParameter +#endif + +#endif // SRC_COMPILER_CONFIG_PROTOBUF_H diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0f560fd1063..7a1baae36cd 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7184,6 +7184,7 @@ ], "headers": [ "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h", "src/compiler/csharp_generator.h", @@ -7210,6 +7211,7 @@ "name": "grpc_plugin_support", "src": [ "src/compiler/config.h", + "src/compiler/config_protobuf.h", "src/compiler/cpp_generator.cc", "src/compiler/cpp_generator.h", "src/compiler/cpp_generator_helpers.h",