Compose the use-statements, reduce debug-printouts

This commit is contained in:
Henrik Tjäder 2020-05-26 10:55:13 +00:00
parent 9fd052b876
commit 0c7a619432

View file

@ -30,17 +30,18 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
let mut mains = vec![]; let mut mains = vec![];
let mut root = vec![]; let mut root = vec![];
let mut user = vec![]; let mut user = vec![];
let mut imports = vec![];
// Generate the `main` function // Generate the `main` function
let assertion_stmts = assertions::codegen(analysis); let assertion_stmts = assertions::codegen(analysis);
let pre_init_stmts = pre_init::codegen(&app, analysis, extra); let pre_init_stmts = pre_init::codegen(&app, analysis, extra);
let (const_app_init, root_init, user_init, call_init) = init::codegen(app, analysis, extra); let (const_app_init, root_init, user_init, user_init_imports, call_init) = init::codegen(app, analysis, extra);
let post_init_stmts = post_init::codegen(&app, analysis); let post_init_stmts = post_init::codegen(&app, analysis);
let (const_app_idle, root_idle, user_idle, call_idle) = idle::codegen(app, analysis, extra); let (const_app_idle, root_idle, user_idle, user_idle_imports, call_idle) = idle::codegen(app, analysis, extra);
if user_init.is_some() { if user_init.is_some() {
const_app_imports.push(quote!( const_app_imports.push(quote!(
@ -59,6 +60,11 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
#user_idle #user_idle
)); ));
imports.push(quote!(
#(#user_init_imports)*
#(#user_idle_imports)*
));
root.push(quote!( root.push(quote!(
#(#root_init)* #(#root_init)*
@ -105,27 +111,23 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
let const_app_schedule = schedule::codegen(app, extra); let const_app_schedule = schedule::codegen(app, extra);
let user_imports = app.user_imports.clone();
let name = &app.name; let name = &app.name;
let device = extra.device; let device = extra.device;
quote!( quote!(
#(#user)* #(#user)*
/// USER_HW_TASKS
#(#user_hardware_tasks)* #(#user_hardware_tasks)*
/// USER_SW_TASKS
#(#user_software_tasks)* #(#user_software_tasks)*
/// ROOT
#(#root)* #(#root)*
/// MOD_RESOURCES
#mod_resources #mod_resources
/// root_hardware_tasks
#(#root_hardware_tasks)* #(#root_hardware_tasks)*
/// root_software_tasks
#(#root_software_tasks)* #(#root_software_tasks)*
/// Implementation details /// Implementation details
@ -133,35 +135,27 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
mod #name { mod #name {
/// Always include the device crate which contains the vector table /// Always include the device crate which contains the vector table
use #device as _; use #device as _;
#(#const_app_imports)* #(#imports)*
#(#user_imports)*
/// User hardware_tasks
#(#user_hardware_tasks_imports)* #(#user_hardware_tasks_imports)*
/// User software_tasks
#(#user_software_tasks_imports)* #(#user_software_tasks_imports)*
/// Mod resources imports
#(#mod_resources_imports)* #(#mod_resources_imports)*
/// Const app /// Const app
#(#const_app)* #(#const_app)*
/// Const app resources
#(#const_app_resources)* #(#const_app_resources)*
/// Const app hw tasks
#(#const_app_hardware_tasks)* #(#const_app_hardware_tasks)*
/// Const app sw tasks
#(#const_app_software_tasks)* #(#const_app_software_tasks)*
/// Const app dispatchers
#(#const_app_dispatchers)* #(#const_app_dispatchers)*
/// Const app spawn
#(#const_app_spawn)* #(#const_app_spawn)*
/// Const app spawn end
#(#const_app_timer_queue)* #(#const_app_timer_queue)*