Skip to content

Commit b125659

Browse files
authored
Merge pull request #865 from kingosticks/feature/log-build-profile
Add build profile to displayed version info
2 parents d99581a + 3b51a5d commit b125659

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- Include build profile in the displayed version information
12+
1013
### Fixed
1114
- [connect] Partly fix behavior after last track of an album/playlist
1215

src/main.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,20 @@ pub fn parse_file_size(input: &str) -> Result<u64, ParseFileSizeError> {
160160
Ok((num * base.pow(exponent) as f64) as u64)
161161
}
162162

163-
fn print_version() {
164-
println!(
165-
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id})",
163+
fn get_version_string() -> String {
164+
#[cfg(debug_assertions)]
165+
const BUILD_PROFILE: &str = "debug";
166+
#[cfg(not(debug_assertions))]
167+
const BUILD_PROFILE: &str = "release";
168+
169+
format!(
170+
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id}, Profile: {build_profile})",
166171
semver = version::SEMVER,
167172
sha = version::SHA_SHORT,
168173
build_date = version::BUILD_DATE,
169-
build_id = version::BUILD_ID
170-
);
174+
build_id = version::BUILD_ID,
175+
build_profile = BUILD_PROFILE
176+
)
171177
}
172178

173179
struct Setup {
@@ -438,20 +444,14 @@ fn get_setup(args: &[String]) -> Setup {
438444
}
439445

440446
if matches.opt_present(VERSION) {
441-
print_version();
447+
println!("{}", get_version_string());
442448
exit(0);
443449
}
444450

445451
let verbose = matches.opt_present(VERBOSE);
446452
setup_logging(verbose);
447453

448-
info!(
449-
"librespot {semver} {sha} (Built on {build_date}, Build ID: {build_id})",
450-
semver = version::SEMVER,
451-
sha = version::SHA_SHORT,
452-
build_date = version::BUILD_DATE,
453-
build_id = version::BUILD_ID
454-
);
454+
info!("{}", get_version_string());
455455

456456
let backend_name = matches.opt_str(BACKEND);
457457
if backend_name == Some("?".into()) {

0 commit comments

Comments
 (0)