|
@ -1,4 +1,5 @@ |
|
|
use std::process::Command; |
|
|
use std::process::Command; |
|
|
|
|
|
use std::env; |
|
|
|
|
|
|
|
|
fn main() { |
|
|
fn main() { |
|
|
#[cfg(all(feature = "sqlite", feature = "mysql"))] |
|
|
#[cfg(all(feature = "sqlite", feature = "mysql"))] |
|
@ -11,8 +12,13 @@ fn main() { |
|
|
#[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgresql")))] |
|
|
#[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"); |
|
|
compile_error!("You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite"); |
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
read_git_info().ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
fn run(args: &[&str]) -> Result<String, std::io::Error> { |
|
|
fn run(args: &[&str]) -> Result<String, std::io::Error> { |
|
|
let out = Command::new(args[0]).args(&args[1..]).output()?; |
|
|
let out = Command::new(args[0]).args(&args[1..]).output()?; |
|
@ -54,14 +60,16 @@ fn read_git_info() -> Result<(), std::io::Error> { |
|
|
} else { |
|
|
} else { |
|
|
format!("{}-{}", last_tag, rev_short) |
|
|
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:
|
|
|
// To access these values, use:
|
|
|
// env!("GIT_EXACT_TAG")
|
|
|
// env!("GIT_EXACT_TAG")
|
|
|
// env!("GIT_LAST_TAG")
|
|
|
// env!("GIT_LAST_TAG")
|
|
|
// env!("GIT_BRANCH")
|
|
|
// env!("GIT_BRANCH")
|
|
|
// env!("GIT_REV")
|
|
|
// env!("GIT_REV")
|
|
|
// env!("GIT_VERSION")
|
|
|
// env!("BWRS_VERSION")
|
|
|
|
|
|
|
|
|
Ok(()) |
|
|
Ok(()) |
|
|
} |
|
|
} |
|
|