-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathbuild.rs
52 lines (46 loc) · 1.74 KB
/
build.rs
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
43
44
45
46
47
48
49
50
51
52
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
#[cfg(not(docsrs))]
use std::io;
#[cfg(not(docsrs))]
use std::io::prelude::*;
#[cfg(not(docsrs))]
use std::process;
#[cfg(docsrs)]
fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(docsrs))]
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(docsrs))]
fn check_features() {
const PKG_CONFIG_PACKAGE: &str = "gtk4";
// The pkg-config file defines a `targets` variable listing the
// various backends that GTK 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 macos broadway wayland
if let Ok(targets) = pkg_config::get_variable(PKG_CONFIG_PACKAGE, "targets") {
println!("cargo:backends={targets}");
for target in targets.split_whitespace() {
// For whatever reasons,calling pkg-config --variable=targets gtk4
// returns broadway\ wayland\ x11. So we drop those from the configured
// gtk_backend
println!(
"cargo:rustc-cfg=gdk_backend=\"{}\"",
target.trim_end_matches('\\')
);
}
}
}