-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
31 lines (30 loc) · 977 Bytes
/
build.rs
File metadata and controls
31 lines (30 loc) · 977 Bytes
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
use std::{env, fs, path::Path};
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("constants.rs");
let git_v = if env::var("R2T_GIT_VERSION").is_ok() {
env::var("R2T_GIT_VERSION").unwrap().to_uppercase()
} else {
git_version::git_version!(
args = ["--abbrev=8", "--always", "--dirty=*"],
fallback = "unknown"
)
.to_uppercase()
};
let version = format!(
"{}-{git_v}-{}",
env!("CARGO_PKG_VERSION"),
rustc_version::version().unwrap()
);
let full_version = format!(
"{version}-{}-{}-{}",
build_target::target_arch().unwrap(),
build_target::target_os().unwrap(),
build_target::target_env().unwrap(),
);
fs::write(
dest_path,
format!("pub const R2T_VERSION: &str = \"{version}\";\npub const R2T_FULL_VERSION: &str = \"{full_version}\";\n"),
)
.unwrap();
}