Update to toml 0.4

This commit is contained in:
Mark Simulacrum
2017-07-04 10:03:01 -06:00
parent d360af45bb
commit a1fa2681cf
9 changed files with 69 additions and 81 deletions

17
src/Cargo.lock generated
View File

@@ -136,11 +136,10 @@ dependencies = [
"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)",
"libc 0.2.26 (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)", "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 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_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)", "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]] [[package]]
@@ -156,8 +155,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "build-manifest" name = "build-manifest"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"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)",
"toml 0.1.30 (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]] [[package]]
@@ -1871,14 +1871,6 @@ dependencies = [
name = "tidy" name = "tidy"
version = "0.1.0" 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]] [[package]]
name = "toml" name = "toml"
version = "0.2.1" 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-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.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 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.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 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" "checksum typed-arena 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5934776c3ac1bea4a9d56620d6bf2d483b20d394e49581db40f187e1118ff667"

View File

@@ -33,11 +33,10 @@ build_helper = { path = "../build_helper" }
cmake = "0.1.23" cmake = "0.1.23"
filetime = "0.1" filetime = "0.1"
num_cpus = "1.0" num_cpus = "1.0"
toml = "0.1"
getopts = "0.2" getopts = "0.2"
rustc-serialize = "0.3"
gcc = "0.3.50" gcc = "0.3.50"
libc = "0.2" libc = "0.2"
serde = "1.0" serde = "1.0.8"
serde_json = "1.0" serde_derive = "1.0.8"
serde_derive = "1.0" serde_json = "1.0.2"
toml = "0.4"

View File

@@ -25,6 +25,7 @@ use cache::{Cache, Key};
use check; use check;
use flags::Subcommand; use flags::Subcommand;
use doc; use doc;
use tool;
pub use Compiler; pub use Compiler;
@@ -144,7 +145,10 @@ impl<'a> Builder<'a> {
let builder = &builder; let builder = &builder;
match builder.kind { match builder.kind {
Kind::Build => check!(builder, paths, compile::Std, compile::Test, compile::Rustc, 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, Kind::Test => check!(builder, paths, check::Tidy, check::Bootstrap, check::Compiletest,
check::Krate, check::KrateLibrustc, check::Linkcheck, check::Cargotest, check::Krate, check::KrateLibrustc, check::Linkcheck, check::Cargotest,
check::Cargo, check::Docs, check::ErrorIndex, check::Distcheck), check::Cargo, check::Docs, check::ErrorIndex, check::Distcheck),

View File

@@ -21,8 +21,7 @@ use std::path::PathBuf;
use std::process; use std::process;
use num_cpus; use num_cpus;
use rustc_serialize::Decodable; use toml;
use toml::{Parser, Decoder, Value};
use util::{exe, push_exe_path}; use util::{exe, push_exe_path};
/// Global configuration for the entire build and/or bootstrap. /// 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 /// This structure uses `Decodable` to automatically decode a TOML configuration
/// file into this format, and then this is traversed and written into the above /// file into this format, and then this is traversed and written into the above
/// `Config` structure. /// `Config` structure.
#[derive(RustcDecodable, Default)] #[derive(Deserialize, Default)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "kebab-case")]
struct TomlConfig { struct TomlConfig {
build: Option<Build>, build: Option<Build>,
install: Option<Install>, install: Option<Install>,
@@ -149,10 +150,14 @@ struct TomlConfig {
} }
/// TOML representation of various global build decisions. /// 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 { struct Build {
build: Option<String>, build: Option<String>,
#[serde(default)]
host: Vec<String>, host: Vec<String>,
#[serde(default)]
target: Vec<String>, target: Vec<String>,
cargo: Option<String>, cargo: Option<String>,
rustc: Option<String>, rustc: Option<String>,
@@ -174,7 +179,9 @@ struct Build {
} }
/// TOML representation of various global install decisions. /// 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 { struct Install {
prefix: Option<String>, prefix: Option<String>,
sysconfdir: Option<String>, sysconfdir: Option<String>,
@@ -185,7 +192,9 @@ struct Install {
} }
/// TOML representation of how the LLVM build is configured. /// 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 { struct Llvm {
ccache: Option<StringOrBool>, ccache: Option<StringOrBool>,
ninja: Option<bool>, ninja: Option<bool>,
@@ -200,7 +209,9 @@ struct Llvm {
clean_rebuild: Option<bool>, clean_rebuild: Option<bool>,
} }
#[derive(RustcDecodable, Default, Clone)] #[derive(Deserialize, Default, Clone)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "kebab-case")]
struct Dist { struct Dist {
sign_folder: Option<String>, sign_folder: Option<String>,
gpg_password_file: Option<String>, gpg_password_file: Option<String>,
@@ -208,7 +219,8 @@ struct Dist {
src_tarball: Option<bool>, src_tarball: Option<bool>,
} }
#[derive(RustcDecodable)] #[derive(Deserialize)]
#[serde(untagged)]
enum StringOrBool { enum StringOrBool {
String(String), String(String),
Bool(bool), Bool(bool),
@@ -221,7 +233,9 @@ impl Default for StringOrBool {
} }
/// TOML representation of how the Rust build is configured. /// 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 { struct Rust {
optimize: Option<bool>, optimize: Option<bool>,
codegen_units: Option<u32>, codegen_units: Option<u32>,
@@ -243,7 +257,9 @@ struct Rust {
} }
/// TOML representation of how each build target is configured. /// 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 { struct TomlTarget {
llvm_config: Option<String>, llvm_config: Option<String>,
jemalloc: Option<String>, jemalloc: Option<String>,
@@ -273,27 +289,13 @@ impl Config {
let toml = file.map(|file| { let toml = file.map(|file| {
let mut f = t!(File::open(&file)); let mut f = t!(File::open(&file));
let mut toml = String::new(); let mut contents = String::new();
t!(f.read_to_string(&mut toml)); t!(f.read_to_string(&mut contents));
let mut p = Parser::new(&toml); match toml::from_str(&contents) {
let table = match p.parse() { Ok(table) => table,
Some(table) => table, Err(err) => {
None => { println!("failed to parse TOML configuration '{}': {}",
println!("failed to parse TOML configuration '{}':", file.to_str().unwrap()); file.display(), err);
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);
process::exit(2); process::exit(2);
} }
} }

View File

@@ -128,7 +128,6 @@ extern crate filetime;
extern crate gcc; extern crate gcc;
extern crate getopts; extern crate getopts;
extern crate num_cpus; extern crate num_cpus;
extern crate rustc_serialize;
extern crate toml; extern crate toml;
#[cfg(unix)] #[cfg(unix)]

View File

@@ -13,17 +13,17 @@ use std::process::Command;
use std::path::PathBuf; use std::path::PathBuf;
use build_helper::output; use build_helper::output;
use rustc_serialize::json; use serde_json;
use {Build, Crate}; use {Build, Crate};
#[derive(RustcDecodable)] #[derive(Deserialize)]
struct Output { struct Output {
packages: Vec<Package>, packages: Vec<Package>,
resolve: Resolve, resolve: Resolve,
} }
#[derive(RustcDecodable)] #[derive(Deserialize)]
struct Package { struct Package {
id: String, id: String,
name: String, name: String,
@@ -32,12 +32,12 @@ struct Package {
manifest_path: String, manifest_path: String,
} }
#[derive(RustcDecodable)] #[derive(Deserialize)]
struct Resolve { struct Resolve {
nodes: Vec<ResolveNode>, nodes: Vec<ResolveNode>,
} }
#[derive(RustcDecodable)] #[derive(Deserialize)]
struct ResolveNode { struct ResolveNode {
id: String, id: String,
dependencies: Vec<String>, dependencies: Vec<String>,
@@ -61,7 +61,7 @@ fn build_krate(build: &mut Build, krate: &str) {
.arg("--format-version").arg("1") .arg("--format-version").arg("1")
.arg("--manifest-path").arg(build.src.join(krate).join("Cargo.toml")); .arg("--manifest-path").arg(build.src.join(krate).join("Cargo.toml"));
let output = output(&mut cargo); 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(); let mut id2name = HashMap::new();
for package in output.packages { for package in output.packages {
if package.source.is_none() { if package.source.is_none() {

View File

@@ -238,7 +238,7 @@ tool!(
// .dep(|s| s.name("maybe-clean-tools")) // .dep(|s| s.name("maybe-clean-tools"))
// .dep(|s| s.name("libstd-tool")) // .dep(|s| s.name("libstd-tool"))
// .run(move |s| compile::tool(build, s.stage, s.target, "build-manifest")); // .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") // rules.build("tool-remote-test-server", "src/tools/remote-test-server")
// .dep(|s| s.name("maybe-clean-tools")) // .dep(|s| s.name("maybe-clean-tools"))
// .dep(|s| s.name("libstd-tool")) // .dep(|s| s.name("libstd-tool"))

View File

@@ -4,5 +4,6 @@ version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["Alex Crichton <alex@alexcrichton.com>"]
[dependencies] [dependencies]
toml = "0.1" toml = "0.4"
rustc-serialize = "0.3" serde = "1.0"
serde_derive = "1.0"

View File

@@ -9,7 +9,9 @@
// except according to those terms. // except according to those terms.
extern crate toml; extern crate toml;
extern crate rustc_serialize; #[macro_use]
extern crate serde_derive;
extern crate serde;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::env; use std::env;
@@ -99,19 +101,21 @@ static MINGW: &'static [&'static str] = &[
"x86_64-pc-windows-gnu", "x86_64-pc-windows-gnu",
]; ];
#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
struct Manifest { struct Manifest {
manifest_version: String, manifest_version: String,
date: String, date: String,
pkg: BTreeMap<String, Package>, pkg: BTreeMap<String, Package>,
} }
#[derive(RustcEncodable)] #[derive(Serialize)]
struct Package { struct Package {
version: String, version: String,
target: BTreeMap<String, Target>, target: BTreeMap<String, Target>,
} }
#[derive(RustcEncodable)] #[derive(Serialize)]
struct Target { struct Target {
available: bool, available: bool,
url: Option<String>, url: Option<String>,
@@ -136,7 +140,7 @@ impl Target {
} }
} }
#[derive(RustcEncodable)] #[derive(Serialize)]
struct Component { struct Component {
pkg: String, pkg: String,
target: String, target: String,
@@ -199,28 +203,16 @@ impl Builder {
self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu"); self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu");
self.digest_and_sign(); self.digest_and_sign();
let Manifest { manifest_version, date, pkg } = self.build_manifest(); let manifest = 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 filename = format!("channel-rust-{}.toml", self.rust_release); 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); 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" { if self.rust_release != "beta" && self.rust_release != "nightly" {
self.write_manifest(&manifest, "channel-rust-stable.toml"); self.write_manifest(&toml::to_string(&manifest).unwrap(), "channel-rust-stable.toml");
self.write_date_stamp(&date, "channel-rust-stable-date.txt"); self.write_date_stamp(&manifest.date, "channel-rust-stable-date.txt");
} }
} }