diff --git a/build.rs b/build.rs index 54f9d0a..6ccc913 100644 --- a/build.rs +++ b/build.rs @@ -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"); } @@ -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"); } diff --git a/codegen/src/build.rs b/codegen/src/build.rs index 365a82f..21ac916 100644 --- a/codegen/src/build.rs +++ b/codegen/src/build.rs @@ -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!("}}"); @@ -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"); {