3 releases (breaking)

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

#1903 in Procedural macros

Download history 17266/week @ 2023-11-20 23020/week @ 2023-11-27 14706/week @ 2023-12-04 13379/week @ 2023-12-11 20748/week @ 2023-12-18 5619/week @ 2023-12-25 9545/week @ 2024-01-01 11079/week @ 2024-01-08 10947/week @ 2024-01-15 10343/week @ 2024-01-22 9318/week @ 2024-01-29 10231/week @ 2024-02-05 8378/week @ 2024-02-12 11252/week @ 2024-02-19 12814/week @ 2024-02-26 10356/week @ 2024-03-04

43,478 downloads per month
Used in 998 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
~80K SLoC