Include build profile in the displayed version information

Example output from -V for a debug build is:
librespot 0.3.0 832889b (Built on 2021-10-14, Build ID: ANJrycbG, Profile: debug)
This commit is contained in:
Nick Steel 2021-10-14 11:57:33 +01:00
parent d99581aeb7
commit 3b51a5dc23
2 changed files with 16 additions and 13 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Include build profile in the displayed version information
### Fixed ### Fixed
- [connect] Partly fix behavior after last track of an album/playlist - [connect] Partly fix behavior after last track of an album/playlist

View file

@ -160,14 +160,20 @@ pub fn parse_file_size(input: &str) -> Result<u64, ParseFileSizeError> {
Ok((num * base.pow(exponent) as f64) as u64) Ok((num * base.pow(exponent) as f64) as u64)
} }
fn print_version() { fn get_version_string() -> String {
println!( #[cfg(debug_assertions)]
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id})", const BUILD_PROFILE: &str = "debug";
#[cfg(not(debug_assertions))]
const BUILD_PROFILE: &str = "release";
format!(
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id}, Profile: {build_profile})",
semver = version::SEMVER, semver = version::SEMVER,
sha = version::SHA_SHORT, sha = version::SHA_SHORT,
build_date = version::BUILD_DATE, build_date = version::BUILD_DATE,
build_id = version::BUILD_ID build_id = version::BUILD_ID,
); build_profile = BUILD_PROFILE
)
} }
struct Setup { struct Setup {
@ -438,20 +444,14 @@ fn get_setup(args: &[String]) -> Setup {
} }
if matches.opt_present(VERSION) { if matches.opt_present(VERSION) {
print_version(); println!("{}", get_version_string());
exit(0); exit(0);
} }
let verbose = matches.opt_present(VERBOSE); let verbose = matches.opt_present(VERBOSE);
setup_logging(verbose); setup_logging(verbose);
info!( info!("{}", get_version_string());
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id})",
semver = version::SEMVER,
sha = version::SHA_SHORT,
build_date = version::BUILD_DATE,
build_id = version::BUILD_ID
);
let backend_name = matches.opt_str(BACKEND); let backend_name = matches.opt_str(BACKEND);
if backend_name == Some("?".into()) { if backend_name == Some("?".into()) {