-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters