use std::{env, io, fs, path::Path, process::Command}; const SCHEMA_NAME: &'static str = "im.zander.SimpleLogin.gschema.xml"; fn main() -> io::Result<()> { println!("cargo:rerun-if-changed=data/{}", SCHEMA_NAME); #[cfg(debug_assertions)] { let out_dir = env::var("OUT_DIR").unwrap(); let source_path = Path::new("data/").join(SCHEMA_NAME); let compile_dir = Path::new(&out_dir).join("schemas"); let compile_path = compile_dir.join(SCHEMA_NAME); eprintln!("Creating \"{}\"...", compile_dir.display()); fs::create_dir_all(&compile_dir)?; eprintln!( "Copping \"{}\" to \"{}\"...", source_path.display(), compile_path.display() ); fs::copy(source_path, &compile_path)?; eprintln!("Compiling schemas..."); let status = Command::new("glib-compile-schemas") .args(["--strict", compile_dir.to_str().unwrap()]) .status()?; if !status.success() { panic!("failed to compile schemas"); } } Ok(()) }