3 releases (breaking)

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

#38 in Procedural macros

Download history 7531/week @ 2021-10-06 6879/week @ 2021-10-13 7177/week @ 2021-10-20 7241/week @ 2021-10-27 6185/week @ 2021-11-03 6449/week @ 2021-11-10 6308/week @ 2021-11-17 6168/week @ 2021-11-24 7442/week @ 2021-12-01 7642/week @ 2021-12-08 8829/week @ 2021-12-15 6923/week @ 2021-12-22 8593/week @ 2021-12-29 11745/week @ 2022-01-05 9666/week @ 2022-01-12 8762/week @ 2022-01-19

39,944 downloads per month
Used in 672 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

~0.9–1.4MB
~34K SLoC