mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
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`
This commit is contained in:
parent
bc024f1979
commit
d4eb4d2c47
2 changed files with 74 additions and 1 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue