diff options
author | Jeff Waugh <jdub@bethesignal.org> | 2016-11-15 17:01:08 +1100 |
---|---|---|
committer | Jeff Waugh <jdub@bethesignal.org> | 2016-11-16 05:31:08 +1100 |
commit | c555fcf76a3b3b2e416a8a517e72b319e9a4d18b (patch) | |
tree | f9fefe9cc33a3c5f94a1a4b7f7db60454a73056f /README.md | |
parent | 8270a0ca766ea834032daeb67c7f32a1947ab3bd (diff) |
Document library usage
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -76,6 +76,40 @@ $ LIBCLANG_PATH=path/to/clang-3.9/build/lib \ cargo build ``` +# Library usage with `build.rs` + +In `Cargo.toml`: + +```toml +[package] +... +build = "build.rs" + +[build-dependencies.libbindgen] +git = "https://github.com/servo/rust-bindgen" +features = ["llvm_stable"] +``` + +In `build.rs`: + +```rust +extern crate libbindgen; + +fn main() { + let _ = libbindgen::builder() + .header("example.h") + .use_core() + .generate().unwrap() + .write_to_file(concat!(env!("OUT_DIR"), "/example.rs")); +} +``` + +In `src/main.rs`: + +```rust +include!(concat!(env!("OUT_DIR"), "/example.rs")); +``` + # Command Line Usage There are a few options documented when running `./bindgen --help`. Other |