You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bindgen::ParseCallbacks: support tracking env variable usage for cargo (#2400)
bindgen currently has a `bindgen/build.rs` which attempts to have cargo
rebuild bindgen when TARGET specific env variables change, specifically
`BINDGEN_EXTRA_CLANG_ARGS_<target>`. Unfortunately, this doesn't have
the desired effect in most cases.
Specifically, when a crate `A` has `bindgen` in `build-dependencies`,
and we're cross compiling `A` for target `T` on a host `H`, `bindgen`'s
`build.rs` will observe `TARGET` set to `H` (the host target name)
instead of `T` (because `bindgen` itself is being built for `H` and not
`T`). Then, within the build script of crate `A`, one would use
`bindgen` to generate bindings, and now `TARGET` is set to `T`, so
different env variables are used.
Allow crates using `bindgen` in build scripts to correctly handle env
variable changes by adding `ParseCallbacks::read_env_var()` to track
env var reads and adding a basic implementation to `CargoCallbacks` to
emit `cargo:rerun-if-env-changed` lines.
0 commit comments