Skip to content

Commit 818c903

Browse files
committed
fix codegen
1 parent 39d13fa commit 818c903

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

xtask/src/main.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,20 +1256,21 @@ impl Xtasks {
12561256
"crates/bevy_mod_scripting_functions",
12571257
)?;
12581258

1259-
let expand_crates = std::fs::read_dir(&output_dir)?;
1260-
for entry in expand_crates {
1261-
let entry = entry?;
1262-
let path = entry.path();
1263-
if path.extension().and_then(|s| s.to_str()) != Some("rs") || path.ends_with("mod.rs") {
1264-
continue;
1265-
}
1266-
1267-
let without_extension = path.file_stem().unwrap().to_str().unwrap();
1259+
let expand_crates = (std::fs::read_dir(&output_dir)?).collect::<Result<Vec<_>, _>>()?;
1260+
let crate_names = expand_crates
1261+
.iter()
1262+
.filter(|s| {
1263+
s.path().is_file() && s.path().ends_with(".rs") && !s.path().ends_with("mod.rs")
1264+
})
1265+
.map(|s| s.path().file_stem().unwrap().to_str().unwrap().to_owned())
1266+
.collect::<Vec<_>>();
1267+
let features = crate_names.join(",");
1268+
for entry in crate_names {
12681269
let args = vec![
12691270
String::from("expand"),
1270-
format!("bevy_bindings::{without_extension}"),
1271+
format!("bevy_bindings::{entry}"),
12711272
String::from("--features"),
1272-
String::from(without_extension),
1273+
features.clone(),
12731274
];
12741275
let expand_cmd = Self::run_system_command(
12751276
&main_workspace_app_settings,
@@ -1288,7 +1289,7 @@ impl Xtasks {
12881289
.take(output.lines().count() - 2)
12891290
.collect::<Vec<_>>()
12901291
.join("\n");
1291-
1292+
let path = output_dir.join(format!("{entry}.rs"));
12921293
std::fs::write(&path, output)
12931294
.with_context(|| format!("writing expanded code to {path:?}"))?;
12941295
info!("Wrote expanded code to {path:?}");

0 commit comments

Comments
 (0)