refactor(bootstrap): replace make_* macros with #[orbital::main] #846

Merged
SakulFlee merged 2 commits from feat/app-bootstrap-macro into main 2026-09-30 03:03:26 +00:00
Owner

Supersedes #724.

make_desktop_main! / make_android_main! / make_ios_main! were three
macro_rules! in orbital_core. They are now one proc-macro attribute in a
new orbital_macros crate:

#[orbital::main]
pub fn entrypoint(
event_loop_result: Result<
orbital::winit::event_loop::EventLoop<()>,
orbital::winit::error::EventLoopError,
>,
) { ... }

src/main.rs shrinks to fn main() { <crate>::run(); }. Entry point
bodies are unchanged.

All three targets now hand the entrypoint the Result from
EventLoop::builder().build() unchanged, so the generated call sites are
identical across targets — this removes the Ok()-wrapping asymmetry that
needed 69625540 to paper over.

Two fixes come along:

  • The old make_ios_main! used ::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. All generated paths are now ::orbital::-rooted.
  • The Android activity-recreation path keeps its "log and return, don't kill
    the process" behaviour rather than panicking inside a macro.

Migrates all eight examples and all three orbital init templates. skybox,
roll_camera and ui_demo drop their now-unused winit dependency.

Verification

  • cargo check --workspace --all-targets
  • cargo clippy -- -D warnings
  • cargo fmt --all -- --check
  • cargo check --target aarch64-linux-android
  • cargo check --target aarch64-apple-ios
  • orbital init for minimal / all-in-one / 2d, each then built
Supersedes #724. `make_desktop_main!` / `make_android_main!` / `make_ios_main!` were three `macro_rules!` in `orbital_core`. They are now one proc-macro attribute in a new `orbital_macros` crate: #[orbital::main] pub fn entrypoint( event_loop_result: Result< orbital::winit::event_loop::EventLoop<()>, orbital::winit::error::EventLoopError, >, ) { ... } `src/main.rs` shrinks to `fn main() { <crate>::run(); }`. Entry point bodies are unchanged. All three targets now hand the entrypoint the `Result` from `EventLoop::builder().build()` unchanged, so the generated call sites are identical across targets — this removes the `Ok()`-wrapping asymmetry that needed 69625540 to paper over. Two fixes come along: - The old `make_ios_main!` used `::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. All generated paths are now `::orbital::`-rooted. - The Android activity-recreation path keeps its "log and return, don't kill the process" behaviour rather than panicking inside a macro. Migrates all eight examples and all three `orbital init` templates. skybox, roll_camera and ui_demo drop their now-unused `winit` dependency. ## Verification - `cargo check --workspace --all-targets` - `cargo clippy -- -D warnings` - `cargo fmt --all -- --check` - `cargo check --target aarch64-linux-android` - `cargo check --target aarch64-apple-ios` - `orbital init` for minimal / all-in-one / 2d, each then built
Replaces 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 needed
69625540 to 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.
fix(ios): repair GameController poll so iOS compiles
All checks were successful
Lint / lint (pull_request) Successful in 4m27s
bd03aad7e6
`cargo check --target aarch64-apple-ios` failed on orbital_app in three
places, all in 27749a95 (feat: poll GameController for iOS gamepads). The
module is iOS-gated, so host-target CI never compiled it and the breakage
landed unnoticed.

- `alive` was a HashMap but only ever used as a set. Make it a HashSet,
  which is what the single-argument `insert` and `contains` calls want.
- `&mut self.pads[&key]` needs IndexMut, which HashMap does not
  implement. Use get_mut; the entry was inserted a few lines above for
  newly seen controllers, so it is always present.

Found while cross-checking the new #[orbital::main] attribute, which
needed an iOS compile to verify its generated `ios_main`.
SakulFlee deleted branch feat/app-bootstrap-macro 2026-09-30 03:03:27 +00:00
Sign in to join this conversation.
No description provided.