Skip to content

Commit

Permalink
fix lints: unexpected cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed May 12, 2024
1 parent 06c4c94 commit a53b80f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();

println!("cargo:rustc-check-cfg=cfg(target_os, values(\"switch\"))");
let has_prlimit64 = (target_os == "android" && target_env != "newlib")
|| ((target_env == "gnu" || target_env == "musl" || target_env == "ohos")
&& (target_os == "l4re" || target_os == "linux"));
println!("cargo:rustc-check-cfg=cfg(rlimit__has_prlimit64)");
if has_prlimit64 {
println!("cargo:rustc-cfg=rlimit__has_prlimit64");
}
Expand All @@ -16,6 +18,7 @@ fn main() {
|| target_os == "tvos"
|| target_os == "watchos")
&& target_env != "newlib";
println!("cargo:rustc-check-cfg=cfg(rlimit__get_kern_max_files_per_proc)");
if get_kern_max_files_per_proc {
println!("cargo:rustc-cfg=rlimit__get_kern_max_files_per_proc");
}
Expand Down
7 changes: 7 additions & 0 deletions codegen/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn set_cfg_if(key: &str, cfg: &Expr) {
};

g!("let {key} = {cfg};");
g!(r#"println!("cargo:rustc-check-cfg=cfg(rlimit__{key})");"#);
g!("if {key} {{");
g!(r#"println!("cargo:rustc-cfg=rlimit__{key}");"#);
g!("}}");
Expand All @@ -85,6 +86,12 @@ pub fn codegen(item_list: &[CfgItem]) {
g!();
}

{
let extra_os = ["switch"];
let values = extra_os.join("\",\"");
g!(r#"println!("cargo:rustc-check-cfg=cfg(target_os, values(\"{values}\"))");"#)
}

forward_item_cfg(item_list, "prlimit64");

{
Expand Down

0 comments on commit a53b80f

Please sign in to comment.