aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorDaniel García <[email protected]>2020-03-22 16:13:34 +0100
committerDaniel García <[email protected]>2020-03-22 16:13:34 +0100
commit7a6a3e4160d2a472febd2122248f21ae7dfb0c90 (patch)
treeec3619ba7fc8512e89050768adbe84b7074b04d9 /build.rs
parent94341f9f3f273eaa14b058c310f39dd6536f84cb (diff)
downloadvaultwarden-7a6a3e4160d2a472febd2122248f21ae7dfb0c90.tar.gz
vaultwarden-7a6a3e4160d2a472febd2122248f21ae7dfb0c90.zip
Set the cargo version and allow changing it during build time with BWRS_VERSION.
Also renamed GIT_VERSION because that's not the only source anymore.
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/build.rs b/build.rs
index ac92dbd9..0eeb4767 100644
--- a/build.rs
+++ b/build.rs
@@ -1,4 +1,5 @@
use std::process::Command;
+use std::env;
fn main() {
#[cfg(all(feature = "sqlite", feature = "mysql"))]
@@ -10,8 +11,13 @@ fn main() {
#[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgresql")))]
compile_error!("You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite");
-
- read_git_info().ok();
+
+ if let Ok(version) = env::var("BWRS_VERSION") {
+ println!("cargo:rustc-env=BWRS_VERSION={}", version);
+ println!("cargo:rustc-env=CARGO_PKG_VERSION={}", version);
+ } else {
+ read_git_info().ok();
+ }
}
fn run(args: &[&str]) -> Result<String, std::io::Error> {
@@ -54,14 +60,16 @@ fn read_git_info() -> Result<(), std::io::Error> {
} else {
format!("{}-{}", last_tag, rev_short)
};
- println!("cargo:rustc-env=GIT_VERSION={}", version);
+
+ println!("cargo:rustc-env=BWRS_VERSION={}", version);
+ println!("cargo:rustc-env=CARGO_PKG_VERSION={}", version);
// To access these values, use:
// env!("GIT_EXACT_TAG")
// env!("GIT_LAST_TAG")
// env!("GIT_BRANCH")
// env!("GIT_REV")
- // env!("GIT_VERSION")
+ // env!("BWRS_VERSION")
Ok(())
}