From 349d264a5678a93e27d514b149503c3ed278858a Mon Sep 17 00:00:00 2001 From: Roma Sokolov Date: Sat, 18 Aug 2018 00:40:06 +0200 Subject: [PATCH 1/2] Add `required-features` to `SerializedTarget` This will add it to `cargo metadata` output and will make it possible to enable features needed to build specific target. --- src/cargo/core/manifest.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 82a9c6527a3..f46348c5c49 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -229,6 +229,8 @@ struct SerializedTarget<'a> { name: &'a str, src_path: &'a PathBuf, edition: &'a str, + #[serde(skip_serializing_if = "Option::is_none")] + required_features: Option>, } impl ser::Serialize for Target { @@ -238,7 +240,11 @@ impl ser::Serialize for Target { crate_types: self.rustc_crate_types(), name: &self.name, src_path: &self.src_path.path, - edition: &self.edition.to_string() + edition: &self.edition.to_string(), + required_features: self + .required_features + .as_ref() + .map(|rf| rf.iter().map(|s| &**s).collect()), }.serialize(s) } } From 9c38505ab768fc36f476286bfc25c90c474bf2c4 Mon Sep 17 00:00:00 2001 From: Roma Sokolov Date: Mon, 20 Aug 2018 20:54:45 +0200 Subject: [PATCH 2/2] Serialize required_dependencies as 'require-dependencies' --- src/cargo/core/manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index f46348c5c49..4ae39baee94 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -229,7 +229,7 @@ struct SerializedTarget<'a> { name: &'a str, src_path: &'a PathBuf, edition: &'a str, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "required-features", skip_serializing_if = "Option::is_none")] required_features: Option>, }