Skip to content

Commit c057768

Browse files
committed
Document library usage
1 parent 9e5a47e commit c057768

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,40 @@ $ LIBCLANG_PATH=path/to/clang-3.9/build/lib \
7676
cargo build
7777
```
7878

79+
# Library usage with `build.rs`
80+
81+
In `Cargo.toml`:
82+
83+
```toml
84+
[package]
85+
...
86+
build = "build.rs"
87+
88+
[build-dependencies.libbindgen]
89+
git = "https://github.com/servo/rust-bindgen"
90+
features = ["llvm_stable"]
91+
```
92+
93+
In `build.rs`:
94+
95+
```rust
96+
extern crate libbindgen;
97+
98+
fn main() {
99+
let _ = libbindgen::builder()
100+
.header("example.h")
101+
.use_core()
102+
.generate().unwrap()
103+
.write_to_file(concat!(env!("OUT_DIR"), "/example.rs"));
104+
}
105+
```
106+
107+
In `src/main.rs`:
108+
109+
```rust
110+
include!(concat!(env!("OUT_DIR"), "/example.rs"));
111+
```
112+
79113
# Command Line Usage
80114

81115
There are a few options documented when running `./bindgen --help`. Other

0 commit comments

Comments
 (0)