Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindgen::ParseCallbacks: support tracking env variable usage for cargo #2400

Merged
merged 4 commits into from
Apr 10, 2023

Commits on Apr 10, 2023

  1. bindgen::ParseCallbacks: support tracking env variable usage for cargo

    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.
    codyps authored and pvdrz committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    461faa3 View commit details
    Browse the repository at this point in the history
  2. Run rustfmt

    pvdrz committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    7293154 View commit details
    Browse the repository at this point in the history
  3. Update docs

    pvdrz committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    7179fde View commit details
    Browse the repository at this point in the history
  4. Update changelog

    pvdrz committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    3e0b7a5 View commit details
    Browse the repository at this point in the history