Skip to content

Commit 1e87793

Browse files
committed
Upgrade to bevy 0.16
* Move from utils::HashMap to platform::collections::HashMap * Change to IntoSchedules vs IntoSystems * Change in namespaces
1 parent 040cc4a commit 1e87793

File tree

47 files changed

+577
-632
lines changed

Some content is hidden

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

47 files changed

+577
-632
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: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
@@ -76,37 +76,35 @@ profile_with_tracy = ["bevy/trace_tracy"]
7676
[dependencies]
7777
bevy = { workspace = true }
7878
bevy_mod_scripting_core = { workspace = true }
79-
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.12.0", optional = true }
80-
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.12.0", optional = true }
79+
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.13.0", optional = true }
80+
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.13.0", optional = true }
8181
# bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.9.0-alpha.2", optional = true }
8282
bevy_mod_scripting_functions = { workspace = true }
8383
bevy_mod_scripting_derive = { workspace = true }
8484

8585
[workspace.dependencies]
8686
profiling = { version = "1.0" }
87-
bevy = { version = "0.15.3", default-features = false }
88-
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.12.0" }
89-
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.12.0", default-features = false }
90-
bevy_mod_scripting_derive = { path = "crates/bevy_mod_scripting_derive", version = "0.12.0" }
87+
bevy = { version = "0.16.0", default-features = false }
88+
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.13.0" }
89+
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.13.0", default-features = false }
90+
bevy_mod_scripting_derive = { path = "crates/bevy_mod_scripting_derive", version = "0.13.0" }
9191

9292
# test utilities
9393
script_integration_test_harness = { path = "crates/testing_crates/script_integration_test_harness" }
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.2" }
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 = { git = "https://github.com/Katsutoshii/bevy-console", branch = "bevy-0.16.0"}
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

crates/bevy_api_gen/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ log = "0.4"
4141
env_logger = "0.11"
4242
rustc_plugin = "0.12.0-nightly-2024-12-15"
4343
indexmap = "2"
44-
tempdir = "0.3"
4544
cargo_metadata = "0.18"
4645
serde_json = "1"
4746
serde = "1"
@@ -52,7 +51,6 @@ include_dir = "0.7"
5251
prettyplease = "0.2"
5352
convert_case = "0.6"
5453
syn = { version = "2", features = ["parsing"], no-default-features = true }
55-
clap-verbosity-flag = "2.2"
5654
itertools = "0.12"
5755
chrono = "0.4"
5856

crates/bevy_mod_scripting_core/Cargo.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_mod_scripting_core"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
@@ -29,19 +29,15 @@ mlua = { version = "0.10", default-features = false, optional = true }
2929
rhai = { version = "1.21", default-features = false, features = [
3030
"sync",
3131
], optional = true }
32-
bevy = { workspace = true, default-features = false, features = ["bevy_asset"] }
33-
thiserror = "1.0.31"
32+
bevy = { workspace = true, default-features = false, features = ["bevy_asset", "std"] }
3433
parking_lot = "0.12.1"
35-
dashmap = "6"
3634
smallvec = "1.11"
37-
itertools = "0.13"
38-
derivative = "2.2"
35+
itertools = "0.14"
3936
profiling = { workspace = true }
4037
bevy_mod_scripting_derive = { workspace = true }
4138
fixedbitset = "0.5"
42-
petgraph = "0.6"
43-
bevy_mod_debugdump = "0.12"
4439
bevy_system_reflection = { path = "../bevy_system_reflection", version = "0.1.1" }
40+
variadics_please = "1.1.0"
4541

4642
[dev-dependencies]
4743
test_utils = { workspace = true }

crates/bevy_mod_scripting_core/src/asset.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
//! Systems and resources for handling script assets and events
22
3-
use crate::{
4-
commands::{CreateOrUpdateScript, DeleteScript},
5-
error::ScriptError,
6-
script::ScriptId,
7-
IntoScriptPluginParams, ScriptingSystemSet,
8-
};
3+
use std::borrow::Cow;
4+
95
use bevy::{
106
app::{App, PreUpdate},
117
asset::{Asset, AssetEvent, AssetId, AssetLoader, AssetPath, Assets},
12-
ecs::system::Resource,
138
log::{debug, info, trace, warn},
9+
platform::collections::HashMap,
1410
prelude::{
15-
Commands, Event, EventReader, EventWriter, IntoSystemConfigs, IntoSystemSetConfigs, Res,
16-
ResMut,
11+
Commands, Event, EventReader, EventWriter, IntoScheduleConfigs, Res, ResMut, Resource,
1712
},
1813
reflect::TypePath,
19-
utils::hashbrown::HashMap,
2014
};
21-
use std::borrow::Cow;
15+
16+
use crate::{
17+
commands::{CreateOrUpdateScript, DeleteScript},
18+
error::ScriptError,
19+
script::ScriptId,
20+
IntoScriptPluginParams, ScriptingSystemSet,
21+
};
2222

2323
/// Represents a scripting language. Languages which compile into another language should use the target language as their language.
2424
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
@@ -231,7 +231,7 @@ pub(crate) fn dispatch_script_asset_events(
231231
language,
232232
};
233233
debug!("Script loaded, populating metadata: {:?}:", metadata);
234-
script_asset_events.send(ScriptAssetEvent::Added(metadata.clone()));
234+
script_asset_events.write(ScriptAssetEvent::Added(metadata.clone()));
235235
metadata_store.insert(*id, metadata);
236236
} else {
237237
warn!("A script was added but it's asset was not found, failed to compute metadata. This script will not be loaded. Did you forget to store `Handle<ScriptAsset>` somewhere?. {}", id);
@@ -241,15 +241,15 @@ pub(crate) fn dispatch_script_asset_events(
241241
AssetEvent::Removed { id } => {
242242
if let Some(metadata) = metadata_store.get(*id) {
243243
debug!("Script removed: {:?}", metadata);
244-
script_asset_events.send(ScriptAssetEvent::Removed(metadata.clone()));
244+
script_asset_events.write(ScriptAssetEvent::Removed(metadata.clone()));
245245
} else {
246246
warn!("Script metadata not found for removed script asset: {}. Cannot properly clean up script", id);
247247
}
248248
}
249249
AssetEvent::Modified { id } => {
250250
if let Some(metadata) = metadata_store.get(*id) {
251251
debug!("Script modified: {:?}", metadata);
252-
script_asset_events.send(ScriptAssetEvent::Modified(metadata.clone()));
252+
script_asset_events.write(ScriptAssetEvent::Modified(metadata.clone()));
253253
} else {
254254
warn!("Script metadata not found for modified script asset: {}. Cannot properly update script", id);
255255
}
@@ -572,9 +572,9 @@ mod tests {
572572
struct DummyPlugin;
573573

574574
impl IntoScriptPluginParams for DummyPlugin {
575-
type R = ();
576-
type C = ();
577575
const LANGUAGE: Language = Language::Lua;
576+
type C = ();
577+
type R = ();
578578

579579
fn build_runtime() -> Self::R {}
580580
}

crates/bevy_mod_scripting_core/src/bindings/access_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::hash::{BuildHasherDefault, Hasher};
44

55
use bevy::{
66
ecs::{component::ComponentId, world::unsafe_world_cell::UnsafeWorldCell},
7+
platform::collections::{HashMap, HashSet},
78
prelude::Resource,
8-
utils::hashbrown::{HashMap, HashSet},
99
};
1010
use parking_lot::Mutex;
1111
use smallvec::SmallVec;

crates/bevy_mod_scripting_core/src/bindings/allocator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! An allocator used to control the lifetime of allocations
22
3+
use bevy::prelude::Resource;
34
use bevy::{
45
app::{App, Plugin, PostUpdate},
56
diagnostic::{Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic},
6-
ecs::system::{Res, Resource},
7+
ecs::system::Res,
8+
platform::collections::HashMap,
79
prelude::ResMut,
810
reflect::PartialReflect,
9-
utils::hashbrown::HashMap,
1011
};
1112
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
1213
use std::{

crates/bevy_mod_scripting_core/src/bindings/function/from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,4 +585,4 @@ macro_rules! impl_from_script_tuple {
585585
};
586586
}
587587

588-
bevy::utils::all_tuples!(impl_from_script_tuple, 1, 14, T);
588+
variadics_please::all_tuples!(impl_from_script_tuple, 1, 14, T);

crates/bevy_mod_scripting_core/src/bindings/function/into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@ macro_rules! impl_into_script_tuple {
199199
}
200200
}
201201

202-
bevy::utils::all_tuples!(impl_into_script_tuple, 1, 14, T);
202+
variadics_please::all_tuples!(impl_into_script_tuple, 1, 14, T);

crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::{
1010
error::InteropError,
1111
ScriptValue,
1212
};
13+
use bevy::platform::collections::HashMap;
1314
use bevy::prelude::{Reflect, Resource};
14-
use bevy::utils::hashbrown::HashMap;
1515
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
1616
use std::borrow::Cow;
1717
use std::collections::VecDeque;
@@ -622,13 +622,13 @@ macro_rules! impl_script_function {
622622
};
623623
}
624624

625-
bevy::utils::all_tuples!(impl_script_function, 0, 13, T);
625+
variadics_please::all_tuples!(impl_script_function, 0, 13, T);
626626

627627
#[cfg(test)]
628628
mod test {
629-
use super::*;
629+
use super::*;
630630

631-
fn with_local_world<F: Fn()>(f: F) {
631+
fn with_local_world<F: Fn()>(f: F) {
632632
let mut world = bevy::prelude::World::default();
633633
WorldGuard::with_static_guard(&mut world, |world| {
634634
ThreadWorldContainer.set_world(world).unwrap();

0 commit comments

Comments
 (0)