Skip to content

Commit

Permalink
using cfg(target_os) in build scripts is *wrong*
Browse files Browse the repository at this point in the history
  • Loading branch information
maan2003 committed Jul 6, 2021
1 parent b41eb58 commit 229a3e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions druid-shell/Cargo.toml
Expand Up @@ -90,10 +90,6 @@ gtk-sys = { version = "0.10.0", optional = true }
nix = { version = "0.18.0", optional = true }
x11rb = { version = "0.8.0", features = ["allow-unsafe-code", "present", "render", "randr", "xfixes", "xkb", "resource_manager", "cursor"], optional = true }

[target.'cfg(target_os="linux")'.build-dependencies]
bindgen = {version = "0.58", optional = true}
pkg-config = { version = "0.3", optional = true }

[target.'cfg(target_arch="wasm32")'.dependencies]
wasm-bindgen = "0.2.67"
js-sys = "0.3.44"
Expand All @@ -108,3 +104,7 @@ static_assertions = "1.1.0"
test-env-log = { version = "0.2.5", features = ["trace"], default-features = false }
tracing-subscriber = "0.2.15"
unicode-segmentation = "1.7.0"

[build-dependencies]
bindgen = {version = "0.58", optional = true}
pkg-config = { version = "0.3", optional = true }
8 changes: 6 additions & 2 deletions druid-shell/build.rs
@@ -1,12 +1,16 @@
#[cfg(not(all(target_os = "linux", feature = "x11")))]
#[cfg(not(feature = "x11"))]
fn main() {}

#[cfg(all(target_os = "linux", feature = "x11"))]
#[cfg(feature = "x11")]
fn main() {
use pkg_config::probe_library;
use std::env;
use std::path::PathBuf;

if env::var("CARGO_CFG_TARGET_OS").unwrap() != "linux" {
return;
}

probe_library("xkbcommon").unwrap();
probe_library("xkbcommon-x11").unwrap();

Expand Down

0 comments on commit 229a3e1

Please sign in to comment.