mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Make dns-sd optional
This commit is contained in:
parent
0984ad0bf0
commit
38351c9a87
6 changed files with 47 additions and 7 deletions
|
@ -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
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
29
src/zeroconf.rs
Normal file
29
src/zeroconf.rs
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue