3 releases (breaking)

0.3.0 Nov 22, 2021
0.2.0 Sep 15, 2020
0.1.0 Jul 29, 2020

#1116 in Procedural macros

Download history 15301/week @ 2024-10-27 18349/week @ 2024-11-03 13942/week @ 2024-11-10 15848/week @ 2024-11-17 13399/week @ 2024-11-24 17666/week @ 2024-12-01 16628/week @ 2024-12-08 17426/week @ 2024-12-15 4573/week @ 2024-12-22 6239/week @ 2024-12-29 15004/week @ 2025-01-05 19906/week @ 2025-01-12 15404/week @ 2025-01-19 15354/week @ 2025-01-26 16468/week @ 2025-02-02 18485/week @ 2025-02-09

66,387 downloads per month
Used in 971 crates (via ndk-glue)

MIT/Apache

28KB
703 lines

ndk-macro

Implementation of the attribute procedural macro main which applied directly to main function.

This macro is re-exported in ndk-glue. Typically, it's not needed to depend on this library directly!

Usage

#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
pub fn main() {
    println!("hello world");
}

The attribute macro supports optional input attributes:

  • backtrace = "on|full": Enables backtraces by setting the RUST_BACKTRACE env var
  • ndk_glue = "path::to::ndk_glue": Overrides default path to ndk_glue crate
  • logger(...props): Configures android logger with the passed configuration (requires the logger feature):
    • level = "error|warn|info|debug|trace": Changes log level for logger
    • tag = "my-tag": Assigns tag to logger
    • filter = "filtering-rules": Changes default filtering rules

Dependencies

~4MB
~95K SLoC