Skip to content

Commit a8264a0

Browse files
alexparlettmakspll
andauthored
feat!: Update to Bevy 0.16 (#422)
Co-authored-by: makspll <makspl17@gmail.com>
1 parent 67c5a5d commit a8264a0

Some content is hidden

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

66 files changed

+12211
-2873
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ assets/scripts/tlconfig.lua
1515
**.log
1616
**build/
1717
.html
18+
.idea/
1819

1920
/assets/**/*.lad.json
20-
/docs/src/ladfiles/*.lad.json
21+
/docs/src/ladfiles/*.lad.json

Cargo.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ features = ["lua54", "rhai"]
2323
[features]
2424
default = [
2525
"core_functions",
26-
"bevy_core_bindings",
2726
"bevy_ecs_bindings",
28-
"bevy_hierarchy_bindings",
2927
"bevy_input_bindings",
3028
"bevy_math_bindings",
3129
"bevy_reflect_bindings",
@@ -48,9 +46,7 @@ luau = ["bevy_mod_scripting_lua/luau", "lua"]
4846

4947
# bindings
5048
core_functions = ["bevy_mod_scripting_functions/core_functions"]
51-
bevy_core_bindings = ["bevy_mod_scripting_functions/bevy_core"]
5249
bevy_ecs_bindings = ["bevy_mod_scripting_functions/bevy_ecs"]
53-
bevy_hierarchy_bindings = ["bevy_mod_scripting_functions/bevy_hierarchy"]
5450
bevy_input_bindings = ["bevy_mod_scripting_functions/bevy_input"]
5551
bevy_math_bindings = ["bevy_mod_scripting_functions/bevy_math"]
5652
bevy_reflect_bindings = ["bevy_mod_scripting_functions/bevy_reflect"]
@@ -75,6 +71,8 @@ profile_with_tracy = ["bevy/trace_tracy"]
7571

7672
[dependencies]
7773
bevy = { workspace = true }
74+
bevy_math = { workspace = true }
75+
bevy_reflect = { workspace = true }
7876
bevy_mod_scripting_core = { workspace = true }
7977
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.13.0", optional = true }
8078
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.13.0", optional = true }
@@ -84,7 +82,9 @@ bevy_mod_scripting_derive = { workspace = true }
8482

8583
[workspace.dependencies]
8684
profiling = { version = "1.0" }
87-
bevy = { version = "0.15.3", default-features = false }
85+
bevy = { version = "0.16.0", default-features = false }
86+
bevy_math = { version = "0.16.0" }
87+
bevy_reflect = { version = "0.16.0" }
8888
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.13.0" }
8989
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.13.0", default-features = false }
9090
bevy_mod_scripting_derive = { path = "crates/bevy_mod_scripting_derive", version = "0.13.0" }
@@ -94,19 +94,17 @@ script_integration_test_harness = { path = "crates/testing_crates/script_integra
9494
test_utils = { path = "crates/testing_crates/test_utils" }
9595

9696
[dev-dependencies]
97-
bevy = { workspace = true, default-features = true }
97+
bevy = { workspace = true, default-features = true, features = ["std"] }
9898
clap = { version = "4.1", features = ["derive"] }
99-
rand = "0.8.5"
100-
bevy_console = "0.13"
101-
# rhai-rand = "0.1"
99+
rand = "0.9.1"
102100
criterion = { version = "0.5" }
103-
ansi-parser = "0.9"
104101
ladfile_builder = { path = "crates/ladfile_builder", version = "0.3.3" }
105102
script_integration_test_harness = { workspace = true }
106103
test_utils = { workspace = true }
107104
libtest-mimic = "0.8"
108105
tracing-tracy = "0.11"
109106
regex = "1.11"
107+
bevy_console = "0.14"
110108

111109
[workspace]
112110
members = [

assets/tests/add_system/added_systems_run_in_parallel.lua

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,30 @@ function on_test()
2121

2222
local expected_dot_graph = [[
2323
digraph {
24-
node_0 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
25-
node_1 [label="on_test_post_update"];
26-
node_2 [label="script_integration_test_harness::dummy_before_post_update_system"];
27-
node_3 [label="script_integration_test_harness::dummy_post_update_system"];
28-
node_4 [label="custom_system_a"];
29-
node_5 [label="custom_system_b"];
30-
node_6 [label="SystemSet GarbageCollection"];
31-
node_7 [label="SystemSet ScriptSystem(custom_system_a)"];
32-
node_8 [label="SystemSet ScriptSystem(custom_system_b)"];
33-
node_0 -> node_6 [color=red, label="child of", arrowhead=diamond];
34-
node_4 -> node_7 [color=red, label="child of", arrowhead=diamond];
35-
node_5 -> node_8 [color=red, label="child of", arrowhead=diamond];
36-
node_1 -> node_4 [color=blue, label="runs before", arrowhead=normal];
37-
node_1 -> node_5 [color=blue, label="runs before", arrowhead=normal];
38-
node_2 -> node_3 [color=blue, label="runs before", arrowhead=normal];
24+
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
25+
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
26+
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
27+
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_core::asset::ScriptAsset>::asset_events"];
28+
node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
29+
node_5 [label="on_test_post_update"];
30+
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
31+
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
32+
node_8 [label="custom_system_a"];
33+
node_9 [label="custom_system_b"];
34+
node_10 [label="SystemSet AssetEvents"];
35+
node_11 [label="SystemSet GarbageCollection"];
36+
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
37+
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
38+
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
39+
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
40+
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
41+
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
42+
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
43+
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
44+
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
45+
node_5 -> node_8 [color=blue, label="runs before", arrowhead=normal];
46+
node_5 -> node_9 [color=blue, label="runs before", arrowhead=normal];
47+
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
3948
}
4049
]]
4150

assets/tests/add_system/added_systems_run_in_parallel.rhai

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,30 @@ fn on_test() {
2020

2121
let expected_dot_graph = `
2222
digraph {
23-
node_0 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
24-
node_1 [label="on_test_post_update"];
25-
node_2 [label="script_integration_test_harness::dummy_before_post_update_system"];
26-
node_3 [label="script_integration_test_harness::dummy_post_update_system"];
27-
node_4 [label="custom_system_a"];
28-
node_5 [label="custom_system_b"];
29-
node_6 [label="SystemSet GarbageCollection"];
30-
node_7 [label="SystemSet ScriptSystem(custom_system_a)"];
31-
node_8 [label="SystemSet ScriptSystem(custom_system_b)"];
32-
node_0 -> node_6 [color=red, label="child of", arrowhead=diamond];
33-
node_4 -> node_7 [color=red, label="child of", arrowhead=diamond];
34-
node_5 -> node_8 [color=red, label="child of", arrowhead=diamond];
35-
node_1 -> node_4 [color=blue, label="runs before", arrowhead=normal];
36-
node_1 -> node_5 [color=blue, label="runs before", arrowhead=normal];
37-
node_2 -> node_3 [color=blue, label="runs before", arrowhead=normal];
23+
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
24+
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
25+
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
26+
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_core::asset::ScriptAsset>::asset_events"];
27+
node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
28+
node_5 [label="on_test_post_update"];
29+
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
30+
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
31+
node_8 [label="custom_system_a"];
32+
node_9 [label="custom_system_b"];
33+
node_10 [label="SystemSet AssetEvents"];
34+
node_11 [label="SystemSet GarbageCollection"];
35+
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
36+
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
37+
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
38+
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
39+
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
40+
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
41+
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
42+
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
43+
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
44+
node_5 -> node_8 [color=blue, label="runs before", arrowhead=normal];
45+
node_5 -> node_9 [color=blue, label="runs before", arrowhead=normal];
46+
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
3847
}`;
3948

4049
assert_str_eq.call(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph");

benches/benchmarks.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
use bevy::log::tracing_subscriber::layer::SubscriberExt;
2-
use bevy::log::{tracing_subscriber, Level};
3-
use bevy::reflect::Reflect;
4-
use bevy::utils::tracing;
5-
use bevy::utils::tracing::span;
1+
extern crate bevy_mod_scripting;
2+
extern crate script_integration_test_harness;
3+
extern crate test_utils;
4+
use std::{collections::HashMap, path::PathBuf, sync::LazyLock, time::Duration};
5+
6+
use bevy::{
7+
log::{
8+
tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt, Level,
9+
},
10+
reflect::Reflect,
11+
};
612
use bevy_mod_scripting_core::bindings::{
713
FromScript, IntoScript, Mut, Ref, ReflectReference, ScriptValue, Val,
814
};
9-
use criterion::{criterion_main, measurement::Measurement, BenchmarkGroup, Criterion};
10-
use criterion::{BatchSize, BenchmarkFilter};
15+
use criterion::{
16+
criterion_main, measurement::Measurement, BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion,
17+
};
1118
use regex::Regex;
12-
use script_integration_test_harness::test_functions::rand::Rng;
1319
use script_integration_test_harness::{
1420
make_test_lua_plugin, make_test_rhai_plugin, perform_benchmark_with_generator,
1521
run_lua_benchmark, run_plugin_script_load_benchmark, run_rhai_benchmark,
22+
test_functions::rand::Rng,
1623
};
17-
use std::collections::HashMap;
18-
use std::{path::PathBuf, sync::LazyLock, time::Duration};
1924
use test_utils::{discover_all_tests, Test};
2025

21-
extern crate bevy_mod_scripting;
22-
extern crate script_integration_test_harness;
23-
extern crate test_utils;
24-
2526
static ENABLE_PROFILING: LazyLock<bool> =
2627
LazyLock::new(|| std::env::var("ENABLE_PROFILING").is_ok());
2728

build_scripts.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
WORKSPACE_DIR="$PWD"
3+
4+
cd "$(dirname "$0")"
5+
# if the path is in /bevy_api_gen then we run the codegen check
6+
7+
if [[ "$WORKSPACE_DIR" == *"/bevy_api_gen"* ]]; then
8+
# save output to file as well as stdout and stderr
9+
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
10+
elif [[ "$WORKSPACE_DIR" == *"/xtask"* ]]; then
11+
cd "$WORKSPACE_DIR"
12+
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
13+
else
14+
cd "$WORKSPACE_DIR"
15+
cargo check --quiet --workspace --message-format=json --all-targets --keep-going
16+
fi

codegen_bevy_features.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded
1+
bevy_asset,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded,std,async_executor

crates/bevy_api_gen/Cargo.bootstrap.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66

77
[dependencies]
88
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
9-
bevy_reflect = { version = "0.15.3", features = [
10-
"bevy",
9+
bevy_reflect = { version = "0.16.0", features = [
10+
"smol_str",
1111
"glam",
1212
"petgraph",
1313
"smallvec",

crates/bevy_api_gen/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ codegen-units = 8
3030
incremental = false
3131
debug = false
3232

33-
[rust-analyzer.rustc]
34-
source = "discover"
3533

3634
[package.metadata.rust-analyzer]
3735
rustc_private = true
@@ -41,7 +39,6 @@ log = "0.4"
4139
env_logger = "0.11"
4240
rustc_plugin = "0.12.0-nightly-2024-12-15"
4341
indexmap = "2"
44-
tempdir = "0.3"
4542
cargo_metadata = "0.18"
4643
serde_json = "1"
4744
serde = "1"
@@ -51,8 +48,7 @@ strum = { version = "0.26", features = ["derive"] }
5148
include_dir = "0.7"
5249
prettyplease = "0.2"
5350
convert_case = "0.6"
54-
syn = { version = "2", features = ["parsing"], no-default-features = true }
55-
clap-verbosity-flag = "2.2"
51+
syn = { version = "2", features = ["parsing"], default-features = false }
5652
itertools = "0.12"
5753
chrono = "0.4"
5854

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ fn main() {
6262
.map(|s| s.to_owned())
6363
.collect::<Vec<String>>();
6464

65+
// log all dependencies
66+
debug!("Enabled dependencies: {}", dependencies.join(","));
67+
6568
Some(dependencies)
6669
}
6770
_ => None,
@@ -110,36 +113,34 @@ fn main() {
110113
if !output.is_dir() {
111114
panic!("Output is not a directory");
112115
}
113-
let crates = std::fs::read_dir(&output)
114-
.expect("Could not read output directory")
115-
.filter_map(|d| {
116-
let entry = d.expect("Could not read entry in output directory");
117-
let path = entry.path();
118-
if path.extension().is_some_and(|ext| ext == "rs")
119-
&& path.file_stem().is_some_and(|s| s != "mod")
120-
{
121-
Some(path.file_stem().unwrap().to_owned())
122-
} else {
123-
None
124-
}
125-
});
116+
126117
let meta_loader = MetaLoader::new(vec![output.to_owned()], workspace_meta);
127-
let mut crates: Vec<_> = crates
128-
.map(|c| {
129-
let name = c.to_str().unwrap().to_owned();
130-
log::info!("Collecting crate: {}", name);
131-
let meta = meta_loader
132-
.meta_for(&name)
133-
.expect("Could not find meta file for crate");
134-
Crate { name, meta }
118+
let mut crates = meta_loader
119+
.iter_meta()
120+
.filter_map(|m| {
121+
log::debug!(
122+
"Processing crate: {}, will generate: {}",
123+
m.crate_name(),
124+
m.will_generate()
125+
);
126+
m.will_generate().then_some(Crate {
127+
name: m.crate_name().to_owned(),
128+
meta: m,
129+
})
135130
})
136-
.collect();
131+
.collect::<Vec<_>>();
137132

138133
crates.sort_by(|a, b| a.name.cmp(&b.name));
139134

140-
let context = Collect { crates, api_name };
135+
let json = serde_json::to_string_pretty(
136+
&crates.iter().map(|c| c.name.clone()).collect::<Vec<_>>(),
137+
)
138+
.unwrap();
139+
140+
let collect = Collect { crates, api_name };
141+
141142
let mut context =
142-
Context::from_serialize(context).expect("Could not create template context");
143+
Context::from_serialize(collect).expect("Could not create template context");
143144

144145
extend_context_with_args(args.template_args.as_deref(), &mut context);
145146

@@ -148,6 +149,11 @@ fn main() {
148149
.expect("Failed to render mod.rs");
149150
file.flush().unwrap();
150151
log::info!("Succesfully generated mod.rs");
152+
153+
// put json of Collect context into stdout
154+
std::io::stdout()
155+
.write_all(json.as_bytes())
156+
.expect("Failed to write Collect context to stdout");
151157
return;
152158
}
153159
_ => {}

0 commit comments

Comments
 (0)