diff --git a/.travis.yml b/.travis.yml index 546eb382..59653ece 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,5 @@ before_install: install: - cargo install --git https://github.com/stepancheg/rust-protobuf --rev 921c69b protobuf script: - - cargo build --verbose - - cargo test --verbose + - cargo build --no-default-features --verbose + - cargo test --no-default-features --verbose diff --git a/Cargo.lock b/Cargo.lock index 3e24e36a..9679b2e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = "0.1.0" dependencies = [ "bit-set 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "dns-sd 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "dns-sd 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "eventual 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "json_macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -80,8 +80,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dns-sd" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "encoding" diff --git a/Cargo.toml b/Cargo.toml index 0a4596f7..3023f32e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ path = "protocol" [dependencies] bit-set = "~0.2.0" byteorder = "~0.4.2" -dns-sd = "~0.1.0" eventual = "~0.1.5" getopts = "~0.2.14" json_macros = "~0.2.6" @@ -35,6 +34,10 @@ tempfile = "~1.1.3" url = "~0.5.2" vorbis = "~0.0.13" +[dependencies.dns-sd] +version = "~0.1.1" +optional = true + [dependencies.protobuf_macros] git = "https://github.com/plietar/rust-protobuf-macros.git" [dependencies.shannon] @@ -45,3 +48,5 @@ git = "https://github.com/mvdnes/portaudio-rs" [build-dependencies] vergen = "~0.0.16" +[features] +default = ["dns-sd"] diff --git a/src/discovery.rs b/src/discovery.rs index c3fc8e3e..bc1528b3 100644 --- a/src/discovery.rs +++ b/src/discovery.rs @@ -1,7 +1,7 @@ use crypto; use crypto::mac::Mac; use crypto::digest::Digest; -use dns_sd::DNSService; +use zeroconf::DNSService; use tiny_http::{Method, Response, ResponseBox, Server}; use num::BigUint; use url; diff --git a/src/lib.rs b/src/lib.rs index 8710f0f3..446e84f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,6 @@ extern crate bit_set; extern crate byteorder; extern crate crypto; -extern crate dns_sd; extern crate eventual; extern crate num; extern crate portaudio; @@ -23,6 +22,9 @@ extern crate tempfile; extern crate url; extern crate vorbis; +#[cfg(feature = "dns-sd")] +extern crate dns_sd; + extern crate librespot_protocol; #[macro_use] pub mod util; @@ -39,4 +41,5 @@ pub mod player; pub mod session; pub mod spirc; mod stream; +mod zeroconf; diff --git a/src/zeroconf.rs b/src/zeroconf.rs new file mode 100644 index 00000000..a89f96b4 --- /dev/null +++ b/src/zeroconf.rs @@ -0,0 +1,29 @@ +#[cfg(feature = "dns-sd")] +pub use dns_sd::*; +#[cfg(not(feature = "dns-sd"))] +pub use self::stub::*; + +#[cfg(not(feature = "dns-sd"))] +pub mod stub { + use std; + use std::io::Write; + + #[derive(Debug)] + pub struct DNSService; + + pub type DNSError = (); + + impl DNSService { + pub fn register(_: Option<&str>, + _: &str, + _: Option<&str>, + _: Option<&str>, + _: u16, + _: &[&str]) + -> std::result::Result { + writeln!(&mut std::io::stderr(), + "WARNING: dns-sd is not enabled. Service will probably not be visible").unwrap(); + Ok(DNSService) + } + } +}