mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Support building with rust stable, using syntex.
This commit is contained in:
parent
5059432090
commit
d27c4ca752
13 changed files with 205 additions and 92 deletions
10
.travis.yml
10
.travis.yml
|
@ -1,5 +1,7 @@
|
||||||
language: rust
|
language: rust
|
||||||
rust:
|
rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
|
@ -10,4 +12,10 @@ addons:
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo build --verbose
|
- cargo build --verbose
|
||||||
- cargo test --verbose
|
- cargo build --no-default-features --verbose
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
|
|
89
Cargo.lock
generated
89
Cargo.lock
generated
|
@ -7,18 +7,19 @@ dependencies = [
|
||||||
"dns-sd 0.1.1 (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)",
|
"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)",
|
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"json_macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"json_macros 0.3.0 (git+https://github.com/plietar/json_macros)",
|
||||||
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"librespot-protocol 0.1.0",
|
"librespot-protocol 0.1.0",
|
||||||
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"portaudio 0.2.0 (git+https://github.com/mvdnes/portaudio-rs)",
|
"portaudio 0.2.0 (git+https://github.com/mvdnes/portaudio-rs)",
|
||||||
"protobuf 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"protobuf 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"protobuf_macros 0.2.0 (git+https://github.com/plietar/rust-protobuf-macros.git)",
|
"protobuf_macros 0.3.0 (git+https://github.com/plietar/rust-protobuf-macros)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rpassword 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rpassword 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"shannon 0.1.1 (git+https://github.com/plietar/rust-shannon.git)",
|
"shannon 0.1.1 (git+https://github.com/plietar/rust-shannon)",
|
||||||
|
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempfile 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempfile 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tiny_http 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tiny_http 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -36,6 +37,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
name = "aster"
|
name = "aster"
|
||||||
version = "0.13.1"
|
version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
|
@ -167,9 +171,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "json_macros"
|
name = "json_macros"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/plietar/json_macros#1aa21f6c1c08ac1e9d5b21447edd6c4f34f2a1dd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"quasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"quasi_codegen 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -200,7 +208,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
name = "librespot-protocol"
|
name = "librespot-protocol"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"mod_path 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"protobuf 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"protobuf 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"protobuf_build 0.1.1 (git+https://github.com/plietar/rust-protobuf-build.git)",
|
"protobuf_build 0.1.1 (git+https://github.com/plietar/rust-protobuf-build.git)",
|
||||||
]
|
]
|
||||||
|
@ -218,11 +225,6 @@ name = "matches"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mod_path"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num"
|
name = "num"
|
||||||
version = "0.1.31"
|
version = "0.1.31"
|
||||||
|
@ -284,10 +286,30 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "protobuf_macros"
|
name = "protobuf_macros"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/plietar/rust-protobuf-macros.git#5853fc344d506728fa497eaccb83f0a8a82f9150"
|
source = "git+https://github.com/plietar/rust-protobuf-macros#27e273a3b335a8a6a1c0139bb67d1fe4ba765b20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quasi"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quasi_codegen"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"aster 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -329,18 +351,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shannon"
|
name = "shannon"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/plietar/rust-shannon.git#ed87ffd2cf09a2a99871900e81ecfaaac117b790"
|
source = "git+https://github.com/plietar/rust-shannon#7000b3e49a53daaa890727ba2b2bd5a43cc4ffef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"shannon-sys 0.1.0 (git+https://github.com/plietar/rust-shannon.git)",
|
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"shannon-sys 0.1.0 (git+https://github.com/plietar/rust-shannon)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shannon-sys"
|
name = "shannon-sys"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/plietar/rust-shannon.git#ed87ffd2cf09a2a99871900e81ecfaaac117b790"
|
source = "git+https://github.com/plietar/rust-shannon#7000b3e49a53daaa890727ba2b2bd5a43cc4ffef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gcc 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gcc 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -352,6 +376,27 @@ dependencies = [
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syntex"
|
||||||
|
version = "0.29.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"syntex_syntax 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syntex_syntax"
|
||||||
|
version = "0.29.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -363,6 +408,15 @@ dependencies = [
|
||||||
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "term"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termios"
|
name = "termios"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -407,6 +461,11 @@ name = "unicode-normalization"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "0.2.38"
|
version = "0.2.38"
|
||||||
|
|
23
Cargo.toml
23
Cargo.toml
|
@ -20,7 +20,7 @@ bit-set = "~0.2.0"
|
||||||
byteorder = "~0.4.2"
|
byteorder = "~0.4.2"
|
||||||
eventual = "~0.1.5"
|
eventual = "~0.1.5"
|
||||||
getopts = "~0.2.14"
|
getopts = "~0.2.14"
|
||||||
json_macros = "~0.3.0"
|
#json_macros = "~0.3.0"
|
||||||
lazy_static = "~0.1.15"
|
lazy_static = "~0.1.15"
|
||||||
num = "~0.1.30"
|
num = "~0.1.30"
|
||||||
protobuf = "~1.0.15"
|
protobuf = "~1.0.15"
|
||||||
|
@ -34,20 +34,21 @@ tiny_http = "~0.5.1"
|
||||||
url = "~0.5.2"
|
url = "~0.5.2"
|
||||||
vorbis = "~0.0.14"
|
vorbis = "~0.0.14"
|
||||||
|
|
||||||
[dependencies.dns-sd]
|
dns-sd = { version = "~0.1.1", optional = true }
|
||||||
version = "~0.1.1"
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[dependencies.protobuf_macros]
|
portaudio = { git = "https://github.com/mvdnes/portaudio-rs" }
|
||||||
git = "https://github.com/plietar/rust-protobuf-macros.git"
|
|
||||||
[dependencies.shannon]
|
json_macros = { git = "https://github.com/plietar/json_macros" }
|
||||||
git = "https://github.com/plietar/rust-shannon.git"
|
protobuf_macros = { git = "https://github.com/plietar/rust-protobuf-macros" }
|
||||||
[dependencies.portaudio]
|
shannon = { git = "https://github.com/plietar/rust-shannon" }
|
||||||
git = "https://github.com/mvdnes/portaudio-rs"
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = "~0.1.0"
|
vergen = "~0.1.0"
|
||||||
|
syntex = { version = "*", optional = true }
|
||||||
|
protobuf_macros = { git = "https://github.com/plietar/rust-protobuf-macros" }
|
||||||
|
json_macros = { git = "https://github.com/plietar/json_macros" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
discovery = ["dns-sd"]
|
discovery = ["dns-sd"]
|
||||||
|
with-syntex = ["syntex", "protobuf_macros/with-syntex", "json_macros/with-syntex"]
|
||||||
|
default = ["with-syntex"]
|
||||||
|
|
21
build.rs
21
build.rs
|
@ -1,6 +1,27 @@
|
||||||
extern crate vergen;
|
extern crate vergen;
|
||||||
|
#[cfg(feature = "with-syntex")] extern crate syntex;
|
||||||
|
#[cfg(feature = "with-syntex")] extern crate json_macros;
|
||||||
|
#[cfg(feature = "with-syntex")] extern crate protobuf_macros;
|
||||||
|
|
||||||
|
#[cfg(feature = "with-syntex")]
|
||||||
|
fn codegen() {
|
||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
let mut registry = syntex::Registry::new();
|
||||||
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
|
||||||
|
json_macros::plugin_registrar(&mut registry);
|
||||||
|
protobuf_macros::plugin_registrar(&mut registry);
|
||||||
|
registry.expand("librespot", Path::new("src/lib.in.rs"), &out.join("lib.rs")).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "with-syntex"))]
|
||||||
|
fn codegen() { }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
vergen::vergen(vergen::SHORT_SHA).unwrap();
|
vergen::vergen(vergen::SHORT_SHA).unwrap();
|
||||||
|
codegen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ authors = ["Paul Liétar <paul@lietar.net>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mod_path = "~0.1.6"
|
|
||||||
protobuf = "~1.0.10"
|
protobuf = "~1.0.10"
|
||||||
|
|
||||||
[build-dependencies.protobuf_build]
|
[build-dependencies.protobuf_build]
|
||||||
|
|
|
@ -2,6 +2,8 @@ extern crate protobuf_build;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
@ -10,13 +12,31 @@ fn main() {
|
||||||
|
|
||||||
let mut compiler = protobuf_build::Compiler::new(&proto, &out);
|
let mut compiler = protobuf_build::Compiler::new(&proto, &out);
|
||||||
|
|
||||||
for file in &["keyexchange.proto",
|
let files = ["keyexchange",
|
||||||
"authentication.proto",
|
"authentication",
|
||||||
"mercury.proto",
|
"mercury",
|
||||||
"metadata.proto",
|
"metadata",
|
||||||
"pubsub.proto",
|
"pubsub",
|
||||||
"spirc.proto"] {
|
"spirc"];
|
||||||
compiler.compile(file).unwrap();
|
|
||||||
|
for file in &files {
|
||||||
|
compiler.compile(&((*file).to_owned() + ".proto")).unwrap();
|
||||||
|
|
||||||
|
// Hack for rust-lang/rust#18810
|
||||||
|
// Wrap the generated rust files with "pub mod { ... }", so they
|
||||||
|
// can be included.
|
||||||
|
let path = out.join(&((*file).to_owned() + ".rs"));
|
||||||
|
let contents = {
|
||||||
|
let mut src = File::open(path).unwrap();
|
||||||
|
let mut contents = Vec::new();
|
||||||
|
src.read_to_end(&mut contents).unwrap();
|
||||||
|
contents
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut dst = File::create(out.join(&((*file).to_owned() + ".rs"))).unwrap();
|
||||||
|
dst.write_all(format!("pub mod {} {{\n", file).as_bytes()).unwrap();
|
||||||
|
dst.write_all(&contents).unwrap();
|
||||||
|
dst.write_all("}".as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(mod_path)]
|
|
||||||
|
|
||||||
extern crate protobuf;
|
extern crate protobuf;
|
||||||
|
|
||||||
mod_path! keyexchange (concat!(env!("OUT_DIR"), "/keyexchange.rs"));
|
include! (concat!(env!("OUT_DIR"), "/authentication.rs"));
|
||||||
mod_path! authentication (concat!(env!("OUT_DIR"), "/authentication.rs"));
|
include! (concat!(env!("OUT_DIR"), "/keyexchange.rs"));
|
||||||
mod_path! mercury (concat!(env!("OUT_DIR"), "/mercury.rs"));
|
include! (concat!(env!("OUT_DIR"), "/mercury.rs"));
|
||||||
mod_path! metadata (concat!(env!("OUT_DIR"), "/metadata.rs"));
|
include! (concat!(env!("OUT_DIR"), "/metadata.rs"));
|
||||||
mod_path! pubsub (concat!(env!("OUT_DIR"), "/pubsub.rs"));
|
include! (concat!(env!("OUT_DIR"), "/pubsub.rs"));
|
||||||
mod_path! spirc (concat!(env!("OUT_DIR"), "/spirc.rs"));
|
include! (concat!(env!("OUT_DIR"), "/spirc.rs"));
|
||||||
|
|
||||||
|
|
16
src/lib.in.rs
Normal file
16
src/lib.in.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#[macro_use] pub mod util;
|
||||||
|
mod audio_decrypt;
|
||||||
|
mod audio_file;
|
||||||
|
mod audio_key;
|
||||||
|
mod authentication;
|
||||||
|
mod connection;
|
||||||
|
mod diffie_hellman;
|
||||||
|
pub mod discovery;
|
||||||
|
pub mod mercury;
|
||||||
|
pub mod metadata;
|
||||||
|
pub mod player;
|
||||||
|
pub mod session;
|
||||||
|
pub mod spirc;
|
||||||
|
pub mod link;
|
||||||
|
mod stream;
|
||||||
|
mod zeroconf;
|
27
src/lib.rs
27
src/lib.rs
|
@ -1,9 +1,9 @@
|
||||||
#![crate_name = "librespot"]
|
#![crate_name = "librespot"]
|
||||||
|
|
||||||
#![feature(plugin,zero_one,iter_arith)]
|
#![cfg_attr(not(feature = "with-syntex"), feature(plugin))]
|
||||||
|
#![cfg_attr(not(feature = "with-syntex"), plugin(protobuf_macros))]
|
||||||
|
#![cfg_attr(not(feature = "with-syntex"), plugin(json_macros))]
|
||||||
|
|
||||||
#![plugin(protobuf_macros)]
|
|
||||||
#![plugin(json_macros)]
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
@ -28,19 +28,8 @@ extern crate dns_sd;
|
||||||
|
|
||||||
extern crate librespot_protocol as protocol;
|
extern crate librespot_protocol as protocol;
|
||||||
|
|
||||||
#[macro_use]pub mod util;
|
#[cfg(feature = "with-syntex")]
|
||||||
mod audio_decrypt;
|
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
||||||
mod audio_file;
|
|
||||||
mod audio_key;
|
#[cfg(not(feature = "with-syntex"))]
|
||||||
mod authentication;
|
include!("lib.in.rs");
|
||||||
mod connection;
|
|
||||||
mod diffie_hellman;
|
|
||||||
pub mod discovery;
|
|
||||||
pub mod mercury;
|
|
||||||
pub mod metadata;
|
|
||||||
pub mod player;
|
|
||||||
pub mod session;
|
|
||||||
pub mod spirc;
|
|
||||||
pub mod link;
|
|
||||||
mod stream;
|
|
||||||
mod zeroconf;
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ impl MetadataManager {
|
||||||
payload: Vec::new(),
|
payload: Vec::new(),
|
||||||
})
|
})
|
||||||
.and_then(move |response| {
|
.and_then(move |response| {
|
||||||
let data = response.payload.first().unwrap();
|
let data = response.payload.first().expect("Empty payload");
|
||||||
let msg: T::Message = protobuf::parse_from_bytes(data).unwrap();
|
let msg: T::Message = protobuf::parse_from_bytes(data).unwrap();
|
||||||
|
|
||||||
Ok(T::parse(&msg, &session))
|
Ok(T::parse(&msg, &session))
|
||||||
|
|
|
@ -8,6 +8,10 @@ pub struct u128 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl u128 {
|
impl u128 {
|
||||||
|
pub fn zero() -> u128 {
|
||||||
|
u128::from_parts(0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_parts(high: u64, low: u64) -> u128 {
|
pub fn from_parts(high: u64, low: u64) -> u128 {
|
||||||
u128 {
|
u128 {
|
||||||
high: high,
|
high: high,
|
||||||
|
@ -20,12 +24,6 @@ impl u128 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::num::Zero for u128 {
|
|
||||||
fn zero() -> u128 {
|
|
||||||
u128::from_parts(0, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::ops::Add<u128> for u128 {
|
impl std::ops::Add<u128> for u128 {
|
||||||
type Output = u128;
|
type Output = u128;
|
||||||
fn add(self, rhs: u128) -> u128 {
|
fn add(self, rhs: u128) -> u128 {
|
||||||
|
@ -77,7 +75,7 @@ impl std::ops::Mul<u128> for u128 {
|
||||||
rhs.low >> 32,
|
rhs.low >> 32,
|
||||||
rhs.low & 0xFFFFFFFF];
|
rhs.low & 0xFFFFFFFF];
|
||||||
|
|
||||||
let mut rows = [std::num::Zero::zero(); 16];
|
let mut rows = [u128::zero(); 16];
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
for j in 0..4 {
|
for j in 0..4 {
|
||||||
let shift = i + j;
|
let shift = i + j;
|
||||||
|
@ -99,6 +97,6 @@ impl std::ops::Mul<u128> for u128 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.iter().sum::<u128>()
|
rows.iter().fold(u128::zero(), std::ops::Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,14 @@ pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub mod version {
|
pub mod version {
|
||||||
include!(concat!(env!("OUT_DIR"), "/version.rs"));
|
// 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 {
|
pub fn version_string() -> String {
|
||||||
format!("librespot-{}", short_sha())
|
format!("librespot-{}", short_sha())
|
||||||
|
|
|
@ -18,7 +18,7 @@ impl SpotifyId {
|
||||||
assert!(id.is_ascii());
|
assert!(id.is_ascii());
|
||||||
let data = id.as_bytes();
|
let data = id.as_bytes();
|
||||||
|
|
||||||
let mut n: u128 = std::num::Zero::zero();
|
let mut n: u128 = u128::zero();
|
||||||
for c in data {
|
for c in data {
|
||||||
let d = BASE16_DIGITS.iter().position(|e| e == c).unwrap() as u8;
|
let d = BASE16_DIGITS.iter().position(|e| e == c).unwrap() as u8;
|
||||||
n = n * u128::from(16);
|
n = n * u128::from(16);
|
||||||
|
@ -32,7 +32,7 @@ impl SpotifyId {
|
||||||
assert!(id.is_ascii());
|
assert!(id.is_ascii());
|
||||||
let data = id.as_bytes();
|
let data = id.as_bytes();
|
||||||
|
|
||||||
let mut n: u128 = std::num::Zero::zero();
|
let mut n: u128 = u128::zero();
|
||||||
for c in data {
|
for c in data {
|
||||||
let d = BASE62_DIGITS.iter().position(|e| e == c).unwrap() as u8;
|
let d = BASE62_DIGITS.iter().position(|e| e == c).unwrap() as u8;
|
||||||
n = n * u128::from(62);
|
n = n * u128::from(62);
|
||||||
|
|
Loading…
Reference in a new issue