From be74469ab71341da9a564ce1bc3e0e3f17009688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Sun, 22 Jan 2023 03:03:24 +0100 Subject: 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. --- macros/src/codegen.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'macros/src/codegen.rs') diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index 9c444fe..89173d4 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 -- cgit v1.2.3