Update the README for build script instructions

This commit is contained in:
Ryan Hunt 2017-04-17 22:26:18 -04:00
parent e76b25701d
commit 2bf0ca2762

View File

@ -11,8 +11,31 @@ This project can be used to generate C bindings for Rust code. It is currently b
## Use ## Use
### Command line
`cbindgen crate/ crate/bindings.h` `cbindgen crate/ crate/bindings.h`
See `cbindgen --help` for more options.
### `build.rs`
`cbindgen` can also be used in build scripts. How this fits into compiling the native code depends on your project.
Here's an example build.rs script:
```rust
extern crate cbindgen;
use cbindgen::{Config, Library};
fn main() {
let config = Config::default();
Library::load("../build-script", &config)
.build(&config).unwrap()
.write_to_file(&config, "bindings.h");
}
```
## Examples ## Examples
See `examples/` for some examples of rust source that can be handled. See `examples/` for some examples of rust source that can be handled.