Use kebab-case for CompileMode, & discard some info

This commit is contained in:
Dale Wijnand 2018-11-18 18:32:54 +00:00
parent 7b081569ed
commit 27424e2dba
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
2 changed files with 27 additions and 7 deletions

View File

@ -1,6 +1,8 @@
use std::path::Path;
use std::cell::RefCell;
use serde::ser;
use util::{CargoResult, CargoResultExt, Config, RustfixDiagnosticServer};
/// Configuration information for a rustc build.
@ -111,7 +113,7 @@ pub enum MessageFormat {
/// `compile_ws` to tell it the general execution strategy. This influences
/// the default targets selected. The other use is in the `Unit` struct
/// to indicate what is being done with a specific target.
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, PartialOrd, Ord, Serialize)]
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, PartialOrd, Ord)]
pub enum CompileMode {
/// A target being built for a test.
Test,
@ -136,6 +138,24 @@ pub enum CompileMode {
RunCustomBuild,
}
impl ser::Serialize for CompileMode {
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
S: ser::Serializer,
{
use self::CompileMode::*;
match *self {
Test => "test".serialize(s),
Build => "build".serialize(s),
Check { .. } => "check".serialize(s),
Bench => "bench".serialize(s),
Doc { .. } => "doc".serialize(s),
Doctest => "doctest".serialize(s),
RunCustomBuild => "run-custom-build".serialize(s),
}
}
}
impl CompileMode {
/// Returns true if the unit is being checked.
pub fn is_check(self) -> bool {

View File

@ -29,7 +29,7 @@ fn cargo_build_plan_simple() {
"package_version": "0.5.0",
"program": "rustc",
"target_kind": ["bin"],
"compile_mode": "Build"
"compile_mode": "build"
}
]
}
@ -88,7 +88,7 @@ fn cargo_build_plan_single_dep() {
"package_version": "0.0.1",
"program": "rustc",
"target_kind": ["lib"],
"compile_mode": "Build"
"compile_mode": "build"
},
{
"args": "{...}",
@ -104,7 +104,7 @@ fn cargo_build_plan_single_dep() {
"package_version": "0.5.0",
"program": "rustc",
"target_kind": ["lib"],
"compile_mode": "Build"
"compile_mode": "build"
}
]
}
@ -152,7 +152,7 @@ fn cargo_build_plan_build_script() {
"package_version": "0.5.0",
"program": "rustc",
"target_kind": ["custom-build"],
"compile_mode": "Build"
"compile_mode": "build"
},
{
"args": "{...}",
@ -166,7 +166,7 @@ fn cargo_build_plan_build_script() {
"package_version": "0.5.0",
"program": "[..]/build-script-build",
"target_kind": ["custom-build"],
"compile_mode": "RunCustomBuild"
"compile_mode": "run-custom-build"
},
{
"args": "{...}",
@ -180,7 +180,7 @@ fn cargo_build_plan_build_script() {
"package_version": "0.5.0",
"program": "rustc",
"target_kind": ["bin"],
"compile_mode": "Build"
"compile_mode": "build"
}
]
}