Pass arguments to x subcommands with --

This commit is contained in:
clubby789 2023-02-10 21:40:12 +00:00
parent 3574b1a69a
commit 8bd79fda87
5 changed files with 20 additions and 1 deletions

View File

@ -58,9 +58,10 @@ fn args(builder: &Builder<'_>) -> Vec<String> {
clippy_lint_warn.iter().for_each(|v| clippy_lint_levels.push(format!("-W{}", v))); clippy_lint_warn.iter().for_each(|v| clippy_lint_levels.push(format!("-W{}", v)));
clippy_lint_forbid.iter().for_each(|v| clippy_lint_levels.push(format!("-F{}", v))); clippy_lint_forbid.iter().for_each(|v| clippy_lint_levels.push(format!("-F{}", v)));
args.extend(clippy_lint_levels); args.extend(clippy_lint_levels);
args.extend(builder.config.free_args.clone());
args args
} else { } else {
vec![] builder.config.free_args.clone()
} }
} }

View File

@ -97,6 +97,10 @@ pub struct Config {
pub cmd: Subcommand, pub cmd: Subcommand,
pub incremental: bool, pub incremental: bool,
pub dry_run: DryRun, pub dry_run: DryRun,
/// Arguments appearing after `--` to be forwarded to tools,
/// e.g. `--fix-broken` or test arguments.
pub free_args: Vec<String>,
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should. /// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
#[cfg(not(test))] #[cfg(not(test))]
download_rustc_commit: Option<String>, download_rustc_commit: Option<String>,
@ -866,6 +870,7 @@ impl Config {
config.keep_stage = flags.keep_stage; config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std; config.keep_stage_std = flags.keep_stage_std;
config.color = flags.color; config.color = flags.color;
config.free_args = flags.free_args.clone().unwrap_or_default();
if let Some(value) = flags.deny_warnings { if let Some(value) = flags.deny_warnings {
config.deny_warnings = value; config.deny_warnings = value;
} }

View File

@ -80,6 +80,10 @@ pub struct Flags {
pub llvm_profile_generate: bool, pub llvm_profile_generate: bool,
pub llvm_bolt_profile_generate: bool, pub llvm_bolt_profile_generate: bool,
pub llvm_bolt_profile_use: Option<String>, pub llvm_bolt_profile_use: Option<String>,
/// Arguments appearing after `--` to be forwarded to tools,
/// e.g. `--fix-broken` or test arguments.
pub free_args: Option<Vec<String>>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -156,6 +160,12 @@ impl Default for Subcommand {
impl Flags { impl Flags {
pub fn parse(args: &[String]) -> Flags { pub fn parse(args: &[String]) -> Flags {
let (args, free_args) = if let Some(pos) = args.iter().position(|s| s == "--") {
let (args, free) = args.split_at(pos);
(args, Some(free[1..].to_vec()))
} else {
(args, None)
};
let mut subcommand_help = String::from( let mut subcommand_help = String::from(
"\ "\
Usage: x.py <subcommand> [options] [<paths>...] Usage: x.py <subcommand> [options] [<paths>...]
@ -706,6 +716,7 @@ Arguments:
llvm_profile_generate: matches.opt_present("llvm-profile-generate"), llvm_profile_generate: matches.opt_present("llvm-profile-generate"),
llvm_bolt_profile_generate: matches.opt_present("llvm-bolt-profile-generate"), llvm_bolt_profile_generate: matches.opt_present("llvm-bolt-profile-generate"),
llvm_bolt_profile_use: matches.opt_str("llvm-bolt-profile-use"), llvm_bolt_profile_use: matches.opt_str("llvm-bolt-profile-use"),
free_args,
} }
} }
} }

View File

@ -183,6 +183,7 @@ impl Step for Miri {
// Forward arguments. // Forward arguments.
miri.arg("--").arg("--target").arg(target.rustc_target_arg()); miri.arg("--").arg("--target").arg(target.rustc_target_arg());
miri.args(builder.config.cmd.args()); miri.args(builder.config.cmd.args());
miri.args(&builder.config.free_args);
// miri tests need to know about the stage sysroot // miri tests need to know about the stage sysroot
miri.env("MIRI_SYSROOT", &miri_sysroot); miri.env("MIRI_SYSROOT", &miri_sysroot);

View File

@ -1584,6 +1584,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
.collect(); .collect();
test_args.append(&mut builder.config.cmd.test_args()); test_args.append(&mut builder.config.cmd.test_args());
test_args.extend(builder.config.free_args.iter().map(|s| s.as_str()));
// On Windows, replace forward slashes in test-args by backslashes // On Windows, replace forward slashes in test-args by backslashes
// so the correct filters are passed to libtest // so the correct filters are passed to libtest