commit | 1e807c13e5eb07b21c9f0c390965c6c99bb5abde | [log] [tgz] |
---|---|---|
author | Treehugger Robot <treehugger-gerrit@google.com> | Thu Nov 05 04:08:12 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Nov 05 04:08:12 2020 +0000 |
tree | b1bb665e131fe42d692de9983e78f024817893f3 | |
parent | 3b677b94e0e5ff5abd8518b84296aff1001076c3 [diff] | |
parent | 08de407d53d3d40a23c67f948edd379823664e1c [diff] |
Merge "Regenerate .bp and replace env!("...") expressions" am: 3e7a4060f4 am: f515502965 am: 8db7ce732d am: 08de407d53 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/bindgen/+/1485262 Change-Id: I2eed6cf4b18d13aa4c07864c50859db0ed93a8fa
bindgen
bindgen
automatically generates Rust FFI bindings to C (and some C++) libraries.
For example, given the C header doggo.h
:
typedef struct Doggo { int many; char wow; } Doggo; void eleven_out_of_ten_majestic_af(Doggo* pupper);
bindgen
produces Rust FFI code allowing you to call into the doggo
library's functions and use its types:
/* automatically generated by rust-bindgen 0.99.9 */ #[repr(C)] pub struct Doggo { pub many: ::std::os::raw::c_int, pub wow: ::std::os::raw::c_char, } extern "C" { pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo); }
📚 Read the bindgen
users guide here! 📚
The minimum supported Rust version is 1.40.
No MSRV bump policy has been established yet, so MSRV may increase in any release.
API reference documentation is on docs.rs
In addition to the library API and executable command-line API, bindgen
can be controlled through environment variables.
End-users should set these environment variables to modify bindgen
's behavior without modifying the source code of direct consumers of bindgen
.
BINDGEN_EXTRA_CLANG_ARGS
: extra arguments to pass to clang
--sysroot=/path/to/sysroot
-I"/path/with spaces"
Additionally, bindgen
uses libclang
to parse C and C++ header files. To modify how bindgen
searches for libclang
, see the clang-sys
documentation. For more details on how bindgen
uses libclang
, see the bindgen
users guide.