Skip to content

Commit 39d13fa

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactor/restructure-crates
2 parents c719d68 + 5e0c4f4 commit 39d13fa

File tree

6 files changed

+96
-14
lines changed

6 files changed

+96
-14
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/target
2+
**/Cargo.lock

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
crates/bevy_script_api/providers/*.rs linguist-generated
2-
crates/bevy_script_api/providers/*.rs -diff -merge
1+
crates/bevy_mod_scripting_functions/src/bevy_bindings/*.rs linguist-generated
2+
crates/bevy_mod_scripting_functions/src/bevy_gindings/*.rs -diff -merge

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", v
9393

9494
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.15.1" }
9595
bevy = { version = "0.16.0", default-features = false }
96-
bevy_math = { version = "0.16.0", default-features = false }
96+
bevy_math = { version = "0.16.0", default-features = false, features = ["std"] }
9797
bevy_transform = { version = "0.16.0", default-features = false }
9898
bevy_reflect = { version = "0.16.0", default-features = false }
9999
bevy_ecs = { version = "0.16.0", default-features = false }
@@ -138,7 +138,9 @@ anyhow = { version = "1.0", default-features = false }
138138

139139
# development and testing
140140

141-
pretty_assertions = { version = "1.4", default-features = false, features=["std"] }
141+
pretty_assertions = { version = "1.4", default-features = false, features = [
142+
"std",
143+
] }
142144
manifest-dir-macros = { version = "0.1.18", default-features = false }
143145
assert_cmd = { version = "2.0", default-features = false }
144146
tokio = { version = "1", default-features = false }

crates/bevy_mod_scripting_functions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "readme.md"
1414
[features]
1515
bevy_ecs = []
1616
bevy_input = ["dep:bevy_input"]
17-
bevy_math = ["dep:bevy_math"]
17+
bevy_math = ["dep:bevy_math", "dep:glam"]
1818
bevy_reflect = ["dep:bevy_reflect", "dep:glam", "dep:uuid", "dep:smol_str"]
1919
bevy_time = ["dep:bevy_time"]
2020
bevy_transform = ["dep:bevy_transform"]

crates/languages/bevy_mod_scripting_rhai/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bevy_app = { workspace = true, default-features = false, features = [] }
2222
bevy_log = { workspace = true, default-features = false, features = [] }
2323
rhai = { workspace = true, features = ["std"] }
2424
bevy_mod_scripting_core = { workspace = true, features = ["rhai_impls"] }
25-
strum = { workspace = true }
25+
strum = { workspace = true, features = ["derive"] }
2626
parking_lot = { workspace = true }
2727

2828
[lints]

xtask/src/main.rs

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ impl Xtasks {
873873
context: &str,
874874
add_args: I,
875875
dir: Option<&Path>,
876-
) -> Result<()> {
876+
capture_streams_in_output: bool,
877+
) -> Result<Output> {
877878
info!("Running system command: {command}");
878879

879880
let working_dir = match dir {
@@ -882,18 +883,25 @@ impl Xtasks {
882883
};
883884

884885
let mut cmd = Command::new(command);
885-
cmd.args(add_args)
886-
.stdout(std::process::Stdio::inherit())
887-
.stderr(std::process::Stdio::inherit())
888-
.current_dir(working_dir);
886+
cmd.args(add_args).current_dir(working_dir);
887+
888+
if !capture_streams_in_output {
889+
cmd.stdout(std::process::Stdio::inherit())
890+
.stderr(std::process::Stdio::inherit());
891+
}
889892

890893
info!("Using command: {cmd:?}");
891894

892895
let output = cmd.output();
893-
info!("Command output: {output:?}");
896+
if !capture_streams_in_output {
897+
info!("Command status: {:?}", output.as_ref().map(|o| o.status));
898+
} else {
899+
info!("Command output: {output:?}");
900+
}
901+
894902
let output = output.with_context(|| context.to_owned())?;
895903
match output.status.code() {
896-
Some(0) => Ok(()),
904+
Some(0) => Ok(output),
897905
_ => bail!(
898906
"{} failed with exit code: {}",
899907
context,
@@ -1139,6 +1147,7 @@ impl Xtasks {
11391147
"Failed to install bevy_api_gen",
11401148
vec!["install", "--path", "."],
11411149
None,
1150+
false,
11421151
)?;
11431152

11441153
let metadata = Self::main_workspace_cargo_metadata()?;
@@ -1168,6 +1177,7 @@ impl Xtasks {
11681177
".",
11691178
],
11701179
None,
1180+
false,
11711181
);
11721182

11731183
// fetch the tags
@@ -1177,6 +1187,7 @@ impl Xtasks {
11771187
"Failed to fetch bevy tags",
11781188
vec!["fetch", "--tags"],
11791189
Some(&bevy_dir),
1190+
false,
11801191
)?;
11811192

11821193
// checkout the version tag
@@ -1186,6 +1197,7 @@ impl Xtasks {
11861197
"Failed to checkout bevy tag",
11871198
vec!["checkout", format!("v{bevy_version}").as_str()],
11881199
Some(&bevy_dir),
1200+
false,
11891201
)?;
11901202

11911203
// run bevy_api_gen
@@ -1237,6 +1249,51 @@ impl Xtasks {
12371249
false,
12381250
)?;
12391251

1252+
// now expand the macros and replace the files in place
1253+
// by running cargo expand --features crate_name and capturing the output
1254+
let functions_crate_dir = Self::relative_workspace_dir(
1255+
&main_workspace_app_settings,
1256+
"crates/bevy_mod_scripting_functions",
1257+
)?;
1258+
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();
1268+
let args = vec![
1269+
String::from("expand"),
1270+
format!("bevy_bindings::{without_extension}"),
1271+
String::from("--features"),
1272+
String::from(without_extension),
1273+
];
1274+
let expand_cmd = Self::run_system_command(
1275+
&main_workspace_app_settings,
1276+
"cargo",
1277+
"pre-expanding generated code",
1278+
args,
1279+
Some(&functions_crate_dir),
1280+
true,
1281+
)?;
1282+
1283+
let output = String::from_utf8(expand_cmd.stdout)?;
1284+
// remove the first mod <mod name> { .. } wrapper
1285+
let output = output
1286+
.lines()
1287+
.skip(1)
1288+
.take(output.lines().count() - 2)
1289+
.collect::<Vec<_>>()
1290+
.join("\n");
1291+
1292+
std::fs::write(&path, output)
1293+
.with_context(|| format!("writing expanded code to {path:?}"))?;
1294+
info!("Wrote expanded code to {path:?}");
1295+
}
1296+
12401297
Ok(())
12411298
}
12421299

@@ -1347,6 +1404,7 @@ impl Xtasks {
13471404
"Failed to build or serve mdbook docs",
13481405
args,
13491406
Some(Path::new("docs")),
1407+
false,
13501408
)?;
13511409

13521410
Ok(())
@@ -1686,6 +1744,7 @@ impl Xtasks {
16861744
"target/coverage/html",
16871745
],
16881746
None,
1747+
false,
16891748
)?;
16901749

16911750
Self::run_system_command(
@@ -1708,6 +1767,7 @@ impl Xtasks {
17081767
"target/coverage/lcov.info",
17091768
],
17101769
None,
1770+
false,
17111771
)?;
17121772
}
17131773
Ok(())
@@ -1843,6 +1903,7 @@ impl Xtasks {
18431903
"Failed to install Linux dependencies",
18441904
vec!["-c", install_cmd.as_str()],
18451905
None,
1906+
false,
18461907
)?;
18471908
}
18481909

@@ -1864,6 +1925,7 @@ impl Xtasks {
18641925
"bencher_cli",
18651926
],
18661927
None,
1928+
false,
18671929
)?;
18681930
// install cargo mdbook
18691931
Self::run_system_command(
@@ -1872,6 +1934,7 @@ impl Xtasks {
18721934
"Failed to install mdbook",
18731935
vec!["install", "mdbook"],
18741936
None,
1937+
false,
18751938
)?;
18761939

18771940
// install grcov
@@ -1881,6 +1944,17 @@ impl Xtasks {
18811944
"Failed to install grcov",
18821945
vec!["install", "grcov"],
18831946
None,
1947+
false,
1948+
)?;
1949+
1950+
// install cargo expand
1951+
Self::run_system_command(
1952+
&app_settings,
1953+
"cargo",
1954+
"Failed to install cargo expand",
1955+
vec!["install", "cargo-expand"],
1956+
None,
1957+
false,
18841958
)?;
18851959

18861960
// install nightly toolchaing for bevy api gen
@@ -1891,6 +1965,7 @@ impl Xtasks {
18911965
"Failed to install nightly toolchain",
18921966
vec!["toolchain", "install", toolchain.as_str()],
18931967
None,
1968+
false,
18941969
)?;
18951970

18961971
let rustup_components_args = [
@@ -1910,6 +1985,7 @@ impl Xtasks {
19101985
"Failed to install rust components",
19111986
rustup_components_args,
19121987
None,
1988+
false,
19131989
)?;
19141990

19151991
// add components on nightly toolchain
@@ -1921,6 +1997,7 @@ impl Xtasks {
19211997
.iter()
19221998
.chain(["--toolchain", toolchain.as_str()].iter()),
19231999
Some(Path::new(".")),
2000+
false,
19242001
)?;
19252002

19262003
// create .vscode settings
@@ -2018,6 +2095,7 @@ impl Xtasks {
20182095
"Failed to install binary",
20192096
vec!["install", "--path", binary_path.to_str().unwrap()],
20202097
None,
2098+
false,
20212099
)?;
20222100

20232101
Ok(())
@@ -2030,7 +2108,7 @@ impl Xtasks {
20302108
fn pop_cargo_env() -> Result<()> {
20312109
let env = std::env::vars().collect::<Vec<_>>();
20322110
// RUSTUP TOOLCHAIN exclude is a temporary fix, it might make deving the api codegen crate not work
2033-
let exclude_list = [];
2111+
let exclude_list = ["CARGO_HOME"];
20342112

20352113
for (key, value) in env.iter() {
20362114
if key.starts_with("CARGO_") && !exclude_list.contains(&(key.as_str())) {

0 commit comments

Comments
 (0)