Migrate to serde_json entirely

This commit is contained in:
Mark Simulacrum 2017-07-04 07:31:05 -06:00
parent d812d430a4
commit d360af45bb

View File

@ -26,7 +26,7 @@ use std::str;
use build_helper::{output, mtime, up_to_date}; use build_helper::{output, mtime, up_to_date};
use filetime::FileTime; use filetime::FileTime;
use rustc_serialize::json; use serde_json;
use util::{exe, libdir, is_dylib, copy}; use util::{exe, libdir, is_dylib, copy};
use {Build, Compiler, Mode}; use {Build, Compiler, Mode};
@ -934,18 +934,18 @@ fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path) {
let stdout = BufReader::new(child.stdout.take().unwrap()); let stdout = BufReader::new(child.stdout.take().unwrap());
for line in stdout.lines() { for line in stdout.lines() {
let line = t!(line); let line = t!(line);
let json = if line.starts_with("{") { let json: serde_json::Value = if line.starts_with("{") {
t!(line.parse::<json::Json>()) t!(serde_json::from_str(&line))
} else { } else {
// If this was informational, just print it out and continue // If this was informational, just print it out and continue
println!("{}", line); println!("{}", line);
continue continue
}; };
if json.find("reason").and_then(|j| j.as_string()) != Some("compiler-artifact") { if json["reason"].as_str() != Some("compiler-artifact") {
continue continue
} }
for filename in json["filenames"].as_array().unwrap() { for filename in json["filenames"].as_array().unwrap() {
let filename = filename.as_string().unwrap(); let filename = filename.as_str().unwrap();
// Skip files like executables // Skip files like executables
if !filename.ends_with(".rlib") && if !filename.ends_with(".rlib") &&
!filename.ends_with(".lib") && !filename.ends_with(".lib") &&