Update the README for build script instructions
This commit is contained in:
parent
e76b25701d
commit
2bf0ca2762
23
README.md
23
README.md
@ -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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user