rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.45k stars 52 forks source link

zig: do not overwrite bindgen env vars if already set #126

Closed lriesebos closed 1 year ago

lriesebos commented 1 year ago

see https://github.com/rust-cross/cargo-zigbuild/issues/74#issuecomment-1507886083

basically, BINDGEN_EXTRA_CLANG_ARGS_<target> was always set (i.e. overwritten) even if the env variable was already set by the user. this target-specific env variable also precedes BINDGEN_EXTRA_CLANG_ARGS which becomes powerless. as a result, users were not able to pass their own arguments to clang for bindgen through env variables.

this fix checks if BINDGEN_EXTRA_CLANG_ARGS or BINDGEN_EXTRA_CLANG_ARGS_<target> was already set. if it was set by the user, cargo-zigbuild will not overwrite those values and leave them as is. if both env vars are not set, cargo-zigbuild will keep its existing behavior by setting the clang sysroot.