Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: tools/protoc_wrapper/protoc_wrapper.py

Issue 2082693002: Plugin support for protobuf compiler (protoc) targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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:
« third_party/protobuf/proto_library.gni ('K') | « third_party/protobuf/proto_library.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698