Closed CGMossa closed 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.
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!");
I've updated the description, and amended the purpose of this PR.
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 addbindings.rs
as a version controlled source file, and every time you want to alter this, you'll have toexport_bindings
that saves the resultingbindings.rs
file, and so that we can version control it. The feature ensures that we don't use it on crates.io, but still can keep track of what is emitted from bindgen from the flecs source.Follow-up PRs:
flecs
. A skeleton would be: (1) Placeflecs.c
andflecs.h
inflecs-sys/
directory. Runcargo build --features export_bindings
. Go through theflecs-sys/src/bindings.rs
file and accept changes that come from the updated. Make sure not to accept changes that modify changes to the bindings done by hand.flecs
version that is supported.