diff --git a/commons/zenoh-shm/Cargo.toml b/commons/zenoh-shm/Cargo.toml index d87fefb408..ab8d94d697 100644 --- a/commons/zenoh-shm/Cargo.toml +++ b/commons/zenoh-shm/Cargo.toml @@ -61,6 +61,3 @@ winapi = { workspace = true } [dev-dependencies] libc = { workspace = true } - -[build-dependencies] -cfg_aliases = "0.2.1" diff --git a/commons/zenoh-shm/build.rs b/commons/zenoh-shm/build.rs index 2502b031c0..72158ab769 100644 --- a/commons/zenoh-shm/build.rs +++ b/commons/zenoh-shm/build.rs @@ -12,38 +12,30 @@ // ZettaScale Zenoh Team, // -use cfg_aliases::cfg_aliases; - fn main() { - // these aliases should at least be included in the same aliases of Nix crate: - // ___________________ - // | | - // | Nix aliases | - // | ___________ | - // | | Our | | - // | | aliases | | - // | |_________| | - // |_________________| - cfg_aliases! { - dragonfly: { target_os = "dragonfly" }, - ios: { target_os = "ios" }, - freebsd: { target_os = "freebsd" }, - macos: { target_os = "macos" }, - netbsd: { target_os = "netbsd" }, - openbsd: { target_os = "openbsd" }, - watchos: { target_os = "watchos" }, - tvos: { target_os = "tvos" }, - visionos: { target_os = "visionos" }, - - apple_targets: { any(ios, macos, watchos, tvos, visionos) }, - bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets) }, + // `shm_external_lockfile` is the only cfg alias this crate actually + // queries (see src/posix_shm/cleanup.rs, src/shm/unix.rs) -- it marks + // platforms that don't support advisory file locking on tmpfs: the BSD + // family (including all Apple targets, which are BSD-derived) plus + // Redox. Computed directly instead of pulling in the `cfg_aliases` + // crate for a single derived flag. + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let shm_external_lockfile = matches!( + target_os.as_str(), + "freebsd" + | "dragonfly" + | "netbsd" + | "openbsd" + | "ios" + | "macos" + | "watchos" + | "tvos" + | "visionos" + | "redox" + ); - // we use this alias to detect platforms that - // don't support advisory file locking on tmpfs - shm_external_lockfile: { any(bsd, target_os = "redox") }, - } - - println!("cargo:rustc-check-cfg=cfg(apple_targets)"); - println!("cargo:rustc-check-cfg=cfg(bsd)"); println!("cargo:rustc-check-cfg=cfg(shm_external_lockfile)"); + if shm_external_lockfile { + println!("cargo:rustc-cfg=shm_external_lockfile"); + } }