
# Objective - Remove dependency in bevy_asset to bevy_winit - First step for #15565 ## Solution - the static `ANDROID_APP` and the `android_activity` reexport are now in `bevy_window` ## Migration Guide If you use the `android_activity` reexport from `bevy::winit::android_activity`, it is now in `bevy:🪟:android_activity`. Same for the `ANDROID_APP` static
30 lines
773 B
Rust
30 lines
773 B
Rust
use proc_macro::TokenStream;
|
|
use quote::quote;
|
|
use syn::{parse_macro_input, ItemFn};
|
|
|
|
pub fn bevy_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
let input = parse_macro_input!(item as ItemFn);
|
|
assert_eq!(
|
|
input.sig.ident, "main",
|
|
"`bevy_main` can only be used on a function called 'main'."
|
|
);
|
|
|
|
TokenStream::from(quote! {
|
|
#[no_mangle]
|
|
#[cfg(target_os = "android")]
|
|
fn android_main(android_app: bevy::window::android_activity::AndroidApp) {
|
|
let _ = bevy::window::ANDROID_APP.set(android_app);
|
|
main();
|
|
}
|
|
|
|
#[no_mangle]
|
|
#[cfg(target_os = "ios")]
|
|
extern "C" fn main_rs() {
|
|
main();
|
|
}
|
|
|
|
#[allow(unused)]
|
|
#input
|
|
})
|
|
}
|