diff --git a/tools/protoc_wrapper/protoc_wrapper.py b/tools/protoc_wrapper/protoc_wrapper.py index 26f3e3d5ba4bb..8eac88409c676 100755 --- a/tools/protoc_wrapper/protoc_wrapper.py +++ b/tools/protoc_wrapper/protoc_wrapper.py @@ -96,15 +96,15 @@ def main(argv): options = parser.parse_args() proto_dir = os.path.relpath(options.proto_in_dir) - protoc_cmd = [ - os.path.realpath(options.protoc), - "--proto_path", proto_dir - ] + protoc_cmd = [os.path.realpath(options.protoc)] protos = options.protos headers = [] VerifyProtoNames(protos) + if options.py_out_dir: + protoc_cmd += ["--python_out", options.py_out_dir] + if options.cc_out_dir: cc_out_dir = options.cc_out_dir cc_options = FormatGeneratorOptions(options.cc_options) @@ -113,9 +113,6 @@ def main(argv): stripped_name = StripProtoExtension(filename) headers.append(os.path.join(cc_out_dir, stripped_name + ".pb.h")) - if options.py_out_dir: - protoc_cmd += ["--python_out", options.py_out_dir] - if options.plugin_out_dir: plugin_options = FormatGeneratorOptions(options.plugin_options) protoc_cmd += [ @@ -123,6 +120,7 @@ def main(argv): "--plugin_out", plugin_options + options.plugin_out_dir ] + protoc_cmd += ["--proto_path", proto_dir] protoc_cmd += [os.path.join(proto_dir, name) for name in protos] ret = subprocess.call(protoc_cmd) if ret != 0: