From b7e4498a7136041d89541bdc7725c8c023fa5c9c Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sun, 16 Apr 2023 14:14:49 +0200 Subject: [PATCH] Also allow denying for QEMU, and fix the link-arg problem caused by overriding RUSTFLAGS --- xtask/src/cargo_command.rs | 24 ++++++++++++++++++++---- xtask/src/run.rs | 7 +++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/xtask/src/cargo_command.rs b/xtask/src/cargo_command.rs index 401bab4c41..1d5f3c5730 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 { diff --git a/xtask/src/run.rs b/xtask/src/run.rs index bf8d3b7b6e..605755116d 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -381,13 +381,15 @@ pub fn qemu_run_examples<'c>( into_iter(examples) .flat_map(|example| { let target = target.into(); + let dir = Some(PathBuf::from("./rtic")); + let cmd_build = CargoCommand::ExampleBuild { cargoarg: &None, example, target, features: features.clone(), mode: BuildMode::Release, - dir: Some(PathBuf::from("./rtic")), + dir: dir.clone(), deny_warnings: globals.deny_warnings, }; @@ -397,7 +399,7 @@ pub fn qemu_run_examples<'c>( target, features: features.clone(), mode: BuildMode::Release, - dir: Some(PathBuf::from("./rtic")), + dir, deny_warnings: globals.deny_warnings, }; @@ -441,6 +443,7 @@ pub fn build_and_check_size<'c>( mode: BuildMode::Release, arguments: arguments.clone(), dir: Some(PathBuf::from("./rtic")), + deny_warnings: globals.deny_warnings, }; [cmd_build, cmd_size]