-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
34 lines (26 loc) · 819 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use cmd_lib::run_fun;
fn main() {
slint_build::compile("ui/appwindow.slint").unwrap();
#[cfg(target_os = "windows")]
{
set_win_info();
}
let _ = write_app_version();
}
fn write_app_version() -> Result<(), Box<dyn std::error::Error>> {
let tags = run_fun!(git describe --tags --abbrev=0)?
.split(char::is_whitespace)
.map(|s| s.to_owned())
.collect::<Vec<String>>();
let output = if let Some(version) = tags.last() {
format!(r#"pub static VERSION: &str = "{}";"#, version)
} else {
format!(r#"pub static VERSION: &str = "{}";"#, "0.0.1")
};
let _ = std::fs::write("src/version.rs", output);
Ok(())
}
#[cfg(target_os = "windows")]
fn set_win_info() {
embed_resource::compile("./win/icon.rc", embed_resource::NONE);
}