| Index: tools/protoc_wrapper/protoc_wrapper.py
|
| diff --git a/tools/protoc_wrapper/protoc_wrapper.py b/tools/protoc_wrapper/protoc_wrapper.py
|
| index e6ddf95184adfc089ec8f667da46a99daba35a14..546a75dff7c50e21a8682cac82d1ace60498b9ea 100755
|
| --- a/tools/protoc_wrapper/protoc_wrapper.py
|
| +++ b/tools/protoc_wrapper/protoc_wrapper.py
|
| @@ -8,6 +8,7 @@ A simple wrapper for protoc.
|
|
|
| - Adds includes in generated headers.
|
| - Handles building with system protobuf as an option.
|
| +- Able to generate C++ target with protoc plugin.
|
| """
|
|
|
| import fnmatch
|
| @@ -101,6 +102,9 @@ def main(argv):
|
| parser.add_option('--use-system-protobuf', type=int, default=0,
|
| help='Option to use system-installed protobuf '
|
| 'instead of bundled one.')
|
| + parser.add_option('--cc-generator-plugin', default='',
|
| + help='Compile C++ target with protoc generator plugin. '
|
| + 'Expected .pb.h and .pb.cc as output.')
|
| (options, args) = parser.parse_args(sys.argv)
|
| if len(args) < 2:
|
| return 1
|
| @@ -113,10 +117,15 @@ def main(argv):
|
| proto_path = RewriteProtoFilesForSystemProtobuf(proto_path)
|
| try:
|
| # Run what is hopefully protoc.
|
| - protoc_args = args[1:]
|
| + protoc = args[1]
|
| + protoc_args = args[2:]
|
| protoc_args += ['--proto_path=%s' % proto_path,
|
| os.path.join(proto_path, options.proto_in_file)]
|
| - ret = subprocess.call(protoc_args)
|
| + if options.cc_generator_plugin != '':
|
| + args = [x.replace('--cpp_out', '--plugin_out') for x in protoc_args]
|
| + protoc_args = ['--plugin',
|
| + 'protoc-gen-plugin=' + options.cc_generator_plugin] + args
|
| + ret = subprocess.call([protoc] + protoc_args)
|
| if ret != 0:
|
| return ret
|
| finally:
|
|
|