summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorJeff Waugh <jdub@bethesignal.org>2016-11-15 17:01:08 +1100
committerJeff Waugh <jdub@bethesignal.org>2016-11-16 05:31:08 +1100
commitc555fcf76a3b3b2e416a8a517e72b319e9a4d18b (patch)
treef9fefe9cc33a3c5f94a1a4b7f7db60454a73056f /README.md
parent8270a0ca766ea834032daeb67c7f32a1947ab3bd (diff)
Document library usage
Diffstat (limited to 'README.md')
-rw-r--r--README.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/README.md b/README.md
index 97488b6b..7187201f 100644
--- a/README.md
+++ b/README.md
@@ -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