Skip to content

Commit

Permalink
Use kebab-case for CompileMode, & discard some info
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Nov 18, 2018
1 parent 7b08156 commit 27424e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
22 changes: 21 additions & 1 deletion src/cargo/core/compiler/build_config.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions tests/testsuite/build_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down Expand Up @@ -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": "{...}",
Expand All @@ -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"
}
]
}
Expand Down Expand Up @@ -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": "{...}",
Expand All @@ -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": "{...}",
Expand All @@ -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"
}
]
}
Expand Down

0 comments on commit 27424e2

Please sign in to comment.