jazzay / flecs-rs

Rust bindings for the Flecs ECS library
MIT License
69 stars 9 forks source link

Version control generated `bindings.rs`, export documentation, etc. #16

Closed CGMossa closed 1 year ago

CGMossa commented 1 year ago

Bindings should not solely come from bindgen, or otherwise programmatically. They should be carefully modified by hand. One idea we have is to add #[inline] or #[inline(always)] to various parts of the bindings. Thus this PR aims to add bindings.rs as a version controlled source file, and every time you want to alter this, you'll have to

cargo build --features export_bindings

Follow-up PRs:

CGMossa commented 1 year ago

For instance, one commit I just pushed does this:

    let bindings = bindings
        .allowlist_file("flecs.c")
        .allowlist_file("flecs.h")
        .generate()
        .expect("Unable to generate bindings");

Which aims to remove all C-system-header stuff from the bindings. Their effect on the bindings is now visible here in the PR. image

CGMossa commented 1 year ago

Comments from the build.rs

    // We generate bindings to an actual source file so that we get better IDE integration
    // Sadly to publish on crates.io we cannot write outside the OUT_DIR revisit this later.
    // let out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
    // bindings
    //  .write_to_file(out_path.join("src/bindings.rs"))
    //  .expect("Couldn't write bindings!");
CGMossa commented 1 year ago

I've updated the description, and amended the purpose of this PR.