Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/ariel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ fn render_board_rs(board: &Board) -> String {
pub fn render_build_rs(boards: &[Board]) -> String {
let mut build_rs = String::new();

// Not done in the krate.rs prettifier because this does not work on files that are later
// inlined.
//
// Conditional until <https://github.com/rust-lang/rust/issues/54726> is resolved.
build_rs.push_str("#![cfg_attr(rustfmt, rustfmt::skip)]\n\n");

build_rs.push_str("pub fn main() {\n");

for board in boards {
Expand Down
5 changes: 1 addition & 4 deletions src/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ impl Crate {
let formatted = prettyplease::unparse(&syntax_tree);
content.clear();
content.push_str("// @generated\n");
content.push_str("//! Generated by sbd-gen\n");
// Condition is a workaround for <https://github.com/rust-lang/rust/issues/54726>
// -- otherwise, generated code is limited to nightly.
content.push_str("#![cfg_attr(rustfmt, rustfmt::skip)]\n\n");
content.push_str("// Generated by sbd-gen\n");
content.push_str(&formatted);
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/snapshots/sbd_gen__tests__sbd_ariel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ expression: ariel
FileMap {
map: {
"Cargo.toml": "# @generated\n\n[package]\nname = \"ariel-os-boards\"\n\n[package.edition]\nworkspace = true\n\n[package.license]\nworkspace = true\n\n[package.rust-version]\nworkspace = true\n\n[dependencies.ariel-os-embassy-common]\nworkspace = true\n\n[dependencies.ariel-os-hal]\nworkspace = true\n\n[dependencies.cfg-if]\nworkspace = true\n\n[features]\nno-boards = []\n",
"build.rs": "// @generated\n//! Generated by sbd-gen\n#![cfg_attr(rustfmt, rustfmt::skip)]\n\npub fn main() {\n println!(\"cargo::rustc-check-cfg=cfg(context, values(\\\"nrf52840dk\\\"))\");\n}\n",
"build.rs": "// @generated\n// Generated by sbd-gen\n#![cfg_attr(rustfmt, rustfmt::skip)]\npub fn main() {\n println!(\"cargo::rustc-check-cfg=cfg(context, values(\\\"nrf52840dk\\\"))\");\n}\n",
"laze.yml": "# yamllint disable-file\n\nbuilders:\n- name: nrf52840dk\n parent: nrf52840\n provides:\n - has_buttons\n - has_leds\n - has_usb_device_port\n",
"src/lib.rs": "// @generated\n//! Generated by sbd-gen\n#![cfg_attr(rustfmt, rustfmt::skip)]\n\n#![no_std]\ncfg_if::cfg_if! {\n if #[cfg(context = \"nrf52840dk\")] { include!(\"nrf52840dk.rs\"); } else {}\n}\n",
"src/nrf52840dk.rs": "// @generated\n//! Generated by sbd-gen\n#![cfg_attr(rustfmt, rustfmt::skip)]\n\npub mod pins {\n use ariel_os_hal::hal::peripherals;\n ariel_os_hal::define_peripherals!(\n LedPeripherals { led0 : P0_13, led1 : P0_14, led2 : P0_15, led3 : P0_16, }\n );\n ariel_os_hal::define_peripherals!(\n ButtonPeripherals { button0 : P0_11, button1 : P0_12, button2 : P0_24, button3 :\n P0_25, }\n );\n}\n#[allow(unused_variables)]\npub fn init(peripherals: &mut ariel_os_hal::hal::OptionalPeripherals) {}\n",
"src/lib.rs": "// @generated\n// Generated by sbd-gen\n#![no_std]\ncfg_if::cfg_if! {\n if #[cfg(context = \"nrf52840dk\")] { include!(\"nrf52840dk.rs\"); } else {}\n}\n",
"src/nrf52840dk.rs": "// @generated\n// Generated by sbd-gen\npub mod pins {\n use ariel_os_hal::hal::peripherals;\n ariel_os_hal::define_peripherals!(\n LedPeripherals { led0 : P0_13, led1 : P0_14, led2 : P0_15, led3 : P0_16, }\n );\n ariel_os_hal::define_peripherals!(\n ButtonPeripherals { button0 : P0_11, button1 : P0_12, button2 : P0_24, button3 :\n P0_25, }\n );\n}\n#[allow(unused_variables)]\npub fn init(peripherals: &mut ariel_os_hal::hal::OptionalPeripherals) {}\n",
},
tagfile: Some(
".sbd-gen",
Expand Down