2020-07-05 13:24:39 +03:00
|
|
|
use std::{env, error::Error, path::Path, process::Command};
|
2020-07-02 09:24:35 +03:00
|
|
|
|
|
|
|
fn main() {
|
2020-07-05 13:24:39 +03:00
|
|
|
let version = if Path::new(".git").exists() {
|
|
|
|
get_git_version().unwrap_or_else(|_| String::from("unknown"))
|
|
|
|
} else {
|
|
|
|
env!("CARGO_PKG_VERSION").to_string()
|
|
|
|
};
|
2020-07-02 09:24:35 +03:00
|
|
|
|
2022-02-17 01:08:21 +03:00
|
|
|
println!("cargo:rustc-env=VERSION={version}");
|
2020-07-02 09:24:35 +03:00
|
|
|
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
|
|
|
|
}
|
|
|
|
|
2020-07-05 13:24:39 +03:00
|
|
|
fn get_git_version() -> Result<String, Box<dyn Error>> {
|
2022-01-24 10:26:46 +03:00
|
|
|
Ok(String::from_utf8(Command::new("./contrib/git-version.sh").output()?.stdout)?)
|
2020-07-02 09:24:35 +03:00
|
|
|
}
|