2020-06-12 16:20:02 +00:00
|
|
|
use std::env;
|
|
|
|
use std::path::Path;
|
2020-06-12 10:41:20 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
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 16:20:02 +00:00
|
|
|
let codegen_bin = manifest_dir.join("../target/debug/lvgl-codegen");
|
2020-06-12 10:41:20 +00:00
|
|
|
|
2020-06-12 16:20:02 +00:00
|
|
|
println!("rerun-if-changed={}", codegen_bin.to_string_lossy());
|
|
|
|
|
|
|
|
if env::var("LVGL_FORCE_CODEGEN").is_ok() || !widgets_rs_path.exists() {
|
2020-06-12 11:23:16 +00:00
|
|
|
println!("Generating `src/widgets/generated.rs`");
|
2020-06-12 16:20:02 +00:00
|
|
|
let status = Command::new(codegen_bin)
|
2020-06-12 11:23:16 +00:00
|
|
|
.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
|
|
|
}
|