Merge branch 'master' of https://github.com/grpc/grpc into fixbazel
diff --git a/bazel/generate_cc.bzl b/bazel/generate_cc.bzl
index f8fddeb..d05509f 100644
--- a/bazel/generate_cc.bzl
+++ b/bazel/generate_cc.bzl
@@ -14,6 +14,8 @@
if ctx.executable.plugin:
outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.h" for proto in protos]
outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.cc" for proto in protos]
+ if ctx.attr.generate_mock:
+ outs += [proto.path[label_len:-len(".proto")] + "_mock.grpc.pb.h" for proto in protos]
else:
outs += [proto.path[label_len:-len(".proto")] + ".pb.h" for proto in protos]
outs += [proto.path[label_len:-len(".proto")] + ".pb.cc" for proto in protos]
@@ -23,7 +25,10 @@
arguments = []
if ctx.executable.plugin:
arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path]
- arguments += ["--PLUGIN_out=" + ",".join(ctx.attr.flags) + ":" + dir_out]
+ flags = list(ctx.attr.flags)
+ if ctx.attr.generate_mock:
+ flags.append("generate_mock_code=true")
+ arguments += ["--PLUGIN_out=" + ",".join(flags) + ":" + dir_out]
additional_input = [ctx.executable.plugin]
else:
arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out]
@@ -35,10 +40,10 @@
well_known_proto_files = []
if ctx.attr.well_known_protos:
f = ctx.attr.well_known_protos.files.to_list()[0].dirname
- if f != "external/submodule_protobuf/src/google/protobuf":
- print("Error: Only @submodule_protobuf//:well_known_protos is supported")
+ if f != "external/com_google_protobuf/src/google/protobuf":
+ print("Error: Only @com_google_protobuf//:well_known_protos is supported")
else:
- # f points to "external/submodule_protobuf/src/google/protobuf"
+ # f points to "external/com_google_protobuf/src/google/protobuf"
# add -I argument to protoc so it knows where to look for the proto files.
arguments += ["-I{0}".format(f + "/../..")]
well_known_proto_files = [f for f in ctx.attr.well_known_protos.files]
@@ -71,6 +76,10 @@
"well_known_protos" : attr.label(
mandatory = False,
),
+ "generate_mock" : attr.bool(
+ default = False,
+ mandatory = False,
+ ),
"_protoc": attr.label(
default = Label("//external:protocol_compiler"),
executable = True,