diff --git a/src/cargo.rs b/src/cargo.rs index 5a6b6e0..68c5194 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -233,6 +233,19 @@ impl<'t> fmt::Display for Profile<'t> { } } +pub struct Features<'a> { + array: &'a Value, +} + +impl<'a> fmt::Display for Features<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut map = toml::map::Map::new(); + map.insert("cargo-features".to_owned(), self.array.clone()); + + fmt::Display::fmt(&Value::Table(map), f) + } +} + pub struct Toml { table: Value, } @@ -245,6 +258,12 @@ impl Toml { .and_then(|v| v.get("release")) .map(|t| Profile { table: t }) } + + pub fn features(&self) -> Option { + self.table + .get("cargo-features") + .map(|a| Features { array: a }) + } } pub fn toml(root: &Path) -> Result { diff --git a/src/sysroot.rs b/src/sysroot.rs index a8b213d..7956887 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -76,6 +76,10 @@ fn build_crate( let target_dir = td.join("target"); + if let Some(features) = ctoml.features() { + stoml.insert_str(0, &features.to_string()) + } + if let Some(profile) = ctoml.profile() { stoml.push_str(&profile.to_string()) }