-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
39 lines (32 loc) · 1005 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
35
36
37
38
39
fn report_build_profile() {
println!(
"cargo:rustc-env=BUILD_PROFILE={}",
std::env::var("PROFILE").unwrap()
);
}
fn report_enabled_features() {
let mut enabled_features: Vec<&str> = Vec::new();
if enabled_features.is_empty() {
enabled_features.push("none");
}
println!(
"cargo:rustc-env=BUILD_FEATURES={}",
enabled_features.join(",")
);
}
fn report_repository_version() {
let git_describe = std::process::Command::new("git")
.args(["describe", "--always", "--dirty", "--long", "--tags"])
.output()
.unwrap();
let long_version = String::from_utf8(git_describe.stdout).unwrap();
println!("cargo:rustc-env=REPO_VERSION={}", long_version);
}
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=migrations");
println!("cargo:rerun-if-changed=templates");
report_repository_version();
report_build_profile();
report_enabled_features();
}