Futher extensions to `cfg(target_family)`, and concerns about breakage

Even more interesting... https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

  • CARGO_CFG_TARGET_FAMILY=unix — The target family, either unix or windows .

The one place you can check what the cargo buildscript environment variables are specifically says that only unix or windows are allowed values. This isn't true, and clicking through to the #[cfg] docs makes this clear, but the env var docs are wrong here.

In general, the docs aren't clear on what keys are allowed to be multi-valued.

I know having it as a 3rd party crate isn't ideal, but I did publish build-rs to put a typed interface to the environment variables and cargo: println!s. It should properly have all potentially multi-valued inputs returning a split Vec, but the docs aren't super clear on what's allowed to be multi-valued.

3 Likes