Skip to content

Commit aa42f94

Browse files
committed
fix missing external feature activations, and regen code
1 parent 6939702 commit aa42f94

File tree

62 files changed

+21215
-7797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+21215
-7797
lines changed

codegen/crates/crate_feature_graph/src/feature.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ impl FeatureName {
4949
pub fn new(name: impl Into<Cow<'static, str>>) -> Self {
5050
Self(name.into())
5151
}
52+
53+
pub fn is_special_default_enabling_feature(&self) -> bool {
54+
self.0.contains("enable_default_for")
55+
}
5256
}
5357

5458
impl Display for FeatureName {
@@ -228,7 +232,7 @@ pub struct Crate {
228232
pub version: Version,
229233
pub in_workspace: Option<bool>,
230234
pub active_features: Option<IndexSet<FeatureName>>,
231-
pub active_dependency_features: Option<IndexMap<CrateName, Vec<FeatureName>>>,
235+
pub active_dependency_features: Option<IndexMap<CrateName, Vec<(FeatureName, bool)>>>,
232236
pub is_enabled: Option<bool>,
233237
}
234238

codegen/crates/crate_feature_graph/src/graph.rs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ impl WorkspaceGraph {
331331
.map(|(k, v)| {
332332
(
333333
k.to_string(),
334-
v.iter().map(|f| f.to_string()).collect::<Vec<_>>(),
334+
v.iter()
335+
.map(|(f, enabled_by_shared)| {
336+
(f.to_string(), enabled_by_shared)
337+
})
338+
.collect::<Vec<_>>(),
335339
)
336340
})
337341
.collect()
@@ -345,7 +349,20 @@ impl WorkspaceGraph {
345349
active_features.join("\\n"),
346350
active_dependencies
347351
.iter()
348-
.map(|(k, v)| format!("{}: [{}]", k, v.join(", ")))
352+
.map(|(k, v)| format!(
353+
"{}: [{}]",
354+
k,
355+
v.iter()
356+
.map(|(f, enabled_by_shared)| format!(
357+
"{}{}",
358+
f,
359+
enabled_by_shared
360+
.then_some(String::from(" (*shared)"))
361+
.unwrap_or_default()
362+
))
363+
.collect::<Vec<_>>()
364+
.join(", ")
365+
))
349366
.collect::<Vec<_>>()
350367
.join("\\n")
351368
);
@@ -555,7 +572,7 @@ impl WorkspaceGraph {
555572
}
556573

557574
// then compute the active dependency features for each crate
558-
let mut active_dependency_features = HashMap::<_, Vec<_>>::new();
575+
let mut active_dependency_features = HashMap::<_, Vec<(_, _)>>::new();
559576
for krate in self
560577
.workspace
561578
.all_crates()
@@ -585,12 +602,34 @@ impl WorkspaceGraph {
585602
active_dependency_features
586603
.entry((krate.name.clone(), dependency.name.clone()))
587604
.or_default()
588-
.push(feature.clone());
605+
.push((feature.clone(), false));
606+
}
607+
}
608+
}
609+
// now go through the active features for this crate, and add remaining features enabled by cargo through other crates
610+
if let Some(entry) = active_dependency_features
611+
.get_mut(&(krate.name.clone(), dependency.name.clone()))
612+
{
613+
// find features on these active deps, that must now be enabled, we show that on the graph with a note
614+
for feat in self
615+
.workspace
616+
.find_crate_opt(&dependency.name)
617+
.iter()
618+
.flat_map(|d| d.active_features.iter())
619+
.flatten()
620+
.filter(|f| !f.is_special_default_enabling_feature())
621+
{
622+
// meh
623+
let val = (feat.clone(), true);
624+
let false_val = (feat.clone(), false);
625+
if !entry.contains(&val) && !entry.contains(&false_val) {
626+
entry.push(val);
589627
}
590628
}
591629
}
592630
}
593631
}
632+
594633
// finally remove all enable_default_for_ features not to pollute the output
595634
// and insert the previously computed active dependency features
596635
for krate in self.workspace.all_crates_mut() {

codegen/src/passes/write_meta.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ pub(crate) fn write_meta(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
5151
k.to_string(),
5252
Dependency {
5353
version: d.version.to_string(),
54-
features: features.iter().map(|f| f.to_string()).collect(),
54+
features: features
55+
.iter()
56+
.map(|(feat_name, _)| feat_name.to_string())
57+
.collect(),
5558
},
5659
),
5760
None => todo!(),

crates/bindings/bevy_a11y_bms_bindings/Cargo.toml

Lines changed: 7 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings/bevy_a11y_bms_bindings/src/lib.rs

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings/bevy_animation_bms_bindings/Cargo.toml

Lines changed: 20 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)