Skip to content

Commit ccbbd93

Browse files
committed
feat(cargo): Set rustc-check-cfg for all config options
This squashes lint warnings for config options which are not currently enabled. See https://doc.rust-lang.org/cargo/reference/build-scripts.html\#rustc-check-cfg Signed-off-by: Hayden Ball <[email protected]>
1 parent 8952b44 commit ccbbd93

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

zephyr-build/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ pub fn export_bool_kconfig() {
3333
println!("cargo:rerun-if-env-changed=DOTCONFIG");
3434
println!("cargo-rerun-if-changed={}", dotconfig);
3535

36+
let config_n = Regex::new(r"(CONFIG_.*) is not set$").unwrap();
3637
let config_y = Regex::new(r"^(CONFIG_.*)=y$").unwrap();
3738

3839
let file = File::open(&dotconfig).expect("Unable to open dotconfig");
3940
for line in BufReader::new(file).lines() {
4041
let line = line.expect("reading line from dotconfig");
42+
4143
if let Some(caps) = config_y.captures(&line) {
4244
println!("cargo:rustc-cfg={}", &caps[1]);
45+
println!("cargo:rustc-check-cfg=cfg({})", &caps[1]);
46+
} else if let Some(caps) = config_n.captures(&line) {
47+
println!("cargo:rustc-check-cfg=cfg({})", &caps[1]);
4348
}
4449
}
4550
}

0 commit comments

Comments
 (0)