Fixed do <cmd> +nightly on Windows.
Implemented do build .. -Z<flag> for more easy compile time debug.
This commit is contained in:
parent
c5a7bc8d2d
commit
84f3046d92
|
@ -509,7 +509,7 @@ fn check(args: Vec<&str>) {
|
||||||
cmd("cargo", &["clippy", "--no-deps", "--tests", "--workspace", "--examples"], &args);
|
cmd("cargo", &["clippy", "--no-deps", "--tests", "--workspace", "--examples"], &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do build, b [-e, --example] [--examples] [-t, --timings] [--release-lto] [<cargo-build-args>]
|
// do build, b [-e, --example] [--examples] [-t, --timings] [--release-lto] [-Z*] [<cargo-build-args>]
|
||||||
// Compile the main crate and its dependencies.
|
// Compile the main crate and its dependencies.
|
||||||
// USAGE:
|
// USAGE:
|
||||||
// build -e <example>
|
// build -e <example>
|
||||||
|
@ -519,13 +519,31 @@ fn check(args: Vec<&str>) {
|
||||||
// build -p <crate> -t
|
// build -p <crate> -t
|
||||||
// Compile crate and report in "target/cargo-timings"
|
// Compile crate and report in "target/cargo-timings"
|
||||||
fn build(mut args: Vec<&str>) {
|
fn build(mut args: Vec<&str>) {
|
||||||
let mut cargo_args = vec![];
|
let mut nightly = if take_flag(&mut args, &["+nightly"]) { "+nightly" } else { "" };
|
||||||
|
|
||||||
cargo_args.push("build");
|
let mut rust_flags = release_rust_flags(args.contains(&"--release"));
|
||||||
|
|
||||||
let rust_flags = release_rust_flags(args.contains(&"--release"));
|
args.retain(|f| {
|
||||||
|
if f.starts_with("-Z") {
|
||||||
|
if rust_flags.0.is_empty() {
|
||||||
|
rust_flags = ("RUSTFLAGS", String::new());
|
||||||
|
}
|
||||||
|
rust_flags.1.push(' ');
|
||||||
|
rust_flags.1.push_str(f);
|
||||||
|
|
||||||
|
if nightly.is_empty() {
|
||||||
|
nightly = "+nightly";
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
});
|
||||||
let rust_flags = &[(rust_flags.0, rust_flags.1.as_str())];
|
let rust_flags = &[(rust_flags.0, rust_flags.1.as_str())];
|
||||||
|
|
||||||
|
let mut cargo_args = vec![nightly, "build"];
|
||||||
|
|
||||||
if take_flag(&mut args, &["-t", "--timings"]) {
|
if take_flag(&mut args, &["-t", "--timings"]) {
|
||||||
cargo_args.push("--timings");
|
cargo_args.push("--timings");
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,24 @@ pub fn cmd_env(cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&s
|
||||||
pub fn cmd_env_req(cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&str, &str)]) {
|
pub fn cmd_env_req(cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&str, &str)]) {
|
||||||
cmd_impl(cmd, default_args, user_args, envs, true)
|
cmd_impl(cmd, default_args, user_args, envs, true)
|
||||||
}
|
}
|
||||||
fn cmd_impl(cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&str, &str)], required: bool) {
|
fn cmd_impl(mut cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&str, &str)], required: bool) {
|
||||||
let args: Vec<_> = default_args.iter().chain(user_args.iter()).filter(|a| !a.is_empty()).collect();
|
let mut args: Vec<_> = default_args
|
||||||
|
.iter()
|
||||||
|
.chain(user_args.iter())
|
||||||
|
.filter(|a| !a.is_empty())
|
||||||
|
.map(|s| *s)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
if cfg!(windows) && cmd == "cargo" && default_args.first() == Some(&"+nightly") {
|
||||||
|
// nested cargo calls don't use rustup's cargo on Windows.
|
||||||
|
// https://github.com/rust-lang/rustup/issues/3036
|
||||||
|
//
|
||||||
|
// rustup run nightly cargo
|
||||||
|
cmd = "rustup";
|
||||||
|
args[0] = "run";
|
||||||
|
args.insert(1, "nightly");
|
||||||
|
args.insert(2, "cargo");
|
||||||
|
}
|
||||||
|
|
||||||
let mut cmd = Command::new(cmd);
|
let mut cmd = Command::new(cmd);
|
||||||
cmd.args(&args[..]);
|
cmd.args(&args[..]);
|
||||||
|
|
Loading…
Reference in New Issue