Skip to content

feat!: Update to Bevy 0.16 #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6bae518
Upgrade to bevy 0.16
alexparlett May 22, 2025
922ab68
Merge branch 'main' into bevy_0.16
alexparlett May 25, 2025
f1a200b
Fix compile issues not seen when using as branch
alexparlett May 26, 2025
802c864
Update bevy_console
alexparlett May 29, 2025
616fc89
Merge remote-tracking branch 'origin/main' into bevy_0.16
makspll Jul 3, 2025
5f9fb52
make codegen work
makspll Jul 5, 2025
82f8e94
small refactor
makspll Jul 5, 2025
22a41b8
actually skip functions with generics that don't appear as types
makspll Jul 5, 2025
6f8a0f3
try make xtask work properly again
makspll Jul 6, 2025
63c6b01
cargo fmt
makspll Jul 6, 2025
2515b5e
remove xtask changes from PR
makspll Jul 6, 2025
65f8fb5
Merge remote-tracking branch 'origin/main' into bevy_0.16
makspll Jul 6, 2025
400cc47
clippy
makspll Jul 6, 2025
d1019fb
Merge branch 'main' into bevy_0.16
makspll Jul 6, 2025
f37f3b2
make api gen work with no_std crates better
makspll Jul 6, 2025
c60b849
Merge branch 'bevy_0.16' of https://github.com/alexparlett/bevy_mod_s…
makspll Jul 6, 2025
0b38370
correct collection code not to try to collect old crates
makspll Jul 7, 2025
ecd3550
remove deprecated bindings flags
makspll Jul 7, 2025
716c5b0
remove leftover references
makspll Jul 7, 2025
c5903bd
fix xtask
makspll Jul 7, 2025
ae956ba
remove unneeded imports
makspll Jul 7, 2025
7b77f93
they were in fact needed
makspll Jul 8, 2025
a862d25
fix issue with commands dispatched during a callback being run before…
makspll Aug 2, 2025
9641e89
manually flush command for entity spawning
makspll Aug 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ assets/scripts/tlconfig.lua
**.log
**build/
.html
.idea/

/assets/**/*.lad.json
/docs/src/ladfiles/*.lad.json
/docs/src/ladfiles/*.lad.json
25 changes: 13 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_mod_scripting"
version = "0.12.0"
version = "0.13.0"
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -76,37 +76,38 @@ profile_with_tracy = ["bevy/trace_tracy"]
[dependencies]
bevy = { workspace = true }
bevy_mod_scripting_core = { workspace = true }
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.12.0", optional = true }
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.12.0", optional = true }
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.13.0", optional = true }
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.13.0", optional = true }
# bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.9.0-alpha.2", optional = true }
bevy_mod_scripting_functions = { workspace = true }
bevy_mod_scripting_derive = { workspace = true }

[workspace.dependencies]
profiling = { version = "1.0" }
bevy = { version = "0.15.3", default-features = false }
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.12.0" }
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.12.0", default-features = false }
bevy_mod_scripting_derive = { path = "crates/bevy_mod_scripting_derive", version = "0.12.0" }
bevy_math = { version = "0.16.0", default-features = false }
bevy_reflect = { version = "0.16.0", default-features = false }
bevy_input = { version = "0.16.0", default-features = false }
bevy = { version = "0.16.0", default-features = false }
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.13.0" }
bevy_mod_scripting_functions = { path = "crates/bevy_mod_scripting_functions", version = "0.13.0", default-features = false }
bevy_mod_scripting_derive = { path = "crates/bevy_mod_scripting_derive", version = "0.13.0" }

# test utilities
script_integration_test_harness = { path = "crates/testing_crates/script_integration_test_harness" }
test_utils = { path = "crates/testing_crates/test_utils" }

[dev-dependencies]
bevy = { workspace = true, default-features = true }
bevy = { workspace = true, default-features = true, features = ["std"] }
clap = { version = "4.1", features = ["derive"] }
rand = "0.8.5"
bevy_console = "0.13"
# rhai-rand = "0.1"
rand = "0.9.1"
criterion = { version = "0.5" }
ansi-parser = "0.9"
ladfile_builder = { path = "crates/ladfile_builder", version = "0.3.2" }
script_integration_test_harness = { workspace = true }
test_utils = { workspace = true }
libtest-mimic = "0.8"
tracing-tracy = "0.11"
regex = "1.11"
bevy_console = "0.14"

[workspace]
members = [
Expand Down
39 changes: 24 additions & 15 deletions assets/tests/add_system/added_systems_run_in_parallel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,30 @@ function on_test()

local expected_dot_graph = [[
digraph {
node_0 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
node_1 [label="on_test_post_update"];
node_2 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_3 [label="script_integration_test_harness::dummy_post_update_system"];
node_4 [label="custom_system_a"];
node_5 [label="custom_system_b"];
node_6 [label="SystemSet GarbageCollection"];
node_7 [label="SystemSet ScriptSystem(custom_system_a)"];
node_8 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_6 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_7 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_8 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_4 [color=blue, label="runs before", arrowhead=normal];
node_1 -> node_5 [color=blue, label="runs before", arrowhead=normal];
node_2 -> node_3 [color=blue, label="runs before", arrowhead=normal];
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_core::asset::ScriptAsset>::asset_events"];
node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
node_5 [label="on_test_post_update"];
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
node_8 [label="custom_system_a"];
node_9 [label="custom_system_b"];
node_10 [label="SystemSet AssetEvents"];
node_11 [label="SystemSet GarbageCollection"];
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_8 [color=blue, label="runs before", arrowhead=normal];
node_5 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
}
]]

Expand Down
39 changes: 24 additions & 15 deletions assets/tests/add_system/added_systems_run_in_parallel.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,30 @@ fn on_test() {

let expected_dot_graph = `
digraph {
node_0 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
node_1 [label="on_test_post_update"];
node_2 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_3 [label="script_integration_test_harness::dummy_post_update_system"];
node_4 [label="custom_system_a"];
node_5 [label="custom_system_b"];
node_6 [label="SystemSet GarbageCollection"];
node_7 [label="SystemSet ScriptSystem(custom_system_a)"];
node_8 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_6 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_7 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_8 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_4 [color=blue, label="runs before", arrowhead=normal];
node_1 -> node_5 [color=blue, label="runs before", arrowhead=normal];
node_2 -> node_3 [color=blue, label="runs before", arrowhead=normal];
node_0 [label="bevy_asset::assets::Assets<bevy_asset::folder::LoadedFolder>::asset_events"];
node_1 [label="bevy_asset::assets::Assets<bevy_asset::assets::LoadedUntypedAsset>::asset_events"];
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_core::asset::ScriptAsset>::asset_events"];
node_4 [label="bevy_mod_scripting_core::bindings::allocator::garbage_collector"];
node_5 [label="on_test_post_update"];
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
node_8 [label="custom_system_a"];
node_9 [label="custom_system_b"];
node_10 [label="SystemSet AssetEvents"];
node_11 [label="SystemSet GarbageCollection"];
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_8 [color=blue, label="runs before", arrowhead=normal];
node_5 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
}`;

assert_str_eq.call(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph");
Expand Down
29 changes: 15 additions & 14 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
use bevy::log::tracing_subscriber::layer::SubscriberExt;
use bevy::log::{tracing_subscriber, Level};
use bevy::reflect::Reflect;
use bevy::utils::tracing;
use bevy::utils::tracing::span;
extern crate bevy_mod_scripting;
extern crate script_integration_test_harness;
extern crate test_utils;
use std::{collections::HashMap, path::PathBuf, sync::LazyLock, time::Duration};

use bevy::{
log::{
tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt, Level,
},
reflect::Reflect,
};
use bevy_mod_scripting_core::bindings::{
FromScript, IntoScript, Mut, Ref, ReflectReference, ScriptValue, Val,
};
use criterion::{criterion_main, measurement::Measurement, BenchmarkGroup, Criterion};
use criterion::{BatchSize, BenchmarkFilter};
use criterion::{
criterion_main, measurement::Measurement, BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion,
};
use regex::Regex;
use script_integration_test_harness::test_functions::rand::Rng;
use script_integration_test_harness::{
make_test_lua_plugin, make_test_rhai_plugin, perform_benchmark_with_generator,
run_lua_benchmark, run_plugin_script_load_benchmark, run_rhai_benchmark,
test_functions::rand::Rng,
};
use std::collections::HashMap;
use std::{path::PathBuf, sync::LazyLock, time::Duration};
use test_utils::{discover_all_tests, Test};

extern crate bevy_mod_scripting;
extern crate script_integration_test_harness;
extern crate test_utils;

static ENABLE_PROFILING: LazyLock<bool> =
LazyLock::new(|| std::env::var("ENABLE_PROFILING").is_ok());

Expand Down
1 change: 1 addition & 0 deletions codegen_bevy_features.txt
Original file line number Diff line number Diff line change
@@ -0,0 +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
4 changes: 2 additions & 2 deletions crates/bevy_api_gen/Cargo.bootstrap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2021"

[dependencies]
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
bevy_reflect = { version = "0.15.3", features = [
"bevy",
bevy_reflect = { version = "0.16.0", features = [
"smol_str",
"glam",
"petgraph",
"smallvec",
Expand Down
12 changes: 5 additions & 7 deletions crates/bevy_api_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ codegen-units = 8
incremental = false
debug = false

[rust-analyzer.rustc]
source = "discover"
# [rust-analyzer.rustc]
# source = "discover"

[package.metadata.rust-analyzer]
rustc_private = true
# [package.metadata.rust-analyzer]
# rustc_private = true

[dependencies]
log = "0.4"
env_logger = "0.11"
rustc_plugin = "0.12.0-nightly-2024-12-15"
indexmap = "2"
tempdir = "0.3"
cargo_metadata = "0.18"
serde_json = "1"
serde = "1"
Expand All @@ -51,8 +50,7 @@ strum = { version = "0.26", features = ["derive"] }
include_dir = "0.7"
prettyplease = "0.2"
convert_case = "0.6"
syn = { version = "2", features = ["parsing"], no-default-features = true }
clap-verbosity-flag = "2.2"
syn = { version = "2", features = ["parsing"], default-features = false }
itertools = "0.12"
chrono = "0.4"

Expand Down
24 changes: 19 additions & 5 deletions crates/bevy_api_gen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub(crate) const DEF_PATHS_REFLECT: [&str; 2] =
["bevy_reflect::PartialReflect", "reflect::PartialReflect"];
pub(crate) const DEF_PATHS_GET_TYPE_REGISTRATION: [&str; 2] = [
"bevy_reflect::GetTypeRegistration",
"reflect::GetTypeRegistration",
"type_registry::GetTypeRegistration",
];

/// A collection of traits which we search for in the codebase, some are included purely for the methods they provide,
Expand Down Expand Up @@ -132,12 +132,26 @@ pub(crate) struct CachedTraits {
}

impl CachedTraits {
pub(crate) fn has_all_bms_traits(&self) -> bool {
self.bms_into_script.is_some() && self.bms_from_script.is_some()
pub(crate) fn missing_bms_traits(&self) -> Vec<&'static str> {
let mut missing = Vec::new();
if self.bms_into_script.is_none() {
missing.extend(DEF_PATHS_BMS_INTO_SCRIPT);
}
if self.bms_from_script.is_none() {
missing.extend(DEF_PATHS_BMS_FROM_SCRIPT);
}
missing
}

pub(crate) fn has_all_bevy_traits(&self) -> bool {
self.bevy_reflect_reflect.is_some() && self.bevy_reflect_get_type_registration.is_some()
pub(crate) fn missing_bevy_traits(&self) -> Vec<&'static str> {
let mut missing = Vec::new();
if self.bevy_reflect_reflect.is_none() {
missing.extend(DEF_PATHS_REFLECT);
}
if self.bevy_reflect_get_type_registration.is_none() {
missing.extend(DEF_PATHS_GET_TYPE_REGISTRATION);
}
missing
}

// pub(crate) fn has_all_std_source_traits(&self) -> bool {
Expand Down
12 changes: 9 additions & 3 deletions crates/bevy_api_gen/src/modifying_file_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ impl FileLoader for ModifyingFileLoader {
);
RealFileLoader.read_file(path).map(|mut f| {
// we make it pub so in case we are re-exporting this crate we won't run into private re-export issues

for crate_ in &["bevy_reflect", "bevy_mod_scripting_core"] {
if !f.contains(&format!("extern crate {crate_}")) {
for (crate_, excluded_files) in &[
("bevy_reflect", vec!["crates/bevy_reflect/src/lib.rs"]),
("bevy_mod_scripting_core", vec![]),
] {
if !f.contains(&format!("extern crate {crate_}"))
&& !excluded_files
.iter()
.any(|s| path.to_str().unwrap().contains(s))
{
if f.contains(&format!("pub use {crate_}")) {
f.push_str(&format!(
"#[allow(unused_extern_crates)] pub extern crate {crate_};"
Expand Down
18 changes: 11 additions & 7 deletions crates/bevy_api_gen/src/passes/cache_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS,
};

fn dump_traits(tcx: &TyCtxt) -> String{
fn dump_traits(tcx: &TyCtxt) -> String {
let mut buffer = String::new();
for t in tcx.all_traits() {
buffer.push_str(&tcx.def_path_str(t));
Expand Down Expand Up @@ -43,20 +43,24 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
}
}

if !ctxt.cached_traits.has_all_bms_traits() {
let missing_bevy_traits = ctxt.cached_traits.missing_bevy_traits();
if !missing_bevy_traits.is_empty() {
panic!(
"Could not find all bms traits in crate: {}. Available traits: {}",
"Could not find traits: [{}] in crate: {}, did bootstrapping go wrong? Available traits: {}",
missing_bevy_traits.join(", "),
tcx.crate_name(LOCAL_CRATE),
dump_traits(tcx)
)
);
}

if !ctxt.cached_traits.has_all_bevy_traits() {
let missing_bms_traits = ctxt.cached_traits.missing_bms_traits();
if !missing_bms_traits.is_empty() {
panic!(
"Could not find all reflect traits in crate: {}, did bootstrapping go wrong?. Available traits: {}",
"Could not find traits: [{}] in crate: {}, did bootstrapping go wrong? Available traits: {}",
missing_bms_traits.join(", "),
tcx.crate_name(LOCAL_CRATE),
dump_traits(tcx)
)
);
}

// some crates specifically do not have std in scope via `#![no_std]` which means we do not care about these traits
Expand Down
12 changes: 4 additions & 8 deletions crates/bevy_mod_scripting_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_mod_scripting_core"
version = "0.12.0"
version = "0.13.0"
authors = ["Maksymilian Mozolewski <makspl17@gmail.com>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -29,19 +29,15 @@ mlua = { version = "0.10", default-features = false, optional = true }
rhai = { version = "1.21", default-features = false, features = [
"sync",
], optional = true }
bevy = { workspace = true, default-features = false, features = ["bevy_asset"] }
thiserror = "1.0.31"
bevy = { workspace = true, default-features = false, features = ["bevy_asset", "std"] }
parking_lot = "0.12.1"
dashmap = "6"
smallvec = "1.11"
itertools = "0.13"
derivative = "2.2"
itertools = "0.14"
profiling = { workspace = true }
bevy_mod_scripting_derive = { workspace = true }
fixedbitset = "0.5"
petgraph = "0.6"
bevy_mod_debugdump = "0.12"
bevy_system_reflection = { path = "../bevy_system_reflection", version = "0.1.1" }
variadics_please = "1.1.0"

[dev-dependencies]
test_utils = { workspace = true }
Expand Down
Loading