Skip to content

Commit

Permalink
Add missing inputs to CargoBuildScriptRun action (#2918)
Browse files Browse the repository at this point in the history
This was a miss from #2891
  • Loading branch information
UebelAndre authored Oct 5, 2024
1 parent 26589a3 commit 884a7a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cargo/private/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def _create_runfiles_dir(ctx, script, retain_list):
retain_list (list): A list of strings to keep in generated runfiles directories.
Returns:
Tuple[File, Args]: The output directory to be created and the args required to do so.
Tuple[File, Depset[File], Args]:
- The output directory to be created.
- Runfile inputs needed by the action.
- The args required to create the directory.
"""
runfiles_dir = ctx.actions.declare_directory("{}.cargo_runfiles".format(ctx.label.name))

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

return runfiles_dir, args
return runfiles_dir, runfiles.files, args

def _cargo_build_script_impl(ctx):
"""The implementation for the `cargo_build_script` rule.
Expand Down Expand Up @@ -270,6 +273,7 @@ def _cargo_build_script_impl(ctx):
workspace_name = ctx.workspace_name

extra_args = []
extra_inputs = []
extra_output = []

# Relying on runfiles directories is unreliable when passing data to
Expand All @@ -281,13 +285,14 @@ def _cargo_build_script_impl(ctx):
script_data.append(ctx.attr.script[DefaultInfo].default_runfiles.files)
manifest_dir = "{}.runfiles/{}/{}".format(script.path, workspace_name, ctx.label.package)
else:
runfiles_dir, runfiles_args = _create_runfiles_dir(
runfiles_dir, runfiles_inputs, runfiles_args = _create_runfiles_dir(
ctx = ctx,
script = ctx.attr.script,
retain_list = ctx.attr._cargo_manifest_dir_filename_suffixes_to_retain[BuildSettingInfo].value,
)
manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)
extra_args.append(runfiles_args)
extra_inputs.append(runfiles_inputs)
extra_output = [runfiles_dir]

streams = struct(
Expand Down Expand Up @@ -473,7 +478,7 @@ def _cargo_build_script_impl(ctx):
streams.stderr,
] + extra_output,
tools = tools,
inputs = build_script_inputs,
inputs = depset(build_script_inputs, transitive = extra_inputs),
mnemonic = "CargoBuildScriptRun",
progress_message = "Running Cargo build script {}".format(pkg_name),
env = env,
Expand Down

0 comments on commit 884a7a2

Please sign in to comment.