#![doc = include_str!("../README.md")]
use std::env;
use std::path::Path;
use std::process::Command;
pub fn compile_resources<P: AsRef<Path>>(source_dir: P, gresource: &str, target: &str) {
let out_dir = env::var("OUT_DIR").unwrap();
let status = Command::new("glib-compile-resources")
.arg("--sourcedir")
.arg(source_dir.as_ref())
.arg("--target")
.arg(&format!("{out_dir}/{target}"))
.arg(gresource)
.status()
.unwrap();
assert!(
status.success(),
"glib-compile-resources failed with exit status {status}",
);
println!("cargo:rerun-if-changed={gresource}");
let output = Command::new("glib-compile-resources")
.arg("--sourcedir")
.arg(source_dir.as_ref())
.arg("--generate-dependencies")
.arg(gresource)
.output()
.unwrap()
.stdout;
let output = String::from_utf8(output).unwrap();
for dep in output.split_whitespace() {
println!("cargo:rerun-if-changed={dep}");
}
}