3 releases (breaking)

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

#927 in Procedural macros

Download history 9091/week @ 2024-01-25 8882/week @ 2024-02-01 9674/week @ 2024-02-08 9813/week @ 2024-02-15 11381/week @ 2024-02-22 12483/week @ 2024-02-29 9060/week @ 2024-03-07 7396/week @ 2024-03-14 10248/week @ 2024-03-21 8896/week @ 2024-03-28 14417/week @ 2024-04-04 13893/week @ 2024-04-11 17117/week @ 2024-04-18 14149/week @ 2024-04-25 17399/week @ 2024-05-02 13298/week @ 2024-05-09

64,908 downloads per month
Used in 993 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
~82K SLoC