• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <google/protobuf/compiler/command_line_interface.h>
16 #include <google/protobuf/compiler/python/python_generator.h>
17 
18 #include "src/compiler/python_generator.h"
19 
20 #include "grpc_tools/main.h"
21 
protoc_main(int argc,char * argv[])22 int protoc_main(int argc, char* argv[]) {
23   google::protobuf::compiler::CommandLineInterface cli;
24   cli.AllowPlugins("protoc-");
25 
26   // Proto2 Python
27   google::protobuf::compiler::python::Generator py_generator;
28   cli.RegisterGenerator("--python_out", &py_generator,
29                         "Generate Python source file.");
30 
31   // gRPC Python
32   grpc_python_generator::GeneratorConfiguration grpc_py_config;
33   grpc_python_generator::PythonGrpcGenerator grpc_py_generator(grpc_py_config);
34   cli.RegisterGenerator("--grpc_python_out", &grpc_py_generator,
35                         "Generate Python source file.");
36 
37   return cli.Run(argc, argv);
38 }
39