2020-06-12 10:41:20 +00:00
|
|
|
use std::ffi::OsStr;
|
2020-06-12 11:23:16 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2020-06-12 10:41:20 +00:00
|
|
|
use std::process::Command;
|
|
|
|
use std::{env, fs, path};
|
|
|
|
|
|
|
|
fn main() {
|
2020-06-12 11:23:16 +00:00
|
|
|
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
|
|
let widgets_rs_path = manifest_dir.join("src/widgets/generated.rs");
|
2020-06-12 10:41:20 +00:00
|
|
|
|
2020-06-12 11:23:16 +00:00
|
|
|
if !widgets_rs_path.exists() {
|
|
|
|
println!("Generating `src/widgets/generated.rs`");
|
|
|
|
let status = Command::new(manifest_dir.join("../target/debug/lvgl-codegen"))
|
|
|
|
.spawn()
|
|
|
|
.unwrap_or_else(|_| {
|
2020-06-12 10:41:20 +00:00
|
|
|
panic!(
|
2020-06-12 11:23:16 +00:00
|
|
|
"Code generation failed because no codegen executable was found. \
|
|
|
|
Please run `cargo build --package lvgl-codegen` and then try again.",
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.wait()
|
|
|
|
.unwrap();
|
|
|
|
if !status.success() {
|
|
|
|
panic!("Code generation failed");
|
|
|
|
}
|
|
|
|
}
|
2020-06-12 10:41:20 +00:00
|
|
|
}
|