diff options
author | 2023-01-22 03:03:24 +0100 | |
---|---|---|
committer | 2023-01-22 12:00:08 +0100 | |
commit | be74469ab71341da9a564ce1bc3e0e3f17009688 (patch) | |
tree | f4a8c431fb449c394ef80cb171002ba6e58913e8 /macros/src/codegen.rs | |
parent | 3240fb332a7b1b17333ac1c589b303909bde1dc9 (diff) | |
download | rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.gz rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.tar.zst rtic-be74469ab71341da9a564ce1bc3e0e3f17009688.zip |
Enable at least masking out a Monotonic
Simplest case working, but leaves a lot to ask
as shown by examples/cfg-monotonic.rs
Current `rtic-syntax` is unable to validate and
handle the `cfgs[]` which limits the usefulness
of this.
Diffstat (limited to 'macros/src/codegen.rs')
-rw-r--r-- | macros/src/codegen.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 9c444fed..89173d45 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -108,6 +108,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { .map(|(_, monotonic)| { let name = &monotonic.ident; let name_str = &name.to_string(); + let cfgs = &monotonic.cfgs; let ident = util::monotonic_ident(name_str); let doc = &format!( "This module holds the static implementation for `{}::now()`", @@ -115,7 +116,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { ); let default_monotonic = if monotonic.args.default { - quote!(pub use #name::now;) + quote!( + #(#cfgs)* + pub use #name::now; + ) } else { quote!() }; @@ -125,6 +129,7 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 { #[doc = #doc] #[allow(non_snake_case)] + #(#cfgs)* pub mod #name { /// Read the current time from this monotonic |