diff options
| author | Vixu <lonevixu@gmail.com> | 2023-06-08 13:44:49 +0200 |
|---|---|---|
| committer | Vixu <lonevixu@gmail.com> | 2023-06-08 14:14:36 +0200 |
| commit | a7653cc05092aa5b009172c531e4f729c678a858 (patch) | |
| tree | 3ef77dd6af020d06cc37b25faf277834f94ef093 /rtic-macros/src/codegen/init.rs | |
| parent | 599793829377a64603e93a1136360f17d3bade93 (diff) | |
allow init and idle to be externed
Diffstat (limited to 'rtic-macros/src/codegen/init.rs')
| -rw-r--r-- | rtic-macros/src/codegen/init.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/rtic-macros/src/codegen/init.rs b/rtic-macros/src/codegen/init.rs index b667ae0..f6bb43d 100644 --- a/rtic-macros/src/codegen/init.rs +++ b/rtic-macros/src/codegen/init.rs @@ -54,10 +54,12 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { .collect(); root_init.push(quote! { + #[doc = r"Shared resources"] #shared_vis struct #shared { #(#shared_resources)* } + #[doc = r"Local resources"] #local_vis struct #local { #(#local_resources)* } @@ -67,14 +69,18 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 { let user_init_return = quote! {#shared, #local}; - let user_init = quote!( - #(#attrs)* - #[inline(always)] - #[allow(non_snake_case)] - fn #name(#context: #name::Context) -> (#user_init_return) { - #(#stmts)* - } - ); + let user_init = if !init.is_extern { + Some(quote!( + #(#attrs)* + #[inline(always)] + #[allow(non_snake_case)] + fn #name(#context: #name::Context) -> (#user_init_return) { + #(#stmts)* + } + )) + } else { + None + }; let mut mod_app = None; |
