aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_rules
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-04-07 15:54:22 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-04-07 17:05:31 +0000
commitffcc522498c993e8746cf8a426ff46de4378d84e (patch)
tree25a7d671e4572d2eca4f04f839904aecbd080cbf /tools/build_rules
parent17ea7e10b4689be8e32bd6c52aa12cda5e2b63ea (diff)
*** Reason for rollback *** Breaks //src/test/shell/bazel:bazel_example_test because that relies on the protobuf rules depending on @bazel_tools . The correct solution is probably to eliminate the protobuf dependencies from @bazel_tools altogether, but let's make the continuous build green and then think. *** Original change description *** Update our rudimentary proto rules to be able to handle gRPC. -- MOS_MIGRATED_REVID=119271980
Diffstat (limited to 'tools/build_rules')
-rw-r--r--tools/build_rules/genproto.bzl47
-rwxr-xr-xtools/build_rules/gensrcjar.sh10
2 files changed, 8 insertions, 49 deletions
diff --git a/tools/build_rules/genproto.bzl b/tools/build_rules/genproto.bzl
index 9ac399865d..62284a3b20 100644
--- a/tools/build_rules/genproto.bzl
+++ b/tools/build_rules/genproto.bzl
@@ -25,8 +25,6 @@ def gensrcjar_impl(ctx):
"JAR='%s'" % ctx.executable._jar.path,
"OUTPUT='%s'" % out.path,
"PROTO_COMPILER='%s'" % ctx.executable._proto_compiler.path,
- "GRPC_JAVA_PLUGIN='%s'" % ctx.executable.grpc_java_plugin.path if \
- ctx.executable.grpc_java_plugin else "",
"SOURCE='%s'" % ctx.file.src.path,
ctx.executable._gensrcjar.path,
]),
@@ -45,19 +43,14 @@ gensrcjar = rule(
allow_files = proto_filetype,
single_file = True,
),
- "grpc_java_plugin": attr.label(
- cfg = HOST_CFG,
- executable = True,
- single_file = True,
- ),
"_gensrcjar": attr.label(
- default = Label("//tools/build_rules:gensrcjar"),
+ default = Label("@bazel_tools//tools/build_rules:gensrcjar"),
executable = True,
),
# TODO(bazel-team): this should be a hidden attribute with a default
# value, but Skylark needs to support select first.
"_proto_compiler": attr.label(
- default = Label("//third_party/protobuf:protoc"),
+ default = Label("@bazel_tools//third_party/protobuf:protoc"),
allow_files = True,
executable = True,
single_file = True,
@@ -80,41 +73,13 @@ gensrcjar = rule(
outputs = {"srcjar": "lib%{name}.srcjar"},
)
-def cc_grpc_library(name, src):
- basename = src[:-len(".proto")]
-
- native.genrule(
- name = name + "_codegen",
- srcs = [src],
- tools = ["//third_party/protobuf:protoc", "//third_party/grpc:cpp_plugin"],
- cmd = "\\\n".join([
- "$(location //third_party/protobuf:protoc)",
- " --plugin=protoc-gen-grpc=$(location //third_party/grpc:cpp_plugin)",
- " --cpp_out=$(GENDIR)",
- " --grpc_out=$(GENDIR)",
- " $(location " + src + ")"]),
- outs = [basename + ".grpc.pb.h", basename + ".grpc.pb.cc", basename + ".pb.cc", basename + ".pb.h"])
-
- native.cc_library(
- name = name,
- srcs = [basename + ".grpc.pb.cc", basename + ".pb.cc"],
- hdrs = [basename + ".grpc.pb.h", basename + ".pb.h"],
- deps = ["//third_party/grpc:grpc++"],
- includes = ["."])
-
-def java_proto_library(name, src, use_grpc_plugin=False):
- grpc_java_plugin = None
- if use_grpc_plugin:
- grpc_java_plugin = "//third_party/grpc:grpc-java-plugin"
-
- gensrcjar(name=name + "_srcjar", src=src, grpc_java_plugin=grpc_java_plugin)
- deps = ["//third_party/protobuf"]
- if use_grpc_plugin:
- deps += ["//third_party/grpc:grpc-jar", "//third_party:guava"]
+# TODO(bazel-team): support proto => proto dependencies too
+def java_proto_library(name, src):
+ gensrcjar(name=name + "_srcjar", src=src)
native.java_library(
name=name,
srcs=[name + "_srcjar"],
- deps=deps,
+ deps=["@bazel_tools//third_party/protobuf"],
# The generated code has lots of 'rawtypes' warnings.
javacopts=["-Xlint:-rawtypes"],
)
diff --git a/tools/build_rules/gensrcjar.sh b/tools/build_rules/gensrcjar.sh
index c1674a3950..b94408a703 100755
--- a/tools/build_rules/gensrcjar.sh
+++ b/tools/build_rules/gensrcjar.sh
@@ -65,14 +65,8 @@ main() {
"${PREPROCESSOR}" <"${SOURCE}" >"${processed_source}" \
|| err "Preprocessor ${PREPROCESSOR} failed"
- if [ -n "${GRPC_JAVA_PLUGIN}" ]; then
- "${PROTO_COMPILER}" --plugin=protoc-gen-grpc="${GRPC_JAVA_PLUGIN}" \
- --grpc_out="${proto_output}" --java_out="${proto_output}" "${processed_source}" \
- || err "proto_compiler failed"
- else
- "${PROTO_COMPILER}" --java_out="${proto_output}" "${processed_source}" \
- || err "proto_compiler failed"
- fi
+ "${PROTO_COMPILER}" --java_out="${proto_output}" "${processed_source}" \
+ || err "proto_compiler failed"
find "${proto_output}" -exec touch -t "${TIMESTAMP}" '{}' \; \
|| err "Failed to reset timestamps"
"${JAR}" cMf "${OUTPUT}.tmp" -C "${proto_output}" . \