refactor(bootstrap): replace make_* macros with #[orbital::main] #846
No reviewers
Labels
No labels
Context: Bug
Context: Enhancements
Platform: Android
Platform: Linux
Platform: Web
Platform: Windows
Platform: iOS
Platform: macOS
Target: CI
Target: CLI
Target: Dependency
Target: Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SakulFlee/Orbital!846
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/app-bootstrap-macro"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Supersedes #724.
make_desktop_main!/make_android_main!/make_ios_main!were threemacro_rules!inorbital_core. They are now one proc-macro attribute in anew
orbital_macroscrate:#[orbital::main]
pub fn entrypoint(
event_loop_result: Result<
orbital::winit::event_loop::EventLoop<()>,
orbital::winit::error::EventLoopError,
>,
) { ... }
src/main.rsshrinks tofn main() { <crate>::run(); }. Entry pointbodies are unchanged.
All three targets now hand the entrypoint the
ResultfromEventLoop::builder().build()unchanged, so the generated call sites areidentical across targets — this removes the
Ok()-wrapping asymmetry thatneeded
69625540to paper over.Two fixes come along:
make_ios_main!used::winitwhile its desktop and Androidsiblings used
::orbital::winit.orbital initscaffolds projects withouta
winitdependency, so iOS builds of a freshly scaffolded project couldnot resolve the path. All generated paths are now
::orbital::-rooted.the process" behaviour rather than panicking inside a macro.
Migrates all eight examples and all three
orbital inittemplates. skybox,roll_camera and ui_demo drop their now-unused
winitdependency.Verification
cargo check --workspace --all-targetscargo clippy -- -D warningscargo fmt --all -- --checkcargo check --target aarch64-linux-androidcargo check --target aarch64-apple-iosorbital initfor minimal / all-in-one / 2d, each then builtReplaces the make_desktop_main! / make_android_main! / make_ios_main! macro_rules! trio in orbital_core with a single proc-macro attribute, `#[orbital::main]`, in a new orbital_macros crate. App entrypoints stay unchanged: #[orbital::main] pub fn entrypoint( event_loop_result: Result< orbital::winit::event_loop::EventLoop<()>, orbital::winit::error::EventLoopError, >, ) { ... } The attribute generates a desktop `run()` plus the Android and iOS entrypoints, so `src/main.rs` shrinks to `fn main() { <crate>::run(); }`. All three targets now hand the entrypoint the `Result` from EventLoop::builder().build() unchanged. That makes the generated call sites identical across targets and drops the Ok()-wrapping asymmetry that needed69625540to paper over. Two behavioural fixes come along: - The old make_ios_main! referred to `::winit` while its desktop and Android siblings used `::orbital::winit`. `orbital init` scaffolds projects without a winit dependency, so iOS builds of a freshly scaffolded project could not resolve the path. Every generated path is now `::orbital::`-rooted. - The Android recreation path keeps its "log and return, don't kill the process" behaviour instead of panicking inside a macro. Migrates all eight examples and all three `orbital init` templates. The examples whose only winit use was already `orbital::winit` (skybox, roll_camera, ui_demo) drop their now-unused `winit` dependency. Supersedes #724, which was written against the pre-Result entrypoint signature and had no Android FileManager initialisation or iOS target.