From b7e4498a7136041d89541bdc7725c8c023fa5c9c Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sun, 16 Apr 2023 14:14:49 +0200 Subject: Also allow denying for QEMU, and fix the link-arg problem caused by overriding RUSTFLAGS --- xtask/src/cargo_command.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'xtask/src/cargo_command.rs') diff --git a/xtask/src/cargo_command.rs b/xtask/src/cargo_command.rs index 401bab4..1d5f3c5 100644 --- a/xtask/src/cargo_command.rs +++ b/xtask/src/cargo_command.rs @@ -100,6 +100,7 @@ pub enum CargoCommand<'a> { mode: BuildMode, arguments: Option, dir: Option, + deny_warnings: bool, }, } @@ -345,8 +346,10 @@ impl core::fmt::Display for CargoCommand<'_> { mode, arguments: _, dir, + deny_warnings, } => { - let details = details(false, target, Some(mode), features, cargoarg, dir.as_ref()); + let warns = *deny_warnings; + let details = details(warns, target, Some(mode), features, cargoarg, dir.as_ref()); write!(f, "Compute size of example {example} {details}") } } @@ -645,6 +648,8 @@ impl<'a> CargoCommand<'a> { target: _, // dir is exposed through `chdir` dir: _, + // deny_warnings is exposed through `extra_env` + deny_warnings: _, } => { let extra = ["--example", example] .into_iter() @@ -688,12 +693,23 @@ impl<'a> CargoCommand<'a> { // through an argument to rustc. CargoCommand::Clippy { .. } => None, CargoCommand::Doc { .. } => Some(("RUSTDOCFLAGS", "-D warnings")), + + CargoCommand::Qemu { deny_warnings, .. } + | CargoCommand::ExampleBuild { deny_warnings, .. } + | CargoCommand::ExampleSize { deny_warnings, .. } => { + if *deny_warnings { + // NOTE: this also needs the link-arg because .cargo/config.toml + // is ignored if you set the RUSTFLAGS env variable. + Some(("RUSTFLAGS", "-D warnings -C link-arg=-Tlink.x")) + } else { + None + } + } + CargoCommand::Check { deny_warnings, .. } | CargoCommand::ExampleCheck { deny_warnings, .. } | CargoCommand::Build { deny_warnings, .. } - | CargoCommand::ExampleBuild { deny_warnings, .. } - | CargoCommand::Test { deny_warnings, .. } - | CargoCommand::Qemu { deny_warnings, .. } => { + | CargoCommand::Test { deny_warnings, .. } => { if *deny_warnings { Some(("RUSTFLAGS", "-D warnings")) } else { -- cgit v1.2.3