aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-15 21:16:45 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-16 13:08:46 +0200
commitd838286de679a1ac35ea79999816418cd02b7259 (patch)
treec98736f11bfdac5c4c46e6299436aeed529387e5
parent859cd418f063590a9928b3e43caeea0b53dc0823 (diff)
Fix config pickup behaviour so that both examples and usage-examples build
correctly
-rw-r--r--.cargo/config.toml12
-rw-r--r--rtic/.cargo/config.toml10
-rw-r--r--xtask/src/command.rs28
-rw-r--r--xtask/src/main.rs4
4 files changed, 39 insertions, 15 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 0a62466..ea1655c 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -2,13 +2,5 @@
xtask = "run --package xtask --"
pxtask = "run --package xtask --features rayon --"
-[target.thumbv6m-none-eabi]
-runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
-
-[target.thumbv7m-none-eabi]
-runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
-
-[target.'cfg(all(target_arch = "arm", target_os = "none"))']
-rustflags = [
- "-C", "link-arg=-Tlink.x",
-]
+# Don't define the RUSTFLAGS link.x thing here: it messes
+# up compilation of the usage examples.
diff --git a/rtic/.cargo/config.toml b/rtic/.cargo/config.toml
new file mode 100644
index 0000000..ddec650
--- /dev/null
+++ b/rtic/.cargo/config.toml
@@ -0,0 +1,10 @@
+[target.thumbv6m-none-eabi]
+runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
+
+[target.thumbv7m-none-eabi]
+runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
+
+[target.'cfg(all(target_arch = "arm", target_os = "none"))']
+rustflags = [
+ "-C", "link-arg=-Tlink.x",
+]
diff --git a/xtask/src/command.rs b/xtask/src/command.rs
index a1c4d25..a45cb8a 100644
--- a/xtask/src/command.rs
+++ b/xtask/src/command.rs
@@ -383,6 +383,7 @@ impl<'a> CargoCommand<'a> {
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
+
args.extend_from_slice(&[
self.command(),
"--example",
@@ -407,9 +408,15 @@ impl<'a> CargoCommand<'a> {
mode,
} => {
let mut args = vec!["+nightly"];
+
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
+
+ // We need to be in the `rtic` directory to pick up
+ // the correct .cargo/config.toml file
+ args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
+
args.extend_from_slice(&[
self.command(),
"--example",
@@ -641,6 +648,11 @@ impl<'a> CargoCommand<'a> {
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
+
+ // We need to be in the `rtic` directory to pick up
+ // the correct .cargo/config.toml file
+ args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
+
args.extend_from_slice(&[
self.command(),
"--example",
@@ -694,6 +706,13 @@ impl<'a> CargoCommand<'a> {
_ => None,
}
}
+
+ pub fn print_stdout_intermediate(&self) -> bool {
+ match self {
+ Self::ExampleSize { .. } => true,
+ _ => false,
+ }
+ }
}
impl BuildMode {
@@ -737,6 +756,10 @@ pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::R
let stderr = String::from_utf8(result.stderr).unwrap_or("Not displayable".into());
let stdout = String::from_utf8(result.stdout).unwrap_or("Not displayable".into());
+ if command.print_stdout_intermediate() && exit_status.success() {
+ log::info!("\n{}", stdout);
+ }
+
Ok(RunResult {
exit_status,
stdout,
@@ -850,9 +873,8 @@ pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> Result
.clone()
.for_each(|(cmd, error)| error!("❌ Failed: {cmd}\n {}\n{error}", cmd.as_cmd_string()));
- let ecount = errors.count();
- let cecount = command_errors.count();
- if ecount != 0 || cecount != 0 {
+ let ecount = errors.count() + command_errors.count();
+ if ecount != 0 {
log::error!("{ecount} commands failed.");
Err(())
} else {
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 10499c0..7077d55 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -100,8 +100,8 @@ impl fmt::Display for TestRunError {
TestRunError::CommandError(e) => {
write!(
f,
- "Command failed with exit status {}: {}",
- e.exit_status, e.stdout
+ "Command failed with exit status {}: {} {}",
+ e.exit_status, e.stdout, e.stderr
)
}
TestRunError::PathConversionError(p) => {