pass correct args to protoc for java wellknown protos when used as an external repository
This commit is contained in:
parent
48ebb29a8e
commit
ea1886661e
2 changed files with 27 additions and 9 deletions
11
BUILD
11
BUILD
|
@ -22,6 +22,7 @@ load(
|
|||
"protobuf",
|
||||
"cc_proto_library",
|
||||
"py_proto_library",
|
||||
"internal_gen_well_known_protos_java",
|
||||
"internal_protobuf_py_tests",
|
||||
)
|
||||
|
||||
|
@ -457,16 +458,8 @@ cc_test(
|
|||
################################################################################
|
||||
# Java support
|
||||
################################################################################
|
||||
genrule(
|
||||
name = "gen_well_known_protos_java",
|
||||
internal_gen_well_known_protos_java(
|
||||
srcs = WELL_KNOWN_PROTOS,
|
||||
outs = [
|
||||
"wellknown.srcjar",
|
||||
],
|
||||
cmd = "$(location :protoc) --java_out=$(@D)/wellknown.jar" +
|
||||
" -Isrc $(SRCS) " +
|
||||
" && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar",
|
||||
tools = [":protoc"],
|
||||
)
|
||||
|
||||
java_library(
|
||||
|
|
25
protobuf.bzl
25
protobuf.bzl
|
@ -199,6 +199,31 @@ def cc_proto_library(
|
|||
includes=includes,
|
||||
**kargs)
|
||||
|
||||
|
||||
def internal_gen_well_known_protos_java(srcs):
|
||||
"""Bazel rule to generate the gen_well_known_protos_java genrule
|
||||
|
||||
Args:
|
||||
srcs: the well known protos
|
||||
"""
|
||||
root = Label("%s//protobuf_java" % (REPOSITORY_NAME)).workspace_root
|
||||
if root == "":
|
||||
include = " -Isrc "
|
||||
else:
|
||||
include = " -I%s/src " % root
|
||||
native.genrule(
|
||||
name = "gen_well_known_protos_java",
|
||||
srcs = srcs,
|
||||
outs = [
|
||||
"wellknown.srcjar",
|
||||
],
|
||||
cmd = "$(location :protoc) --java_out=$(@D)/wellknown.jar" +
|
||||
" %s $(SRCS) " % include +
|
||||
" && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar",
|
||||
tools = [":protoc"],
|
||||
)
|
||||
|
||||
|
||||
def py_proto_library(
|
||||
name,
|
||||
srcs=[],
|
||||
|
|
Loading…
Add table
Reference in a new issue