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.
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 precedesBINDGEN_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
orBINDGEN_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.