Fix embassy::main macros for std target
This commit is contained in:
parent
a3beb1ca3d
commit
5f04d6e6c5
@ -386,7 +386,6 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let embassy_path = macro_args.embassy_prefix.append("embassy");
|
let embassy_path = macro_args.embassy_prefix.append("embassy");
|
||||||
let embassy_std_path = macro_args.embassy_prefix.append("embassy_std");
|
|
||||||
|
|
||||||
let mut fail = false;
|
let mut fail = false;
|
||||||
if task_fn.sig.asyncness.is_none() {
|
if task_fn.sig.asyncness.is_none() {
|
||||||
@ -427,7 +426,6 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
let task_fn_body = task_fn.block.clone();
|
let task_fn_body = task_fn.block.clone();
|
||||||
|
|
||||||
let embassy_path = embassy_path.path();
|
let embassy_path = embassy_path.path();
|
||||||
let embassy_std_path = embassy_std_path.path();
|
|
||||||
let embassy_prefix_lit = macro_args.embassy_prefix.literal();
|
let embassy_prefix_lit = macro_args.embassy_prefix.literal();
|
||||||
|
|
||||||
let result = quote! {
|
let result = quote! {
|
||||||
@ -441,7 +439,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
::core::mem::transmute(t)
|
::core::mem::transmute(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut executor = #embassy_std_path::Executor::new();
|
let mut executor = #embassy_path::executor::Executor::new();
|
||||||
let executor = unsafe { make_static(&mut executor) };
|
let executor = unsafe { make_static(&mut executor) };
|
||||||
|
|
||||||
executor.run(|spawner| {
|
executor.run(|spawner| {
|
||||||
|
@ -7,7 +7,7 @@ resolver = "2"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
std = ["futures/std", "embassy-traits/std", "time", "time-tick-1mhz"]
|
std = ["futures/std", "embassy-traits/std", "time", "time-tick-1mhz", "embassy-macros/std"]
|
||||||
|
|
||||||
# Enable `embassy::time` module.
|
# Enable `embassy::time` module.
|
||||||
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.
|
# NOTE: This feature is only intended to be enabled by crates providing the time driver implementation.
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
|
|
||||||
use embassy::executor::Executor;
|
use embassy::executor::Spawner;
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy::util::Forever;
|
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
#[embassy::task]
|
#[embassy::task]
|
||||||
@ -14,16 +13,12 @@ async fn run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
#[embassy::main]
|
||||||
|
async fn main(spawner: Spawner) {
|
||||||
fn main() {
|
|
||||||
env_logger::builder()
|
env_logger::builder()
|
||||||
.filter_level(log::LevelFilter::Debug)
|
.filter_level(log::LevelFilter::Debug)
|
||||||
.format_timestamp_nanos()
|
.format_timestamp_nanos()
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
spawner.spawn(run()).unwrap();
|
||||||
executor.run(|spawner| {
|
|
||||||
spawner.spawn(run()).unwrap();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user