diff options
author | 2020-10-24 19:38:49 +0200 | |
---|---|---|
committer | 2020-10-24 19:38:49 +0200 | |
commit | 0f8e17361408a704a63995ce9e52fbdeaf34de0b (patch) | |
tree | 6e6097e87ab01186e017f2fc8da0bc11f1a0a486 | |
parent | d11b2ddd3559b29480b9bbcf9d5b7836de190f77 (diff) | |
download | rtic-0f8e17361408a704a63995ce9e52fbdeaf34de0b.tar.gz rtic-0f8e17361408a704a63995ce9e52fbdeaf34de0b.tar.zst rtic-0f8e17361408a704a63995ce9e52fbdeaf34de0b.zip |
extern examples added
-rw-r--r-- | macros/Cargo.toml | 3 | ||||
-rw-r--r-- | macros/src/codegen/hardware_tasks.rs | 28 | ||||
-rw-r--r-- | macros/src/codegen/software_tasks.rs | 32 |
3 files changed, 34 insertions, 29 deletions
diff --git a/macros/Cargo.toml b/macros/Cargo.toml index a9f268fb..ffa353c5 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -22,5 +22,6 @@ proc-macro2 = "1" proc-macro-error = "1" quote = "1" syn = "1" -rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.5.0-alpha.0" } +#rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "master", version = "0.5.0-alpha.0" } +rtic-syntax = { git = "https://github.com/rtic-rs/rtic-syntax", branch = "extern_task", version = "0.5.0-alpha.0" } diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index e5a8deb9..c9d0297e 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -95,19 +95,21 @@ pub fn codegen( locals_pat = Some(pat); } - let attrs = &task.attrs; - let context = &task.context; - let stmts = &task.stmts; - let locals_pat = locals_pat.iter(); - user_tasks.push(quote!( - #(#attrs)* - #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context) { - use rtic::Mutex as _; - - #(#stmts)* - } - )); + if !&task.is_extern { + let attrs = &task.attrs; + let context = &task.context; + let stmts = &task.stmts; + let locals_pat = locals_pat.iter(); + user_tasks.push(quote!( + #(#attrs)* + #[allow(non_snake_case)] + fn #name(#(#locals_pat,)* #context: #name::Context) { + use rtic::Mutex as _; + + #(#stmts)* + } + )); + } } (mod_app, root, user_tasks) diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index dfba193b..833e338d 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -99,21 +99,23 @@ pub fn codegen( root.push(struct_); } - let context = &task.context; - let attrs = &task.attrs; - let cfgs = &task.cfgs; - let stmts = &task.stmts; - let locals_pat = locals_pat.iter(); - user_tasks.push(quote!( - #(#attrs)* - #(#cfgs)* - #[allow(non_snake_case)] - fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { - use rtic::Mutex as _; - - #(#stmts)* - } - )); + if !&task.is_extern { + let context = &task.context; + let attrs = &task.attrs; + let cfgs = &task.cfgs; + let stmts = &task.stmts; + let locals_pat = locals_pat.iter(); + user_tasks.push(quote!( + #(#attrs)* + #(#cfgs)* + #[allow(non_snake_case)] + fn #name(#(#locals_pat,)* #context: #name::Context #(,#inputs)*) { + use rtic::Mutex as _; + + #(#stmts)* + } + )); + } root.push(module::codegen( Context::SoftwareTask(name), |