Skip to content

Commit 4dfe978

Browse files
committed
spi-api: don't silently hide config errors
This build script was throwing away any failure to parse global config, which means that e.g. misspelling "DIV256" would instead get you unrelated compile errors in apparently unrelated crates, since code generation would just switch off. This appears to have been done because the lpc55 code was depending on this crate, and it of course doesn't _have_ an stm32h7 global SPI config stanza in its config TOML. I broke that dependency in an earlier commit, so now I'm making the code generation mandatory with error reporting.
1 parent 8a0f3fa commit 4dfe978

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drv/spi-api/build.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@ fn main() -> Result<()> {
1717
let dest_path = out_dir.join("spi_devices.rs");
1818
let mut file = File::create(dest_path)?;
1919

20-
if let Ok(global_config) = build_util::config::<SpiGlobalConfig>() {
21-
writeln!(&mut file, "pub mod devices {{")?;
22-
for (periph, p) in global_config.spi {
23-
writeln!(
24-
&mut file,
25-
" // {periph} ({} devices)",
26-
p.devices.len()
27-
)?;
28-
for (i, name) in p.devices.keys().enumerate() {
29-
let name = name.to_uppercase();
30-
writeln!(&mut file, " pub const {name}: u8 = {i};")?;
31-
}
20+
let global_config = build_util::config::<SpiGlobalConfig>()?;
21+
22+
writeln!(&mut file, "pub mod devices {{")?;
23+
for (periph, p) in global_config.spi {
24+
writeln!(&mut file, " // {periph} ({} devices)", p.devices.len())?;
25+
for (i, name) in p.devices.keys().enumerate() {
26+
let name = name.to_uppercase();
27+
writeln!(&mut file, " pub const {name}: u8 = {i};")?;
3228
}
33-
writeln!(&mut file, "}}")?;
3429
}
30+
writeln!(&mut file, "}}")?;
3531

3632
Ok(())
3733
}

0 commit comments

Comments
 (0)