extern crate fs_utils; use std::process::Command; use std::str::from_utf8; use std::env; use std::path::Path; use fs_utils::*; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let path = Path::new(&manifest_dir).join("resources"); let path_res = copy::copy_directory(&path, &out_dir); let path = match path_res { Ok(path) => path, Err(err) => { match err { copy::Error::DestinationDirectoryExists(dir) => dir, _ => panic!("failed to copy resources dir: {}", err), } } }; let qml_lib_build_output = Command::new("sh") .current_dir(&path) .arg("build-resources-lib.sh") .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); if !qml_lib_build_output.status.success() { panic!("Cannot build qml lib:\n{:#?}\n{:#?}", to_utf(&qml_lib_build_output.stdout), to_utf(&qml_lib_build_output.stderr)); } let fluid_build_output = Command::new("sh") .arg("build-fluid.sh") .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); if !fluid_build_output.status.success() { panic!("Cannot build qml lib:\n{:#?}\n{:#?}", to_utf(&fluid_build_output.stdout), to_utf(&fluid_build_output.stderr)); } println!("cargo:rerun-if-changed=resources"); println!("cargo:rustc-link-search=native={}", path.display()); println!("cargo:rustc-link-lib=static=resources"); println!("cargo:rustc-link-lib=dylib=Qt5Svg"); } fn to_utf(buf: &[u8]) -> &str { match from_utf8(buf) { Ok(v) => v, Err(e) => panic!("Invalid UTF-8 sequence: {}", e), } }