Skip to content

Commit d395043

Browse files
committed
Propagate cargo-features from project's Cargo.toml into that used
for the xbuild, in order to support any that are required by the propagated profile.
1 parent a779803 commit d395043

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/cargo.rs

+19
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ impl<'t> fmt::Display for Profile<'t> {
233233
}
234234
}
235235

236+
pub struct Features<'a> {
237+
array: &'a Value,
238+
}
239+
240+
impl<'a> fmt::Display for Features<'a> {
241+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
242+
let mut map = toml::map::Map::new();
243+
map.insert("cargo-features".to_owned(), self.array.clone());
244+
245+
fmt::Display::fmt(&Value::Table(map), f)
246+
}
247+
}
248+
236249
pub struct Toml {
237250
table: Value,
238251
}
@@ -245,6 +258,12 @@ impl Toml {
245258
.and_then(|v| v.get("release"))
246259
.map(|t| Profile { table: t })
247260
}
261+
262+
pub fn features(&self) -> Option<Features> {
263+
self.table
264+
.get("cargo-features")
265+
.map(|a| Features { array: a })
266+
}
248267
}
249268

250269
pub fn toml(root: &Path) -> Result<Toml> {

src/sysroot.rs

+4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ fn build_crate(
7676

7777
let target_dir = td.join("target");
7878

79+
if let Some(features) = ctoml.features() {
80+
stoml.insert_str(0, &features.to_string())
81+
}
82+
7983
if let Some(profile) = ctoml.profile() {
8084
stoml.push_str(&profile.to_string())
8185
}

0 commit comments

Comments
 (0)