diff options
author | 2019-05-08 14:08:09 +0200 | |
---|---|---|
committer | 2019-05-08 14:08:09 +0200 | |
commit | d4eb4d2c47c905b3634410a7fdfea84fe1e8cee0 (patch) | |
tree | a14a6c3a0b88546c66ed83ddeba5ada9def67d0d /macros/src/lib.rs | |
parent | bc024f197929be1ce7dac9e6cbf6672c3980437e (diff) | |
download | rtic-d4eb4d2c47c905b3634410a7fdfea84fe1e8cee0.tar.gz rtic-d4eb4d2c47c905b3634410a7fdfea84fe1e8cee0.tar.zst rtic-d4eb4d2c47c905b3634410a7fdfea84fe1e8cee0.zip |
write generated code to disk for easier inspection
now that the generated code is actually readable let's make it easier to access
this commit also documents how to inspect the generated code via
`rtfm-expansion.rs` and `cargo-expand`
Diffstat (limited to '')
-rw-r--r-- | macros/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 441d6b5e..736289cb 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -4,6 +4,8 @@ extern crate proc_macro; use proc_macro::TokenStream; +use std::{fs, path::Path}; + use syn::parse_macro_input; mod analyze; @@ -304,5 +306,12 @@ pub fn app(args: TokenStream, input: TokenStream) -> TokenStream { let analysis = analyze::app(&app); // Code generation - codegen::app(&input.ident, &app, &analysis).into() + let ts = codegen::app(&input.ident, &app, &analysis); + + // Try to write the expanded code to disk + if Path::new("target").exists() { + fs::write("target/rtfm-expansion.rs", ts.to_string()).ok(); + } + + ts.into() } |