3 releases (breaking)

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

#958 in Procedural macros

Download history 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 16731/week @ 2024-05-09 29670/week @ 2024-05-16 23665/week @ 2024-05-23 25125/week @ 2024-05-30 25262/week @ 2024-06-06 27388/week @ 2024-06-13 24544/week @ 2024-06-20 18433/week @ 2024-06-27

101,107 downloads per month
Used in 1,000 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