Skip to content

Commit 9b8ad29

Browse files
authored
feat: improve and formalize script processing pipeline (#481)
1 parent 72388fa commit 9b8ad29

File tree

45 files changed

+4909
-1203
lines changed

Some content is hidden

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

45 files changed

+4909
-1203
lines changed

.github/workflows/bevy_mod_scripting.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
GH_TOKEN: ${{ github.token }}
1919
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2020
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
21+
RUST_BACKTRACE=1
2122

2223
concurrency:
2324
# Use github.run_id on main branch

assets/tests/add_system/added_systems_run_in_parallel.lua

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,46 @@ digraph {
3030
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
3131
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
3232
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
33-
node_8 [label="on_test_post_update"];
34-
node_9 [label="custom_system_a"];
35-
node_10 [label="custom_system_b"];
36-
node_11 [label="SystemSet AssetEvents"];
37-
node_12 [label="SystemSet GarbageCollection"];
38-
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
39-
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
40-
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
41-
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
42-
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
43-
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
44-
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
45-
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
46-
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
33+
node_8 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
34+
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
35+
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
36+
node_11 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
37+
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
38+
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
39+
node_14 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_lua::LuaScriptingPlugin>"];
40+
node_15 [label="on_test_post_update"];
41+
node_16 [label="custom_system_a"];
42+
node_17 [label="custom_system_b"];
43+
node_18 [label="SystemSet AssetEvents"];
44+
node_19 [label="SystemSet GarbageCollection"];
45+
node_20 [label="SystemSet ListeningPhase"];
46+
node_21 [label="SystemSet MachineStartPhase"];
47+
node_22 [label="SystemSet ScriptSystem(custom_system_a)"];
48+
node_23 [label="SystemSet ScriptSystem(custom_system_b)"];
49+
node_0 -> node_18 [color=red, label="child of", arrowhead=diamond];
50+
node_1 -> node_18 [color=red, label="child of", arrowhead=diamond];
51+
node_2 -> node_18 [color=red, label="child of", arrowhead=diamond];
52+
node_3 -> node_18 [color=red, label="child of", arrowhead=diamond];
53+
node_4 -> node_19 [color=red, label="child of", arrowhead=diamond];
54+
node_8 -> node_20 [color=red, label="child of", arrowhead=diamond];
55+
node_9 -> node_20 [color=red, label="child of", arrowhead=diamond];
56+
node_10 -> node_20 [color=red, label="child of", arrowhead=diamond];
57+
node_11 -> node_21 [color=red, label="child of", arrowhead=diamond];
58+
node_12 -> node_21 [color=red, label="child of", arrowhead=diamond];
59+
node_13 -> node_21 [color=red, label="child of", arrowhead=diamond];
60+
node_16 -> node_22 [color=red, label="child of", arrowhead=diamond];
61+
node_17 -> node_23 [color=red, label="child of", arrowhead=diamond];
4762
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
4863
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
64+
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
4965
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
66+
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
67+
node_11 -> node_12 [color=blue, label="runs before", arrowhead=normal];
68+
node_12 -> node_13 [color=blue, label="runs before", arrowhead=normal];
69+
node_15 -> node_16 [color=blue, label="runs before", arrowhead=normal];
70+
node_15 -> node_17 [color=blue, label="runs before", arrowhead=normal];
71+
node_20 -> node_21 [color=blue, label="runs before", arrowhead=normal];
72+
node_21 -> node_14 [color=blue, label="runs before", arrowhead=normal];
5073
}
5174
]]
5275
assert_str_eq(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph")

assets/tests/add_system/added_systems_run_in_parallel.rhai

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,46 @@ digraph {
2929
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
3030
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
3131
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
32-
node_8 [label="on_test_post_update"];
33-
node_9 [label="custom_system_a"];
34-
node_10 [label="custom_system_b"];
35-
node_11 [label="SystemSet AssetEvents"];
36-
node_12 [label="SystemSet GarbageCollection"];
37-
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
38-
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
39-
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
40-
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
41-
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
42-
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
43-
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
44-
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
45-
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
32+
node_8 [label="bevy_mod_scripting_core::pipeline::start::filter_script_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
33+
node_9 [label="bevy_mod_scripting_core::pipeline::start::filter_script_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
34+
node_10 [label="bevy_mod_scripting_core::pipeline::start::filter_script_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
35+
node_11 [label="bevy_mod_scripting_core::pipeline::start::process_attachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
36+
node_12 [label="bevy_mod_scripting_core::pipeline::start::process_detachments<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
37+
node_13 [label="bevy_mod_scripting_core::pipeline::start::process_asset_modifications<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
38+
node_14 [label="bevy_mod_scripting_core::pipeline::automatic_pipeline_runner<bevy_mod_scripting_rhai::RhaiScriptingPlugin>"];
39+
node_15 [label="on_test_post_update"];
40+
node_16 [label="custom_system_a"];
41+
node_17 [label="custom_system_b"];
42+
node_18 [label="SystemSet AssetEvents"];
43+
node_19 [label="SystemSet GarbageCollection"];
44+
node_20 [label="SystemSet ListeningPhase"];
45+
node_21 [label="SystemSet MachineStartPhase"];
46+
node_22 [label="SystemSet ScriptSystem(custom_system_a)"];
47+
node_23 [label="SystemSet ScriptSystem(custom_system_b)"];
48+
node_0 -> node_18 [color=red, label="child of", arrowhead=diamond];
49+
node_1 -> node_18 [color=red, label="child of", arrowhead=diamond];
50+
node_2 -> node_18 [color=red, label="child of", arrowhead=diamond];
51+
node_3 -> node_18 [color=red, label="child of", arrowhead=diamond];
52+
node_4 -> node_19 [color=red, label="child of", arrowhead=diamond];
53+
node_8 -> node_20 [color=red, label="child of", arrowhead=diamond];
54+
node_9 -> node_20 [color=red, label="child of", arrowhead=diamond];
55+
node_10 -> node_20 [color=red, label="child of", arrowhead=diamond];
56+
node_11 -> node_21 [color=red, label="child of", arrowhead=diamond];
57+
node_12 -> node_21 [color=red, label="child of", arrowhead=diamond];
58+
node_13 -> node_21 [color=red, label="child of", arrowhead=diamond];
59+
node_16 -> node_22 [color=red, label="child of", arrowhead=diamond];
60+
node_17 -> node_23 [color=red, label="child of", arrowhead=diamond];
4661
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
4762
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
63+
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
4864
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
65+
node_9 -> node_10 [color=blue, label="runs before", arrowhead=normal];
66+
node_11 -> node_12 [color=blue, label="runs before", arrowhead=normal];
67+
node_12 -> node_13 [color=blue, label="runs before", arrowhead=normal];
68+
node_15 -> node_16 [color=blue, label="runs before", arrowhead=normal];
69+
node_15 -> node_17 [color=blue, label="runs before", arrowhead=normal];
70+
node_20 -> node_21 [color=blue, label="runs before", arrowhead=normal];
71+
node_21 -> node_14 [color=blue, label="runs before", arrowhead=normal];
4972
}`;
5073

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

assets/tests/lifecycle/default/entity_script/callback/scenario.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SetCurrentLanguage language="@this_script_language"
2-
InstallPlugin
2+
InstallPlugin miliseconds_budget=999999
33
SetupHandler OnTest=null, Update=null
44
SetupHandler OnTestPostUpdate=null, PostUpdate=null
55
SetupHandler Last=null, OnTestLast=null

assets/tests/lifecycle/default/static_script/callback/scenario.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SetCurrentLanguage language="@this_script_language"
2-
InstallPlugin
2+
InstallPlugin miliseconds_budget=999999
33
SetupHandler OnTest=null, Update=null
44
SetupHandler OnTestPostUpdate=null, PostUpdate=null
55
SetupHandler Last=null, OnTestLast=null

assets/tests/lifecycle/shared/entity_script/scenario.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ AssertCallbackSuccess attachment="EntityScript", label="OnScriptLoaded", script=
1919
AssertCallbackSuccess attachment="EntityScript", label="OnScriptReloaded", script="script_a", entity="test_entity_a", expect_string_value="reloaded with: unloaded!"
2020
AssertNoCallbackResponsesEmitted
2121

22-
// load licecycle_b.lua, which prefixes all outputs with "B"
22+
// load licecycle_b.lua, which prefixes all outputs with "B", the unload callback is called using the old script's state
2323
LoadScriptAs as_name="script_b", path="lifecycle_b.lua"
2424
WaitForScriptLoaded name="script_b"
2525
SpawnEntityWithScript name="test_entity_b", script="script_b"
2626
RunUpdateOnce
27+
AssertCallbackSuccess attachment="EntityScript", label="OnScriptUnloaded", script="script_b", entity="test_entity_b", expect_string_value="unloaded!"
2728
AssertCallbackSuccess attachment="EntityScript", label="OnScriptLoaded", script="script_b", entity="test_entity_b", expect_string_value="B: loaded!"
29+
AssertCallbackSuccess attachment="EntityScript", label="OnScriptReloaded", script="script_b", entity="test_entity_b", expect_string_value="B: reloaded with: unloaded!"
2830
AssertNoCallbackResponsesEmitted
2931

3032
// reload script_b, with the same content

assets/tests/lifecycle/shared/static_script/scenario.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ LoadScriptAs as_name="script_b", path="lifecycle_b.lua"
2424
WaitForScriptLoaded name="script_b"
2525
AttachStaticScript script="script_b"
2626
RunUpdateOnce
27+
AssertCallbackSuccess attachment="StaticScript", label="OnScriptUnloaded", script="script_b", expect_string_value="unloaded!"
2728
AssertCallbackSuccess attachment="StaticScript", label="OnScriptLoaded", script="script_b", expect_string_value="B: loaded!"
29+
AssertCallbackSuccess attachment="StaticScript", label="OnScriptReloaded", script="script_b", expect_string_value="B: reloaded with: unloaded!"
2830
AssertNoCallbackResponsesEmitted
2931

3032
// reload script_b, with the same content

assets/tests/scenario.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SetCurrentLanguage language="@this_script_language"
2-
InstallPlugin
2+
InstallPlugin miliseconds_budget=999999
33
SetupHandler OnTest=null, Update=null
44
SetupHandler OnTestPostUpdate=null, PostUpdate=null
55
SetupHandler Last=null, OnTestLast=null

crates/bevy_mod_scripting_asset/src/script_asset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_reflect::Reflect;
66
use crate::Language;
77

88
/// Represents a script loaded into memory as an asset
9-
#[derive(Asset, Clone, Reflect)]
9+
#[derive(Asset, Clone, Reflect, Default)]
1010
#[reflect(opaque)]
1111
pub struct ScriptAsset {
1212
/// The body of the script

crates/bevy_mod_scripting_core/src/asset.rs

Lines changed: 0 additions & 202 deletions
This file was deleted.

0 commit comments

Comments
 (0)