mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +01:00
Merge #189
189: write generated code to disk for easier inspection r=japaric a=japaric 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` Co-authored-by: Jorge Aparicio <jorge@japaric.io>
This commit is contained in:
commit
6acb156482
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