From 87ab5af1a5ecbe9b742e6664762db75eb856945e Mon Sep 17 00:00:00 2001 From: James Munns Date: Thu, 6 Dec 2018 12:49:20 +0100 Subject: [PATCH 1/2] Extract just the consistent output of generated code --- ci/script.sh | 26 ++++++++++++++++++-------- src/main.rs | 10 ++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index 8629a1c4..9f38e51e 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -430,20 +430,30 @@ main() { # https://raw.githubusercontent.com/riscv-rust/e310x/master/e310x.svd ) - target/$TARGET/release/svd2rust --target msp430 -i $td/msp430g2553.svd | \ - ( rustfmt 2>/dev/null > $td/src/lib.rs || true ) + local cwd=$(pwd) - cargo check --manifest-path $td/Cargo.toml + # Test MSP430 + pushd $td + + $cwd/target/$TARGET/release/svd2rust --target msp430 -i $td/msp430g2553.svd + mv $td/lib.rs $td/src/lib.rs + rustfmt $td/src/lib.rs || true - target/$TARGET/release/svd2rust --target none -i $td/msp430g2553.svd | \ - ( rustfmt 2>/dev/null > $td/src/lib.rs || true ) + popd cargo check --manifest-path $td/Cargo.toml - # target/$TARGET/release/svd2rust --target riscv -i $td/e310x.svd | \ - # ( rustfmt 2>/dev/null > $td/src/lib.rs || true ) + # Test RISC-V - cargo check --manifest-path $td/Cargo.toml + # pushd $td + + # target/$TARGET/release/svd2rust --target riscv -i $td/e310x.svd + # mv $td/lib.rs $td/src/lib.rs + # rustfmt $td/src/lib.rs || true + + # popd + + # cargo check --manifest-path $td/Cargo.toml ;; Nordic) diff --git a/src/main.rs b/src/main.rs index 0b0211c8..67978b5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,17 +103,11 @@ fn run() -> Result<()> { let mut device_x = String::new(); let items = generate::device::render(&device, &target, nightly, &mut device_x)?; + writeln!(File::create("lib.rs").unwrap(), "{}", quote!(#(#tokens)*)).unwrap(); + if target == Target::CortexM { - writeln!(File::create("lib.rs").unwrap(), "{}", quote!(#(#items)*)).unwrap(); writeln!(File::create("device.x").unwrap(), "{}", device_x).unwrap(); writeln!(File::create("build.rs").unwrap(), "{}", build_rs()).unwrap(); - } else { - println!( - "{}", - quote! { - #(#items)* - } - ); } Ok(()) From f0d42a2cf0a2ec01b6470bfe326cb27e504cc27c Mon Sep 17 00:00:00 2001 From: James Munns Date: Thu, 6 Dec 2018 13:18:52 +0100 Subject: [PATCH 2/2] Revert change from `tokens` to `items` --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 67978b5e..52560702 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,7 +103,7 @@ fn run() -> Result<()> { let mut device_x = String::new(); let items = generate::device::render(&device, &target, nightly, &mut device_x)?; - writeln!(File::create("lib.rs").unwrap(), "{}", quote!(#(#tokens)*)).unwrap(); + writeln!(File::create("lib.rs").unwrap(), "{}", quote!(#(#items)*)).unwrap(); if target == Target::CortexM { writeln!(File::create("device.x").unwrap(), "{}", device_x).unwrap();