mirror of https://github.com/grpc/grpc-java.git
java_grpc_library: Swap to descriptor_set_in to protoc
This avoids re-parsing the proto files and allows proto_library to enforce more checks. This is an export of cl/197343148
This commit is contained in:
parent
71967622d6
commit
a284cff892
|
|
@ -64,9 +64,6 @@ def _path_ignoring_repository(f):
|
||||||
return f.short_path
|
return f.short_path
|
||||||
return f.path[f.path.find(f.owner.workspace_root) + len(f.owner.workspace_root) + 1:]
|
return f.path[f.path.find(f.owner.workspace_root) + len(f.owner.workspace_root) + 1:]
|
||||||
|
|
||||||
def _create_include_path(include):
|
|
||||||
return "-I{0}={1}".format(_path_ignoring_repository(include), include.path)
|
|
||||||
|
|
||||||
def _java_rpc_library_impl(ctx):
|
def _java_rpc_library_impl(ctx):
|
||||||
if len(ctx.attr.srcs) != 1:
|
if len(ctx.attr.srcs) != 1:
|
||||||
fail("Exactly one src value supported", "srcs")
|
fail("Exactly one src value supported", "srcs")
|
||||||
|
|
@ -76,18 +73,18 @@ def _java_rpc_library_impl(ctx):
|
||||||
|
|
||||||
toolchain = ctx.attr._toolchain[_JavaRpcToolchainInfo]
|
toolchain = ctx.attr._toolchain[_JavaRpcToolchainInfo]
|
||||||
srcs = ctx.attr.srcs[0][ProtoInfo].direct_sources
|
srcs = ctx.attr.srcs[0][ProtoInfo].direct_sources
|
||||||
includes = ctx.attr.srcs[0][ProtoInfo].transitive_imports
|
descriptor_set_in = ctx.attr.srcs[0][ProtoInfo].transitive_descriptor_sets
|
||||||
|
|
||||||
srcjar = ctx.actions.declare_file("%s-proto-gensrc.jar" % ctx.label.name)
|
srcjar = ctx.actions.declare_file("%s-proto-gensrc.jar" % ctx.label.name)
|
||||||
|
|
||||||
args = ctx.actions.args()
|
args = ctx.actions.args()
|
||||||
args.add(toolchain.plugin, format = "--plugin=protoc-gen-rpc-plugin=%s")
|
args.add(toolchain.plugin, format = "--plugin=protoc-gen-rpc-plugin=%s")
|
||||||
args.add("--rpc-plugin_out={0}:{1}".format(toolchain.plugin_arg, srcjar.path))
|
args.add("--rpc-plugin_out={0}:{1}".format(toolchain.plugin_arg, srcjar.path))
|
||||||
args.add_all(includes, map_each = _create_include_path)
|
args.add_joined("--descriptor_set_in", descriptor_set_in, join_with = ":")
|
||||||
args.add_all(srcs, map_each = _path_ignoring_repository)
|
args.add_all(srcs, map_each = _path_ignoring_repository)
|
||||||
|
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
inputs = depset([toolchain.plugin] + srcs, transitive = [includes]),
|
inputs = depset([toolchain.plugin] + srcs, transitive = [descriptor_set_in]),
|
||||||
outputs = [srcjar],
|
outputs = [srcjar],
|
||||||
executable = toolchain.protoc,
|
executable = toolchain.protoc,
|
||||||
arguments = [args],
|
arguments = [args],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue