fn generate_bindings()

in aws-crt-sys/build.rs [86:110]


fn generate_bindings() {
    let bindings = bindgen::Builder::default()
        .header("../src/api.h")
        // Only generate types/functions starting with aws_crt and their dependents
        .allowlist_function("^aws_crt.*")
        .allowlist_type("^aws_crt.*")
        .size_t_is_usize(true)
        // Prevent rust from emitting a bazillion warnings about C-style code
        .raw_line("#![allow(dead_code)]")
        .raw_line("#![allow(non_upper_case_globals)]")
        .raw_line("#![allow(non_camel_case_types)]")
        .raw_line("#![allow(non_snake_case)]")
        .raw_line("#![allow(deref_nullptr)]")
        // Enums will be generated as struct/impl constants
        .default_enum_style(EnumVariation::NewType {is_bitfield: false})
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        // Make the generated code actually readable
        .rustfmt_bindings(true)
        .generate()
        .expect("Unable to generate bindings for aws-crt-ffi");

    bindings
        .write_to_file(Path::new("src/lib.rs"))
        .expect("Unable to write generated bindings");
}