diff --git a/src/Cargo.lock b/src/Cargo.lock index c210f80431b..35d77eda951 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -136,11 +136,10 @@ dependencies = [ "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -156,8 +155,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "build-manifest" version = "0.1.0" dependencies = [ - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1871,14 +1871,6 @@ dependencies = [ name = "tidy" version = "0.1.0" -[[package]] -name = "toml" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "toml" version = "0.2.1" @@ -2173,7 +2165,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" -"checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum toml 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b0601da6c97135c8d330c7a13a013ca6cd4143221b01de2f8d4edc50a9e551c7" "checksum typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5934776c3ac1bea4a9d56620d6bf2d483b20d394e49581db40f187e1118ff667" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index f557dcc4763..00004d71aac 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -33,11 +33,10 @@ build_helper = { path = "../build_helper" } cmake = "0.1.23" filetime = "0.1" num_cpus = "1.0" -toml = "0.1" getopts = "0.2" -rustc-serialize = "0.3" gcc = "0.3.50" libc = "0.2" -serde = "1.0" -serde_json = "1.0" -serde_derive = "1.0" +serde = "1.0.8" +serde_derive = "1.0.8" +serde_json = "1.0.2" +toml = "0.4" diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index e6432e8938c..e284e4b9d0a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -25,6 +25,7 @@ use cache::{Cache, Key}; use check; use flags::Subcommand; use doc; +use tool; pub use Compiler; @@ -144,7 +145,10 @@ impl<'a> Builder<'a> { let builder = &builder; match builder.kind { Kind::Build => check!(builder, paths, compile::Std, compile::Test, compile::Rustc, - compile::StartupObjects), + compile::StartupObjects, tool::BuildManifest, tool::Rustbook, tool::ErrorIndex, + tool::UnstableBookGen, tool::Tidy, tool::Linkchecker, tool::CargoTest, + tool::Compiletest, tool::RemoteTestServer, tool::RemoteTestClient, + tool::RustInstaller, tool::Cargo, tool::Rls), Kind::Test => check!(builder, paths, check::Tidy, check::Bootstrap, check::Compiletest, check::Krate, check::KrateLibrustc, check::Linkcheck, check::Cargotest, check::Cargo, check::Docs, check::ErrorIndex, check::Distcheck), diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 34628852ab3..810a9924765 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -21,8 +21,7 @@ use std::path::PathBuf; use std::process; use num_cpus; -use rustc_serialize::Decodable; -use toml::{Parser, Decoder, Value}; +use toml; use util::{exe, push_exe_path}; /// Global configuration for the entire build and/or bootstrap. @@ -138,7 +137,9 @@ pub struct Target { /// This structure uses `Decodable` to automatically decode a TOML configuration /// file into this format, and then this is traversed and written into the above /// `Config` structure. -#[derive(RustcDecodable, Default)] +#[derive(Deserialize, Default)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct TomlConfig { build: Option, install: Option, @@ -149,10 +150,14 @@ struct TomlConfig { } /// TOML representation of various global build decisions. -#[derive(RustcDecodable, Default, Clone)] +#[derive(Deserialize, Default, Clone)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct Build { build: Option, + #[serde(default)] host: Vec, + #[serde(default)] target: Vec, cargo: Option, rustc: Option, @@ -174,7 +179,9 @@ struct Build { } /// TOML representation of various global install decisions. -#[derive(RustcDecodable, Default, Clone)] +#[derive(Deserialize, Default, Clone)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct Install { prefix: Option, sysconfdir: Option, @@ -185,7 +192,9 @@ struct Install { } /// TOML representation of how the LLVM build is configured. -#[derive(RustcDecodable, Default)] +#[derive(Deserialize, Default)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct Llvm { ccache: Option, ninja: Option, @@ -200,7 +209,9 @@ struct Llvm { clean_rebuild: Option, } -#[derive(RustcDecodable, Default, Clone)] +#[derive(Deserialize, Default, Clone)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct Dist { sign_folder: Option, gpg_password_file: Option, @@ -208,7 +219,8 @@ struct Dist { src_tarball: Option, } -#[derive(RustcDecodable)] +#[derive(Deserialize)] +#[serde(untagged)] enum StringOrBool { String(String), Bool(bool), @@ -221,7 +233,9 @@ impl Default for StringOrBool { } /// TOML representation of how the Rust build is configured. -#[derive(RustcDecodable, Default)] +#[derive(Deserialize, Default)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct Rust { optimize: Option, codegen_units: Option, @@ -243,7 +257,9 @@ struct Rust { } /// TOML representation of how each build target is configured. -#[derive(RustcDecodable, Default)] +#[derive(Deserialize, Default)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "kebab-case")] struct TomlTarget { llvm_config: Option, jemalloc: Option, @@ -273,27 +289,13 @@ impl Config { let toml = file.map(|file| { let mut f = t!(File::open(&file)); - let mut toml = String::new(); - t!(f.read_to_string(&mut toml)); - let mut p = Parser::new(&toml); - let table = match p.parse() { - Some(table) => table, - None => { - println!("failed to parse TOML configuration '{}':", file.to_str().unwrap()); - for err in p.errors.iter() { - let (loline, locol) = p.to_linecol(err.lo); - let (hiline, hicol) = p.to_linecol(err.hi); - println!("{}:{}-{}:{}: {}", loline, locol, hiline, - hicol, err.desc); - } - process::exit(2); - } - }; - let mut d = Decoder::new(Value::Table(table)); - match Decodable::decode(&mut d) { - Ok(cfg) => cfg, - Err(e) => { - println!("failed to decode TOML: {}", e); + let mut contents = String::new(); + t!(f.read_to_string(&mut contents)); + match toml::from_str(&contents) { + Ok(table) => table, + Err(err) => { + println!("failed to parse TOML configuration '{}': {}", + file.display(), err); process::exit(2); } } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index d6b474ab3af..d4ef6613a2a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -128,7 +128,6 @@ extern crate filetime; extern crate gcc; extern crate getopts; extern crate num_cpus; -extern crate rustc_serialize; extern crate toml; #[cfg(unix)] diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs index 9326bb7129a..ca0eed3ae86 100644 --- a/src/bootstrap/metadata.rs +++ b/src/bootstrap/metadata.rs @@ -13,17 +13,17 @@ use std::process::Command; use std::path::PathBuf; use build_helper::output; -use rustc_serialize::json; +use serde_json; use {Build, Crate}; -#[derive(RustcDecodable)] +#[derive(Deserialize)] struct Output { packages: Vec, resolve: Resolve, } -#[derive(RustcDecodable)] +#[derive(Deserialize)] struct Package { id: String, name: String, @@ -32,12 +32,12 @@ struct Package { manifest_path: String, } -#[derive(RustcDecodable)] +#[derive(Deserialize)] struct Resolve { nodes: Vec, } -#[derive(RustcDecodable)] +#[derive(Deserialize)] struct ResolveNode { id: String, dependencies: Vec, @@ -61,7 +61,7 @@ fn build_krate(build: &mut Build, krate: &str) { .arg("--format-version").arg("1") .arg("--manifest-path").arg(build.src.join(krate).join("Cargo.toml")); let output = output(&mut cargo); - let output: Output = json::decode(&output).unwrap(); + let output: Output = serde_json::from_str(&output).unwrap(); let mut id2name = HashMap::new(); for package in output.packages { if package.source.is_none() { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 50e76c324c3..eecfbdc8b3d 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -238,7 +238,7 @@ tool!( // .dep(|s| s.name("maybe-clean-tools")) // .dep(|s| s.name("libstd-tool")) // .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest")); - BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; + BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Librustc; // rules.build("tool-remote-test-server", "src/tools/remote-test-server") // .dep(|s| s.name("maybe-clean-tools")) // .dep(|s| s.name("libstd-tool")) diff --git a/src/tools/build-manifest/Cargo.toml b/src/tools/build-manifest/Cargo.toml index 4b876753b1f..844b7aad72f 100644 --- a/src/tools/build-manifest/Cargo.toml +++ b/src/tools/build-manifest/Cargo.toml @@ -4,5 +4,6 @@ version = "0.1.0" authors = ["Alex Crichton "] [dependencies] -toml = "0.1" -rustc-serialize = "0.3" +toml = "0.4" +serde = "1.0" +serde_derive = "1.0" diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index ba37863b1f6..b8efb88acfb 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -9,7 +9,9 @@ // except according to those terms. extern crate toml; -extern crate rustc_serialize; +#[macro_use] +extern crate serde_derive; +extern crate serde; use std::collections::BTreeMap; use std::env; @@ -99,19 +101,21 @@ static MINGW: &'static [&'static str] = &[ "x86_64-pc-windows-gnu", ]; +#[derive(Serialize)] +#[serde(rename_all = "kebab-case")] struct Manifest { manifest_version: String, date: String, pkg: BTreeMap, } -#[derive(RustcEncodable)] +#[derive(Serialize)] struct Package { version: String, target: BTreeMap, } -#[derive(RustcEncodable)] +#[derive(Serialize)] struct Target { available: bool, url: Option, @@ -136,7 +140,7 @@ impl Target { } } -#[derive(RustcEncodable)] +#[derive(Serialize)] struct Component { pkg: String, target: String, @@ -199,28 +203,16 @@ impl Builder { self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu"); self.digest_and_sign(); - let Manifest { manifest_version, date, pkg } = self.build_manifest(); - - // Unfortunately we can't use derive(RustcEncodable) here because the - // version field is called `manifest-version`, not `manifest_version`. - // In lieu of that just create the table directly here with a `BTreeMap` - // and wrap it up in a `Value::Table`. - let mut manifest = BTreeMap::new(); - manifest.insert("manifest-version".to_string(), - toml::Value::String(manifest_version)); - manifest.insert("date".to_string(), toml::Value::String(date.clone())); - manifest.insert("pkg".to_string(), toml::encode(&pkg)); - let manifest = toml::Value::Table(manifest).to_string(); - + let manifest = self.build_manifest(); let filename = format!("channel-rust-{}.toml", self.rust_release); - self.write_manifest(&manifest, &filename); + self.write_manifest(&toml::to_string(&manifest).unwrap(), &filename); let filename = format!("channel-rust-{}-date.txt", self.rust_release); - self.write_date_stamp(&date, &filename); + self.write_date_stamp(&manifest.date, &filename); if self.rust_release != "beta" && self.rust_release != "nightly" { - self.write_manifest(&manifest, "channel-rust-stable.toml"); - self.write_date_stamp(&date, "channel-rust-stable-date.txt"); + self.write_manifest(&toml::to_string(&manifest).unwrap(), "channel-rust-stable.toml"); + self.write_date_stamp(&manifest.date, "channel-rust-stable-date.txt"); } }