Skip to content

Commit dc853c5

Browse files
committed
Delete //cargo/settings:incompatible_runfiles_cargo_manifest_dir
1 parent 9c70ec2 commit dc853c5

4 files changed

Lines changed: 19 additions & 48 deletions

File tree

cargo/private/cargo_build_script.bzl

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -372,28 +372,18 @@ def _cargo_build_script_impl(ctx):
372372
if not workspace_name:
373373
workspace_name = ctx.workspace_name
374374

375-
extra_args = []
376-
extra_inputs = []
377375
extra_output = []
378376

379377
# Relying on runfiles directories is unreliable when passing data to
380378
# dependent actions. Instead, an explicit directory should be created
381379
# until more reliable functionality is implemented in Bazel:
382380
# https://github.com/bazelbuild/bazel/issues/15486
383-
incompatible_runfiles_cargo_manifest_dir = ctx.attr._incompatible_runfiles_cargo_manifest_dir[BuildSettingInfo].value
384-
if not incompatible_runfiles_cargo_manifest_dir:
385-
script_data.append(ctx.attr.script[DefaultInfo].default_runfiles.files)
386-
manifest_dir = "{}.runfiles/{}/{}".format(script.path, workspace_name, ctx.label.package)
387-
else:
388-
runfiles_dir, runfiles_inputs, runfiles_args = _create_runfiles_dir(
389-
ctx = ctx,
390-
script = ctx.attr.script,
391-
retain_list = ctx.attr._cargo_manifest_dir_filename_suffixes_to_retain[BuildSettingInfo].value,
392-
)
393-
manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)
394-
extra_args.append(runfiles_args)
395-
extra_inputs.append(runfiles_inputs)
396-
extra_output = [runfiles_dir]
381+
runfiles_dir, runfiles_inputs, runfiles_args = _create_runfiles_dir(
382+
ctx = ctx,
383+
script = ctx.attr.script,
384+
retain_list = ctx.attr._cargo_manifest_dir_filename_suffixes_to_retain[BuildSettingInfo].value,
385+
)
386+
manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)
397387

398388
pkg_name = ctx.attr.pkg_name
399389
if pkg_name == "":
@@ -635,17 +625,18 @@ def _cargo_build_script_impl(ctx):
635625

636626
ctx.actions.run(
637627
executable = ctx.executable._cargo_build_script_runner,
638-
arguments = [args] + extra_args,
628+
arguments = [args, runfiles_args],
639629
outputs = [
640630
out_dir,
641631
env_out,
642632
flags_out,
643633
link_flags,
644634
link_search_paths,
645635
dep_env_out,
636+
runfiles_dir,
646637
] + extra_output,
647638
tools = tools,
648-
inputs = depset(build_script_inputs, transitive = extra_inputs),
639+
inputs = depset(build_script_inputs, transitive = [runfiles_inputs]),
649640
mnemonic = "CargoBuildScriptRun",
650641
progress_message = "Running Cargo build script {}".format(pkg_name),
651642
env = env,
@@ -805,9 +796,6 @@ cargo_build_script = rule(
805796
allow_files = True,
806797
default = Label("//cargo/private:no_cxx"),
807798
),
808-
"_incompatible_runfiles_cargo_manifest_dir": attr.label(
809-
default = Label("//cargo/settings:incompatible_runfiles_cargo_manifest_dir"),
810-
),
811799
},
812800
fragments = ["cpp"],
813801
toolchains = [

cargo/private/cargo_build_script_runner/bin.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ fn run_buildrs() -> Result<(), String> {
5151
cargo_manifest_maker,
5252
} = Args::parse();
5353

54-
if let Some(cargo_manifest_maker) = &cargo_manifest_maker {
55-
cargo_manifest_maker.create_runfiles_dir().unwrap()
56-
}
54+
cargo_manifest_maker.create_runfiles_dir().unwrap();
5755

5856
let out_dir_abs = exec_root.join(out_dir);
5957
// For some reason Google's RBE does not create the output directory, force create it.
@@ -232,11 +230,10 @@ fn run_buildrs() -> Result<(), String> {
232230
}
233231

234232
// Delete any runfiles that do not need to be propagated to down stream dependents.
235-
if let Some(cargo_manifest_maker) = cargo_manifest_maker {
236-
cargo_manifest_maker
237-
.drain_runfiles_dir(&out_dir_abs)
238-
.unwrap();
239-
}
233+
cargo_manifest_maker
234+
.drain_runfiles_dir(&out_dir_abs)
235+
.unwrap();
236+
240237
Ok(())
241238
}
242239

@@ -292,7 +289,7 @@ struct Args {
292289
stderr_path: Option<String>,
293290
rundir: String,
294291
input_dep_env_paths: Vec<String>,
295-
cargo_manifest_maker: Option<RunfilesMaker>,
292+
cargo_manifest_maker: RunfilesMaker,
296293
}
297294

298295
impl Args {
@@ -316,7 +313,8 @@ impl Args {
316313
let mut stderr_path = None;
317314
let mut rundir: Result<String, String> = Err("Argument `rundir` not provided".to_owned());
318315
let mut input_dep_env_paths = Vec::new();
319-
let mut cargo_manifest_maker = None;
316+
let mut cargo_manifest_maker: Result<RunfilesMaker, String> =
317+
Err("Argument `cargo_manifest_args` not provided".to_owned());
320318

321319
for mut arg in env::args().skip(1) {
322320
if arg.starts_with("--script=") {
@@ -344,7 +342,7 @@ impl Args {
344342
} else if arg.starts_with("--input_dep_env_path=") {
345343
input_dep_env_paths.push(arg.split_off("--input_dep_env_path=".len()));
346344
} else if arg.starts_with("--cargo_manifest_args=") {
347-
cargo_manifest_maker = Some(RunfilesMaker::from_param_file(
345+
cargo_manifest_maker = Ok(RunfilesMaker::from_param_file(
348346
&arg.split_off("--cargo_manifest_args=".len()),
349347
));
350348
}
@@ -363,7 +361,7 @@ impl Args {
363361
stderr_path,
364362
rundir: rundir.unwrap(),
365363
input_dep_env_paths,
366-
cargo_manifest_maker,
364+
cargo_manifest_maker: cargo_manifest_maker.unwrap(),
367365
}
368366
}
369367
}

cargo/settings/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ load(
44
"cargo_manifest_dir_filename_suffixes_to_retain",
55
"debug_std_streams_output_group",
66
"experimental_symlink_execroot",
7-
"incompatible_runfiles_cargo_manifest_dir",
87
"use_default_shell_env",
98
)
109

@@ -27,6 +26,4 @@ debug_std_streams_output_group()
2726

2827
experimental_symlink_execroot()
2928

30-
incompatible_runfiles_cargo_manifest_dir()
31-
3229
use_default_shell_env()

cargo/settings/settings.bzl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ def experimental_symlink_execroot():
1414
build_setting_default = False,
1515
)
1616

17-
def incompatible_runfiles_cargo_manifest_dir():
18-
"""A flag which causes `cargo_build_script` to write an explicit `CARGO_MANIFEST_DIR` \
19-
directory from an action instead of using runfiles directories which cannot be \
20-
passed to downstream actions.
21-
22-
https://github.com/bazelbuild/bazel/issues/15486
23-
"""
24-
bool_flag(
25-
name = "incompatible_runfiles_cargo_manifest_dir",
26-
build_setting_default = True,
27-
)
28-
2917
def cargo_manifest_dir_filename_suffixes_to_retain():
3018
"""A flag which determines what files are retained in `CARGO_MANIFEST_DIR` directories \
3119
that are created in `CargoBuildScriptRun` actions.

0 commit comments

Comments
 (0)