forked from kdschlosser/EventGhost-x64-Python3.5
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
55 lines (45 loc) · 1.87 KB
/
build.rs
File metadata and controls
55 lines (45 loc) · 1.87 KB
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
53
54
55
use std::process::Command;
use std::env;
use std::path::PathBuf;
fn main() {
if cfg!(target_os = "windows") {
// Tell cargo to look for GTK4 in the MSYS2 installation directory
println!("cargo:rustc-link-search=C:/msys64/mingw64/lib");
println!("cargo:rustc-env=PKG_CONFIG_PATH=C:/msys64/mingw64/lib/pkgconfig");
// Tell pkg-config where to find .pc files
if std::env::var("PKG_CONFIG_PATH").is_err() {
std::env::set_var("PKG_CONFIG_PATH", "C:/msys64/mingw64/lib/pkgconfig");
}
}
// Detect GTK4
pkg_config::Config::new()
.atleast_version("4.6")
.probe("gtk4")
.unwrap();
// Get the manifest directory (where Cargo.toml is)
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut src_path = PathBuf::from(&manifest_dir);
src_path.push("src");
// Change to the src directory before running glib-compile-resources
env::set_current_dir(&src_path).expect("Failed to change to src directory");
// Compile the GResource file
let status = Command::new("glib-compile-resources")
.args(&[
"--target=resources.gresource",
"resources.gresource.xml",
])
.status()
.expect("Failed to compile resources");
if !status.success() {
panic!("Failed to compile GResource file");
}
println!("cargo:rerun-if-changed=src/resources.gresource.xml");
println!("cargo:rerun-if-changed=src/images/");
// Create plugins directory in target directory
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let plugins_dir = out_dir.join("plugins");
std::fs::create_dir_all(&plugins_dir).unwrap();
// Tell cargo to rerun if plugin source changes
println!("cargo:rerun-if-changed=src/plugins/logger/mod.rs");
println!("cargo:rerun-if-changed=plugins/logger/Cargo.toml");
}