Print librespot version on startup.

This commit is contained in:
Paul Lietar 2016-03-17 03:31:57 +00:00
parent 0770f6ce61
commit 230c891df0
7 changed files with 28 additions and 28 deletions

View file

@ -21,7 +21,7 @@ fn codegen() {
fn codegen() { }
fn main() {
vergen::vergen(vergen::SHORT_SHA).unwrap();
vergen::vergen(vergen::OutputFns::all()).unwrap();
codegen();
}

View file

@ -1,5 +1,6 @@
#[macro_use] pub mod util;
mod album_cover;
pub mod apresolve;
mod audio_decrypt;
mod audio_file;
mod audio_key;
@ -15,6 +16,5 @@ pub mod session;
pub mod spirc;
pub mod link;
pub mod stream;
pub mod apresolve;
pub use album_cover::get_album_cover;

View file

@ -39,6 +39,15 @@ extern crate openssl;
extern crate librespot_protocol as protocol;
// This doesn't play nice with syntex, so place it here
pub mod version {
include!(concat!(env!("OUT_DIR"), "/version.rs"));
pub fn version_string() -> String {
format!("librespot-{}", short_sha())
}
}
#[cfg(feature = "with-syntex")]
include!(concat!(env!("OUT_DIR"), "/lib.rs"));

View file

@ -15,7 +15,7 @@ use librespot::cache::{Cache, DefaultCache, NoCache};
use librespot::player::Player;
use librespot::session::{Bitrate, Config, Session};
use librespot::spirc::SpircManager;
use librespot::util::version::version_string;
use librespot::version;
static PASSWORD_ENV_NAME: &'static str = "SPOTIFY_PASSWORD";
@ -30,6 +30,11 @@ static APPKEY: Option<&'static [u8]> = Some(include_bytes!(concat!(env!("CARGO_M
static APPKEY: Option<&'static [u8]> = None;
fn main() {
println!("librespot {} ({}). Built on {}.",
version::short_sha(),
version::commit_date(),
version::short_now());
let args: Vec<String> = std::env::args().collect();
let program = args[0].clone();
@ -86,7 +91,7 @@ fn main() {
let config = Config {
application_key: appkey,
user_agent: version_string(),
user_agent: version::version_string(),
device_name: name,
bitrate: bitrate,
};

View file

@ -25,6 +25,7 @@ use metadata::{MetadataManager, MetadataRef, MetadataTrait};
use protocol;
use stream::{ChannelId, StreamManager, StreamEvent, StreamError};
use util::{self, SpotifyId, FileId, ReadSeek};
use version;
pub enum Bitrate {
Bitrate96,
@ -192,7 +193,7 @@ impl Session {
system_information_string: "librespot".to_owned(),
device_id: self.device_id().to_owned(),
},
version_string: util::version::version_string(),
version_string: version::version_string(),
appkey => {
version: self.config().application_key[0] as u32,
devkey: self.config().application_key[0x1..0x81].to_vec(),

View file

@ -1,17 +1,16 @@
use eventual::Async;
use protobuf::{self, Message, RepeatedField};
use util;
use session::Session;
use util::SpotifyId;
use util::version::version_string;
use mercury::{MercuryRequest, MercuryMethod};
use player::{Player, PlayerState};
use std::borrow::Cow;
use std::sync::{Mutex, Arc};
use std::collections::HashMap;
use mercury::{MercuryRequest, MercuryMethod};
use player::{Player, PlayerState};
use session::Session;
use util;
use util::SpotifyId;
use version;
use protocol;
pub use protocol::spirc::{PlayStatus, MessageType};
@ -323,7 +322,7 @@ impl SpircInternal {
fn device_state(&self, player_state: &PlayerState) -> protocol::spirc::DeviceState {
protobuf_init!(protocol::spirc::DeviceState::new(), {
sw_version: version_string(),
sw_version: version::version_string(),
is_active: self.is_active,
can_play: self.can_play,
volume: player_state.volume() as u32,

View file

@ -39,20 +39,6 @@ pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
rng.gen_iter().take(size).collect()
}
pub mod version {
// FIXME: Unfortunately, this doesn't work when using syntex
// And for some reason, cfg-gating it doesn't work
//include!(concat!(env!("OUT_DIR"), "/version.rs"));
pub fn short_sha() -> String {
"unknown".to_owned()
}
pub fn version_string() -> String {
format!("librespot-{}", short_sha())
}
}
pub fn hexdump(data: &[u8]) {
for b in data.iter() {
eprint!("{:02X} ", b);