mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-28 12:59:34 +01:00
Generate mod instead of const, handle import of idle and init
This commit is contained in:
parent
148ad4045e
commit
c718413cb5
1 changed files with 16 additions and 3 deletions
|
@ -26,6 +26,7 @@ mod util;
|
|||
// TODO document the syntax here or in `rtic-syntax`
|
||||
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||
let mut const_app = vec![];
|
||||
let mut const_app_imports = vec![];
|
||||
let mut mains = vec![];
|
||||
let mut root = vec![];
|
||||
let mut user = vec![];
|
||||
|
@ -41,6 +42,17 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
|
||||
let (const_app_idle, root_idle, user_idle, call_idle) = idle::codegen(app, analysis, extra);
|
||||
|
||||
if user_init.is_some() {
|
||||
const_app_imports.push(quote!(
|
||||
use super::init;
|
||||
))
|
||||
}
|
||||
if user_idle.is_some() {
|
||||
const_app_imports.push(quote!(
|
||||
use super::idle;
|
||||
))
|
||||
}
|
||||
|
||||
user.push(quote!(
|
||||
#user_init
|
||||
|
||||
|
@ -111,10 +123,11 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
#(#root_software_tasks)*
|
||||
|
||||
/// Implementation details
|
||||
// The user can't access the items within this `const` item
|
||||
const #name: () = {
|
||||
// the user can't access the items within this `const` item
|
||||
mod #name {
|
||||
/// Always include the device crate which contains the vector table
|
||||
use #device as _;
|
||||
#(#const_app_imports)*
|
||||
|
||||
#(#const_app)*
|
||||
|
||||
|
@ -133,6 +146,6 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
|||
#(#const_app_schedule)*
|
||||
|
||||
#(#mains)*
|
||||
};
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue