3 releases (breaking)

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

#1054 in Procedural macros

Download history 13976/week @ 2024-07-23 12531/week @ 2024-07-30 13516/week @ 2024-08-06 12981/week @ 2024-08-13 14614/week @ 2024-08-20 11855/week @ 2024-08-27 14686/week @ 2024-09-03 13904/week @ 2024-09-10 16464/week @ 2024-09-17 17196/week @ 2024-09-24 17171/week @ 2024-10-01 14064/week @ 2024-10-08 15074/week @ 2024-10-15 18283/week @ 2024-10-22 15190/week @ 2024-10-29 17736/week @ 2024-11-05

68,355 downloads per month
Used in 982 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
~85K SLoC