Skip to content

Pass arguments to x subcommands with -- #107905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_forbid.iter().for_each(|v| clippy_lint_levels.push(format!("-F{}", v)));
args.extend(clippy_lint_levels);
args.extend(builder.config.free_args.clone());
args
} else {
vec![]
builder.config.free_args.clone()
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ pub struct Config {
pub cmd: Subcommand,
pub incremental: bool,
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.
#[cfg(not(test))]
download_rustc_commit: Option<String>,
Expand Down Expand Up @@ -866,6 +870,7 @@ impl Config {
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
config.color = flags.color;
config.free_args = flags.free_args.clone().unwrap_or_default();
if let Some(value) = flags.deny_warnings {
config.deny_warnings = value;
}
Expand Down
11 changes: 11 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub struct Flags {
pub llvm_profile_generate: bool,
pub llvm_bolt_profile_generate: bool,
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)]
Expand Down Expand Up @@ -156,6 +160,12 @@ impl Default for Subcommand {

impl 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(
"\
Usage: x.py <subcommand> [options] [<paths>...]
Expand Down Expand Up @@ -706,6 +716,7 @@ Arguments:
llvm_profile_generate: matches.opt_present("llvm-profile-generate"),
llvm_bolt_profile_generate: matches.opt_present("llvm-bolt-profile-generate"),
llvm_bolt_profile_use: matches.opt_str("llvm-bolt-profile-use"),
free_args,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl Step for Miri {
// Forward arguments.
miri.arg("--").arg("--target").arg(target.rustc_target_arg());
miri.args(builder.config.cmd.args());
miri.args(&builder.config.free_args);

// miri tests need to know about the stage sysroot
miri.env("MIRI_SYSROOT", &miri_sysroot);
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
.collect();

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
// so the correct filters are passed to libtest
Expand Down