Skip to content

Commit 884a7a2

Browse files
authored
Add missing inputs to CargoBuildScriptRun action (#2918)
This was a miss from #2891
1 parent 26589a3 commit 884a7a2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cargo/private/cargo_build_script.bzl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ def _create_runfiles_dir(ctx, script, retain_list):
216216
retain_list (list): A list of strings to keep in generated runfiles directories.
217217
218218
Returns:
219-
Tuple[File, Args]: The output directory to be created and the args required to do so.
219+
Tuple[File, Depset[File], Args]:
220+
- The output directory to be created.
221+
- Runfile inputs needed by the action.
222+
- The args required to create the directory.
220223
"""
221224
runfiles_dir = ctx.actions.declare_directory("{}.cargo_runfiles".format(ctx.label.name))
222225

@@ -234,7 +237,7 @@ def _create_runfiles_dir(ctx, script, retain_list):
234237
args.add(",".join(retain_list))
235238
args.add_all(runfiles.files, map_each = _runfiles_map, allow_closure = True)
236239

237-
return runfiles_dir, args
240+
return runfiles_dir, runfiles.files, args
238241

239242
def _cargo_build_script_impl(ctx):
240243
"""The implementation for the `cargo_build_script` rule.
@@ -270,6 +273,7 @@ def _cargo_build_script_impl(ctx):
270273
workspace_name = ctx.workspace_name
271274

272275
extra_args = []
276+
extra_inputs = []
273277
extra_output = []
274278

275279
# Relying on runfiles directories is unreliable when passing data to
@@ -281,13 +285,14 @@ def _cargo_build_script_impl(ctx):
281285
script_data.append(ctx.attr.script[DefaultInfo].default_runfiles.files)
282286
manifest_dir = "{}.runfiles/{}/{}".format(script.path, workspace_name, ctx.label.package)
283287
else:
284-
runfiles_dir, runfiles_args = _create_runfiles_dir(
288+
runfiles_dir, runfiles_inputs, runfiles_args = _create_runfiles_dir(
285289
ctx = ctx,
286290
script = ctx.attr.script,
287291
retain_list = ctx.attr._cargo_manifest_dir_filename_suffixes_to_retain[BuildSettingInfo].value,
288292
)
289293
manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)
290294
extra_args.append(runfiles_args)
295+
extra_inputs.append(runfiles_inputs)
291296
extra_output = [runfiles_dir]
292297

293298
streams = struct(
@@ -473,7 +478,7 @@ def _cargo_build_script_impl(ctx):
473478
streams.stderr,
474479
] + extra_output,
475480
tools = tools,
476-
inputs = build_script_inputs,
481+
inputs = depset(build_script_inputs, transitive = extra_inputs),
477482
mnemonic = "CargoBuildScriptRun",
478483
progress_message = "Running Cargo build script {}".format(pkg_name),
479484
env = env,

0 commit comments

Comments
 (0)