@ -328,7 +328,7 @@ internal_gen_well_known_protos_java = rule(
" _protoc " : attr . label (
executable = True ,
cfg = " exec " ,
default = " @com_google_protobuf //:protoc" ,
default = " //:protoc " ,
) ,
} ,
)
@ -402,8 +402,8 @@ def internal_objc_proto_library(
outs = [ ] ,
proto_deps = [ ] ,
includes = [ " . " ] ,
default_runtime = " @com_google_protobuf //:protobuf_objc" ,
protoc = " @com_google_protobuf //:protoc" ,
default_runtime = Label ( " //:protobuf_objc " ) ,
protoc = Label ( " //:protoc " ) ,
testonly = None ,
visibility = [ " //visibility:public " ] ,
* * kwargs ) :
@ -485,6 +485,15 @@ def internal_objc_proto_library(
* * kwargs
)
# When canonical labels are in use, use additional "@" prefix
_canonical_label_prefix = " @ " if str ( Label ( " //:protoc " ) ) . startswith ( " @@ " ) else " "
def _to_label ( label_str ) :
""" Converts a string to a label using the repository of the calling thread """
if type ( label_str ) == type ( Label ( " //:foo " ) ) :
return label_str
return Label ( _canonical_label_prefix + native . repository_name ( ) + " // " + native . package_name ( ) + " :foo " ) . relative ( label_str )
def internal_py_proto_library (
name ,
srcs = [ ] ,
@ -492,8 +501,8 @@ def internal_py_proto_library(
py_libs = [ ] ,
py_extra_srcs = [ ] ,
include = None ,
default_runtime = " @com_google_protobuf //:protobuf_python" ,
protoc = " @com_google_protobuf //:protoc" ,
default_runtime = Label ( " //:protobuf_python " ) ,
protoc = Label ( " //:protoc " ) ,
use_grpc_plugin = False ,
testonly = None ,
* * kargs ) :
@ -546,8 +555,12 @@ def internal_py_proto_library(
plugin_language = " grpc " ,
)
if default_runtime and not default_runtime in py_libs + deps :
py_libs = py_libs + [ default_runtime ]
if default_runtime :
# Resolve non-local labels
labels = [ _to_label ( lib ) for lib in py_libs + deps ]
if not _to_label ( default_runtime ) in labels :
py_libs = py_libs + [ default_runtime ]
py_library (
name = name ,
testonly = testonly ,
@ -580,7 +593,7 @@ def _source_proto_library(
outs = [ ] ,
lang = None ,
includes = [ " . " ] ,
protoc = " @com_google_protobuf //:protoc" ,
protoc = Label ( " //:protoc " ) ,
testonly = None ,
visibility = [ " //visibility:public " ] ,
* * kwargs ) :