1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#[cfg(not(feature = "dox"))]
use std::io;
#[cfg(not(feature = "dox"))]
use std::io::prelude::*;
#[cfg(not(feature = "dox"))]
use std::process;
#[cfg(feature = "dox")]
fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
let _ = writeln!(io::stderr(), "{}", s);
process::exit(1);
}
// It's safe to assume we can call this because we found the library OK
// in find()
check_features();
}
#[cfg(not(feature = "dox"))]
fn check_features() {
const PKG_CONFIG_PACKAGE: &str = "gdk-3.0";
// The pkg-config file defines a `targets` variable listing the
// various backends that gdk was compiled for.
// We extract that and create gdk_backend="x11" and the like
// as configuration variables.
// In addition we publish this as a variable which cargo will
// provide to immediate dependents of this crate as an environment
// variable for their `build.rs` runs called DEP_GDK_BACKENDS
// For reference, the backend set at time of writing consists of:
// x11 win32 quartz broadway wayland
if let Ok(targets) = pkg_config::get_variable(PKG_CONFIG_PACKAGE, "targets") {
println!("cargo:backends={}", targets);
for target in targets.split_whitespace() {
println!("cargo:rustc-cfg=gdk_backend=\"{}\"", target);
}
}
}