xonecas.io
8447
Co

conveyor / files

conveyor / crates / conveyor-widgets / build.rs

718 bytes
1//! Compiles the user's widget library: every widgets/<name>.rs becomes a module.
2include!("../../templates/library/gen.rs");
3
4fn main() {
5    println!("cargo:rerun-if-env-changed=CONVEYOR_LIBRARY");
6    let home = std::path::PathBuf::from(std::env::var("HOME").unwrap());
7    let lib = std::env::var("CONVEYOR_LIBRARY").map(std::path::PathBuf::from)
8        .unwrap_or_else(|_| home.join(".local/share/conveyor/library"));
9    // Before conveyord has created the library, build with the empty template.
10    let lib = if lib.join("api.rs").exists() { lib } else { std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../templates/library") };
11    generate_widgets(&lib, Some("pub use conveyor_app::api;"));
12}