diff options
author | Pietro Albini <pietro.albini@ferrous-systems.com> | 2022-12-14 13:41:49 +0100 |
---|---|---|
committer | Pietro Albini <pietro.albini@ferrous-systems.com> | 2023-03-06 09:39:29 +0100 |
commit | f8a12ee0a4e96f830cdc765343aa60cbe27c5a4a (patch) | |
tree | d083c671a5f5f95d445c5184014dfcaa210bb432 /build.rs | |
parent | 88b7f0d991eacae483b23c6ab9ba1ed0a4a6bd43 (diff) | |
download | rust-libc-f8a12ee0a4e96f830cdc765343aa60cbe27c5a4a.tar.gz |
ensure all cfgs used are allowed
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -2,6 +2,33 @@ use std::env; use std::process::Command; use std::str; +// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we +// need to know all the possible cfgs that this script will set. If you need to set another cfg +// make sure to add it to this list as well. +const ALLOWED_CFGS: &[&str] = &[ + "freebsd10", + "freebsd11", + "freebsd12", + "freebsd13", + "freebsd14", + "libc_align", + "libc_cfg_target_vendor", + "libc_const_extern_fn", + "libc_const_extern_fn_unstable", + "libc_const_size_of", + "libc_core_cvoid", + "libc_deny_warnings", + "libc_int128", + "libc_long_array", + "libc_non_exhaustive", + "libc_packedN", + "libc_priv_mod_use", + "libc_ptr_addr_of", + "libc_thread_local", + "libc_underscore_const_names", + "libc_union", +]; + fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=build.rs"); @@ -181,5 +208,8 @@ fn which_freebsd() -> Option<i32> { } fn set_cfg(cfg: &str) { + if !ALLOWED_CFGS.contains(&cfg) { + panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg); + } println!("cargo:rustc-cfg={}", cfg); } |