Skip to content

Commit

Permalink
Make dns-sd optional
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Jan 2, 2016
1 parent 0984ad0 commit 38351c9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand All @@ -45,3 +48,5 @@ git = "https://github.com/mvdnes/portaudio-rs"
[build-dependencies]
vergen = "~0.0.16"

[features]
default = ["dns-sd"]
2 changes: 1 addition & 1 deletion src/discovery.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -39,4 +41,5 @@ pub mod player;
pub mod session;
pub mod spirc;
mod stream;
mod zeroconf;

29 changes: 29 additions & 0 deletions src/zeroconf.rs
Original file line number Diff line number Diff line change
@@ -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<DNSService, DNSError> {
writeln!(&mut std::io::stderr(),
"WARNING: dns-sd is not enabled. Service will probably not be visible").unwrap();
Ok(DNSService)
}
}
}

0 comments on commit 38351c9

Please sign in to comment.