-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
24 lines (21 loc) · 930 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
fn main() {
let pre_release = if let Ok(pre_release) = std::env::var("CI_PKG_VERSION_PRE_RELEASE") {
"-".to_owned() + &pre_release
} else {
"".to_owned()
};
let build = if let Ok(build) = std::env::var("CI_PKG_VERSION_BUILD") {
"+".to_owned() + &build
} else {
"".to_owned()
};
// If we set CARGO_PKG_VERSION this way, then it will override the default value, which is
// taken from the `version` in Cargo.toml or from an override in .cargo/config.toml
let version_override = format!("{}{}{}", env!("CARGO_PKG_VERSION"), pre_release, build);
if !version_override.is_empty() {
println!("cargo:rustc-env=CARGO_PKG_VERSION={}", version_override);
}
println!("cargo:rerun-if-env-changed=CI_PKG_VERSION_PRE_RELEASE");
println!("cargo:rerun-if-env-changed=CI_PKG_VERSION_BUILD");
println!("cargo:rerun-if-changed=.cargo/config.toml");
}