#binary #asm #macro #proc-macro

macro bingen

Procedure macro for bringing a compile-time compiled assembly code as a binary slice

4 releases (2 breaking)

0.3.1 Oct 10, 2021
0.3.0 Oct 10, 2021
0.2.0 Oct 4, 2021
0.1.0 Oct 3, 2021

#1482 in Procedural macros

Download history 13/week @ 2024-07-22 55/week @ 2024-08-05 22/week @ 2024-08-12 18/week @ 2024-08-19 111/week @ 2024-08-26 96/week @ 2024-09-02 236/week @ 2024-09-09 96/week @ 2024-09-16 243/week @ 2024-09-23 179/week @ 2024-09-30 106/week @ 2024-10-07 152/week @ 2024-10-14 113/week @ 2024-10-21 6/week @ 2024-10-28 174/week @ 2024-11-04

447 downloads per month

MIT license

8KB
170 lines

bingen

Procedure macro for bringing a compile-time compiled assembly code as a binary slice.

[dependencies]
bingen = "0.3"
let bin = bingen!("aarch64-linux-eabi", "mrs x0, DBGDTR_EL0");
assert_eq!(bin, [0, 4, 51, 213]);

This crate automatically detects the latest installation of llvm toolchains by default.

If you want to use other llvm installation, specify the paths manually like this:

BINGEN_CLANG_PATH=/path/to/clang \
  BINGEN_OBJCOPY_PATH=/path/to/llvm-objcopy \
  cargo test

To know which toolchain is used by default, run this:

$ cargo test --lib tests::print_llvm_path -- --nocapture --ignored
    Finished test [unoptimized + debuginfo] target(s) in 0.02s
     Running unittests (target/debug/deps/bingen-4b08a2f2272400c9)

running 1 test
LLVMPath { clang: "/usr/bin/clang-8", llvm_objcopy: "/usr/bin/llvm-objcopy-8" }
test tests::print_llvm_path ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Dependencies

~3–11MB
~152K SLoC