mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 19:42:03 +02: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
|
@ -5,7 +5,6 @@ authors = ["Paul Liétar <paul@lietar.net>"]
|
|||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
mod_path = "~0.1.6"
|
||||
protobuf = "~1.0.10"
|
||||
|
||||
[build-dependencies.protobuf_build]
|
||||
|
|
|
@ -2,6 +2,8 @@ extern crate protobuf_build;
|
|||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
fn main() {
|
||||
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);
|
||||
|
||||
for file in &["keyexchange.proto",
|
||||
"authentication.proto",
|
||||
"mercury.proto",
|
||||
"metadata.proto",
|
||||
"pubsub.proto",
|
||||
"spirc.proto"] {
|
||||
compiler.compile(file).unwrap();
|
||||
let files = ["keyexchange",
|
||||
"authentication",
|
||||
"mercury",
|
||||
"metadata",
|
||||
"pubsub",
|
||||
"spirc"];
|
||||
|
||||
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;
|
||||
|
||||
mod_path! keyexchange (concat!(env!("OUT_DIR"), "/keyexchange.rs"));
|
||||
mod_path! authentication (concat!(env!("OUT_DIR"), "/authentication.rs"));
|
||||
mod_path! mercury (concat!(env!("OUT_DIR"), "/mercury.rs"));
|
||||
mod_path! metadata (concat!(env!("OUT_DIR"), "/metadata.rs"));
|
||||
mod_path! pubsub (concat!(env!("OUT_DIR"), "/pubsub.rs"));
|
||||
mod_path! spirc (concat!(env!("OUT_DIR"), "/spirc.rs"));
|
||||
|
||||
include! (concat!(env!("OUT_DIR"), "/authentication.rs"));
|
||||
include! (concat!(env!("OUT_DIR"), "/keyexchange.rs"));
|
||||
include! (concat!(env!("OUT_DIR"), "/mercury.rs"));
|
||||
include! (concat!(env!("OUT_DIR"), "/metadata.rs"));
|
||||
include! (concat!(env!("OUT_DIR"), "/pubsub.rs"));
|
||||
include! (concat!(env!("OUT_DIR"), "/spirc.rs"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue