diff options
author | 2023-01-25 20:15:31 +0000 | |
---|---|---|
committer | 2023-01-25 20:15:31 +0000 | |
commit | a601c6e449e7222dcfe73bc2f2c41c95b99b46d7 (patch) | |
tree | d7d079786f98a0b1c9d4e698607236adc3fde6d3 /macros/src/codegen.rs | |
parent | a5e18cd5294870be824f90bdd1d586586c37a153 (diff) | |
parent | 259be7bbf9cfa0ac24c276190515e988d98770b7 (diff) | |
download | rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.gz rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.tar.zst rtic-a601c6e449e7222dcfe73bc2f2c41c95b99b46d7.zip |
Merge #691
691: Basic cfg support, kind of, for Monotonics r=korken89 a=AfoHT
- Enable at least masking out a Monotonic
- Add example cfg-ing a Monotonic, showing limitations imposed by rtic-syntax
- Update changelog
The use case detailed in linked issue seems to be covered: Fixes #664
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
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 |