fn gen_bindings(
    wrapper: impl AsRef<Path>,
    dst: impl AsRef<Path>,
    args: impl IntoIterator<Item = impl AsRef<str>>,
    docstring: &str,
    mut setup_builder: impl FnMut(bindgen::Builder) -> bindgen::Builder,
) {
    let gen = bindgen::Builder::default()
        .header(format!("{}", wrapper.as_ref().display()))
        .clang_args(args)
        .parse_callbacks(Box::new(bindgen::CargoCallbacks));

    let gen = setup_builder(gen);
    let gen = gen
        .raw_line(docstring)
        .raw_line("")
        .raw_line(r"#![allow(warnings)]");

    let gen = gen.generate().unwrap_or_else(|err| {
        panic!(
            "Unable to generate bindings for `{}`. Original error {:?}",
            dst.as_ref().display(),
            err
        )
    });

    // it's `ok` to fail on crates.io
    gen.write_to_file(dst).ok();
}
/// Generates Rust FFI using a wrapper header file
Generates Rust FFI using a wrapper header file
Generates Rust FFI using a wrapper header file
fn gen_bindings(
    wrapper: impl AsRef<Path>,
    dst: impl AsRef<Path>,
    args: impl IntoIterator<Item = impl AsRef<str>>,
    docstring: &str,
    mut setup_builder: impl FnMut(bindgen::Builder) -> bindgen::Builder,
) {
    let gen = bindgen::Builder::default()
        .header(format!("{}", wrapper.as_ref().display()))
        .clang_args(args)
        .parse_callbacks(Box::new(bindgen::CargoCallbacks));
    let gen = setup_builder(gen);
    let gen = gen
        .raw_line(docstring)
        .raw_line("")
        .raw_line(r"#![allow(warnings)]");
    let gen = gen.generate().unwrap_or_else(|err| {
        panic!(
            "Unable to generate bindings for `{}`. Original error {:?}",
            dst.as_ref().display(),
            err
        )
    });
    // it's `ok` to fail on crates.io
    gen.write_to_file(dst).ok();
}
fn gen_bindings ( wrapper : impl AsRef < Path > , dst : impl AsRef < Path > , args : impl IntoIterator < Item = impl AsRef < str > > , docstring : & str , mut setup_builder : impl FnMut ( bindgen :: Builder ) -> bindgen :: Builder , ) { let gen = bindgen :: Builder :: default ( ) . header ( format ! ( " " wrapper as_ref ( ) display ( ) ) ) . clang_args ( args ) . parse_callbacks ( Box :: new ( bindgen :: CargoCallbacks ) ) ; let gen = setup_builder ( gen ) ; let gen = gen . raw_line ( docstring ) . raw_line ( " " ) . raw_line ( r"#![allow(warnings)]" ) ; let gen = gen . generate ( ) . unwrap_or_else ( | err | { panic ! ( " " dst as_ref ( ) display ( ) err ) } ) ; // it's `ok` to fail on crates.io gen . write_to_file ( dst ) . ok ( ) ; }
Generates Rust FFI using a wrapper header file
Generates Rust FFI using a wrapper header file
wrapper
impl AsRef<Path>
dst
impl AsRef<Path>
args
impl IntoIterator<Item = impl AsRef<str>>
docstring
&str
setup_builder
impl FnMut(bindgen::Builder) -> bindgen::Builder
wrapper
impl AsRef<Path>
dst
impl AsRef<Path>
args
impl IntoIterator<Item = impl AsRef<str>>
docstring
&str
setup_builder
impl FnMut(bindgen::Builder) -> bindgen::Builder