Skip to content

Commit 8bd79fd

Browse files
committed
Pass arguments to x subcommands with --
1 parent 3574b1a commit 8bd79fd

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

src/bootstrap/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ fn args(builder: &Builder<'_>) -> Vec<String> {
5858
clippy_lint_warn.iter().for_each(|v| clippy_lint_levels.push(format!("-W{}", v)));
5959
clippy_lint_forbid.iter().for_each(|v| clippy_lint_levels.push(format!("-F{}", v)));
6060
args.extend(clippy_lint_levels);
61+
args.extend(builder.config.free_args.clone());
6162
args
6263
} else {
63-
vec![]
64+
builder.config.free_args.clone()
6465
}
6566
}
6667

src/bootstrap/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ pub struct Config {
9797
pub cmd: Subcommand,
9898
pub incremental: bool,
9999
pub dry_run: DryRun,
100+
/// Arguments appearing after `--` to be forwarded to tools,
101+
/// e.g. `--fix-broken` or test arguments.
102+
pub free_args: Vec<String>,
103+
100104
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
101105
#[cfg(not(test))]
102106
download_rustc_commit: Option<String>,
@@ -866,6 +870,7 @@ impl Config {
866870
config.keep_stage = flags.keep_stage;
867871
config.keep_stage_std = flags.keep_stage_std;
868872
config.color = flags.color;
873+
config.free_args = flags.free_args.clone().unwrap_or_default();
869874
if let Some(value) = flags.deny_warnings {
870875
config.deny_warnings = value;
871876
}

src/bootstrap/flags.rs

+11
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ pub struct Flags {
8080
pub llvm_profile_generate: bool,
8181
pub llvm_bolt_profile_generate: bool,
8282
pub llvm_bolt_profile_use: Option<String>,
83+
84+
/// Arguments appearing after `--` to be forwarded to tools,
85+
/// e.g. `--fix-broken` or test arguments.
86+
pub free_args: Option<Vec<String>>,
8387
}
8488

8589
#[derive(Debug)]
@@ -156,6 +160,12 @@ impl Default for Subcommand {
156160

157161
impl Flags {
158162
pub fn parse(args: &[String]) -> Flags {
163+
let (args, free_args) = if let Some(pos) = args.iter().position(|s| s == "--") {
164+
let (args, free) = args.split_at(pos);
165+
(args, Some(free[1..].to_vec()))
166+
} else {
167+
(args, None)
168+
};
159169
let mut subcommand_help = String::from(
160170
"\
161171
Usage: x.py <subcommand> [options] [<paths>...]
@@ -706,6 +716,7 @@ Arguments:
706716
llvm_profile_generate: matches.opt_present("llvm-profile-generate"),
707717
llvm_bolt_profile_generate: matches.opt_present("llvm-bolt-profile-generate"),
708718
llvm_bolt_profile_use: matches.opt_str("llvm-bolt-profile-use"),
719+
free_args,
709720
}
710721
}
711722
}

src/bootstrap/run.rs

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ impl Step for Miri {
183183
// Forward arguments.
184184
miri.arg("--").arg("--target").arg(target.rustc_target_arg());
185185
miri.args(builder.config.cmd.args());
186+
miri.args(&builder.config.free_args);
186187

187188
// miri tests need to know about the stage sysroot
188189
miri.env("MIRI_SYSROOT", &miri_sysroot);

src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15841584
.collect();
15851585

15861586
test_args.append(&mut builder.config.cmd.test_args());
1587+
test_args.extend(builder.config.free_args.iter().map(|s| s.as_str()));
15871588

15881589
// On Windows, replace forward slashes in test-args by backslashes
15891590
// so the correct filters are passed to libtest

0 commit comments

Comments
 (0)