Skip to content

Commit 65a6b3b

Browse files
committedJan 20, 2024
java_grpc_library.bzl: Support runfiles for protoc and the plugin
To support runfiles, the rule has to track more than just the executable. `files_to_run` has both the runfile and executable information (as separate fields), as does `files`, (combined as depset). So using those when able is inherently "safe." `files_to_run.executable` is only the executable, so does not propagate dependency information, so we make sure to pass `files` to the rule in addition. (`files_to_run.executable` is formatted into a string, so it wouldn't carry depset information anyway.) As originally noticed in cl/597962426
1 parent 75492c8 commit 65a6b3b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎java_grpc_library.bzl

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ def _java_rpc_toolchain_impl(ctx):
1616
_JavaRpcToolchainInfo(
1717
java_toolchain = ctx.attr._java_toolchain,
1818
java_plugins = ctx.attr.java_plugins,
19-
plugin = ctx.executable.plugin,
19+
plugin = ctx.attr.plugin,
2020
plugin_arg = ctx.attr.plugin_arg,
21-
protoc = ctx.executable._protoc,
21+
protoc = ctx.attr._protoc,
2222
runtime = ctx.attr.runtime,
2323
),
2424
platform_common.ToolchainInfo(), # Magic for b/78647825
@@ -89,15 +89,15 @@ def _java_rpc_library_impl(ctx):
8989
srcjar = ctx.actions.declare_file("%s-proto-gensrc.jar" % ctx.label.name)
9090

9191
args = ctx.actions.args()
92-
args.add(toolchain.plugin, format = "--plugin=protoc-gen-rpc-plugin=%s")
92+
args.add(toolchain.plugin.files_to_run.executable, format = "--plugin=protoc-gen-rpc-plugin=%s")
9393
args.add("--rpc-plugin_out={0}:{1}".format(toolchain.plugin_arg, srcjar.path))
9494
args.add_joined("--descriptor_set_in", descriptor_set_in, join_with = ctx.configuration.host_path_separator)
9595
args.add_all(srcs, map_each = _path_ignoring_repository)
9696

9797
ctx.actions.run(
98-
inputs = depset([toolchain.plugin] + srcs, transitive = [descriptor_set_in]),
98+
inputs = depset(srcs, transitive = [descriptor_set_in, toolchain.plugin.files]),
9999
outputs = [srcjar],
100-
executable = toolchain.protoc,
100+
executable = toolchain.protoc.files_to_run,
101101
arguments = [args],
102102
use_default_shell_env = True,
103103
toolchain = None,

0 commit comments

Comments
 (0)
Please sign in to comment.