diff --git a/build.rs b/build.rs index ff64898..3c836b3 100644 --- a/build.rs +++ b/build.rs @@ -21,7 +21,7 @@ fn codegen() { fn codegen() { } fn main() { - vergen::vergen(vergen::SHORT_SHA).unwrap(); + vergen::vergen(vergen::OutputFns::all()).unwrap(); codegen(); } diff --git a/src/lib.in.rs b/src/lib.in.rs index 4f1c20a..f820f4d 100644 --- a/src/lib.in.rs +++ b/src/lib.in.rs @@ -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; diff --git a/src/lib.rs b/src/lib.rs index 8d94dec..b397dcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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")); diff --git a/src/main.rs b/src/main.rs index c5b1a25..d5916b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 = 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, }; diff --git a/src/session.rs b/src/session.rs index c9ed512..13e8702 100644 --- a/src/session.rs +++ b/src/session.rs @@ -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(), diff --git a/src/spirc.rs b/src/spirc.rs index 8fa49ed..66b2858 100644 --- a/src/spirc.rs +++ b/src/spirc.rs @@ -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, diff --git a/src/util/mod.rs b/src/util/mod.rs index d353ba6..478cf72 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -39,20 +39,6 @@ pub fn rand_vec(rng: &mut G, size: usize) -> Vec { 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);