Skip to content

Commit d838286

Browse files
committed
Fix config pickup behaviour so that both examples and usage-examples build
correctly
1 parent 859cd41 commit d838286

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

.cargo/config.toml

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,5 @@
22
xtask = "run --package xtask --"
33
pxtask = "run --package xtask --features rayon --"
44

5-
[target.thumbv6m-none-eabi]
6-
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
7-
8-
[target.thumbv7m-none-eabi]
9-
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
10-
11-
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
12-
rustflags = [
13-
"-C", "link-arg=-Tlink.x",
14-
]
5+
# Don't define the RUSTFLAGS link.x thing here: it messes
6+
# up compilation of the usage examples.

rtic/.cargo/config.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[target.thumbv6m-none-eabi]
2+
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
3+
4+
[target.thumbv7m-none-eabi]
5+
runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
6+
7+
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
8+
rustflags = [
9+
"-C", "link-arg=-Tlink.x",
10+
]

xtask/src/command.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ impl<'a> CargoCommand<'a> {
383383
if let Some(cargoarg) = cargoarg {
384384
args.extend_from_slice(&[cargoarg]);
385385
}
386+
386387
args.extend_from_slice(&[
387388
self.command(),
388389
"--example",
@@ -407,9 +408,15 @@ impl<'a> CargoCommand<'a> {
407408
mode,
408409
} => {
409410
let mut args = vec!["+nightly"];
411+
410412
if let Some(cargoarg) = cargoarg {
411413
args.extend_from_slice(&[cargoarg]);
412414
}
415+
416+
// We need to be in the `rtic` directory to pick up
417+
// the correct .cargo/config.toml file
418+
args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
419+
413420
args.extend_from_slice(&[
414421
self.command(),
415422
"--example",
@@ -641,6 +648,11 @@ impl<'a> CargoCommand<'a> {
641648
if let Some(cargoarg) = cargoarg {
642649
args.extend_from_slice(&[cargoarg]);
643650
}
651+
652+
// We need to be in the `rtic` directory to pick up
653+
// the correct .cargo/config.toml file
654+
args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
655+
644656
args.extend_from_slice(&[
645657
self.command(),
646658
"--example",
@@ -694,6 +706,13 @@ impl<'a> CargoCommand<'a> {
694706
_ => None,
695707
}
696708
}
709+
710+
pub fn print_stdout_intermediate(&self) -> bool {
711+
match self {
712+
Self::ExampleSize { .. } => true,
713+
_ => false,
714+
}
715+
}
697716
}
698717

699718
impl BuildMode {
@@ -737,6 +756,10 @@ pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::R
737756
let stderr = String::from_utf8(result.stderr).unwrap_or("Not displayable".into());
738757
let stdout = String::from_utf8(result.stdout).unwrap_or("Not displayable".into());
739758

759+
if command.print_stdout_intermediate() && exit_status.success() {
760+
log::info!("\n{}", stdout);
761+
}
762+
740763
Ok(RunResult {
741764
exit_status,
742765
stdout,
@@ -850,9 +873,8 @@ pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> Result
850873
.clone()
851874
.for_each(|(cmd, error)| error!("❌ Failed: {cmd}\n {}\n{error}", cmd.as_cmd_string()));
852875

853-
let ecount = errors.count();
854-
let cecount = command_errors.count();
855-
if ecount != 0 || cecount != 0 {
876+
let ecount = errors.count() + command_errors.count();
877+
if ecount != 0 {
856878
log::error!("{ecount} commands failed.");
857879
Err(())
858880
} else {

xtask/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ impl fmt::Display for TestRunError {
100100
TestRunError::CommandError(e) => {
101101
write!(
102102
f,
103-
"Command failed with exit status {}: {}",
104-
e.exit_status, e.stdout
103+
"Command failed with exit status {}: {} {}",
104+
e.exit_status, e.stdout, e.stderr
105105
)
106106
}
107107
TestRunError::PathConversionError(p) => {

0 commit comments

Comments
 (0)