pass correct args to protoc for java wellknown protos when used as an external repository

pull/1278/head
Steven Parkes 9 years ago
parent 48ebb29a8e
commit ea1886661e
  1. 11
      BUILD
  2. 25
      protobuf.bzl

11
BUILD

@ -22,6 +22,7 @@ load(
"protobuf", "protobuf",
"cc_proto_library", "cc_proto_library",
"py_proto_library", "py_proto_library",
"internal_gen_well_known_protos_java",
"internal_protobuf_py_tests", "internal_protobuf_py_tests",
) )
@ -457,16 +458,8 @@ cc_test(
################################################################################ ################################################################################
# Java support # Java support
################################################################################ ################################################################################
genrule( internal_gen_well_known_protos_java(
name = "gen_well_known_protos_java",
srcs = WELL_KNOWN_PROTOS, 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( java_library(

@ -199,6 +199,31 @@ def cc_proto_library(
includes=includes, includes=includes,
**kargs) **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( def py_proto_library(
name, name,
srcs=[], srcs=[],

Loading…
Cancel
Save