diff --git a/README.md b/README.md index 3d0c8050a5a38bd9309dc6ba9f563a847904c60d..03286796e54a69f2928f4f923d9f5ff79db9417f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,27 @@ fn main() { ``` +## Configuration + +There are a lot of configurable options for binding generation. Options can be specified by creating a `cbindgen.toml` with the options in the binding crate root. Alternatively, build scripts can specify options using `cbindgen::generate_with_config`. + +Some useful options: + +1. `header` - Optional text to output at the beginning of the file +2. `trailer` - Optional text to output at the end of the file +3. `include_guard` - Optional name to use for an include guard +4. `autogen_warning` - Optional text to output at major sections to deter manual editing +5. `include_version` - Whether to include a comment with the version of cbindgen used to generate the file +6. `braces` - The style to use for braces (can be either SameLine or NextLine) +7. `line_length` - The preferred length of a line, used when auto breaking function arguments +8. `tab_width` - The amount of spaces in an indentation +9. `language` - The language to generate bindings in (can be either C++ or C) +10. `parse_deps` - Whether to parse dependent crates +11. `include` - An optional whitelist to use when parsing dependent crates +12. `exclude` - An optional blacklist to use when parsing dependent crates + +A full listing of options can be found in `src/bindgen/config.rs` + ## Examples See `compile-tests/` for some examples of rust source that can be handled. diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs index 123a57e8d5151aa2908eae0d270c76f6c03f5cbc..4e3a1f73afee372bc6515486e4e8316f5467756f 100644 --- a/src/bindgen/config.rs +++ b/src/bindgen/config.rs @@ -253,7 +253,7 @@ pub struct Config { pub header: Option<String>, /// Optional text to output at the end of the file pub trailer: Option<String>, - /// Option name to use for an include guard + /// Optional name to use for an include guard pub include_guard: Option<String>, /// Optional text to output at major sections to deter manual editing pub autogen_warning: Option<String>, diff --git a/src/lib.rs b/src/lib.rs index 6881b97206db562defd3aa2b499f2c3933be9f32..1d4e0f259a70cb66c721faf6d759a4321c73dd8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,6 @@ pub fn generate(crate_dir: &str) -> Result<GeneratedBindings, String> { /// A utility function for build scripts to generate bindings for a crate with a /// custom config. -pub fn generate_config(crate_dir: &str, config: &Config) -> Result<GeneratedBindings, String> { +pub fn generate_with_config(crate_dir: &str, config: &Config) -> Result<GeneratedBindings, String> { Library::load_crate(Cargo::load(Path::new(crate_dir), None)?, config)?.generate() }