Skip to content

Commit a39c0c3

Browse files
committed
fix examples not actually getting checked by by CI or locally
1 parent df6b5b6 commit a39c0c3

File tree

4 files changed

+17
-49
lines changed

4 files changed

+17
-49
lines changed

Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,7 @@ debug = true
156156
[[example]]
157157
name = "game_of_life"
158158
path = "examples/game_of_life.rs"
159-
required-features = [
160-
"lua54",
161-
"rhai",
162-
"bevy/file_watcher",
163-
"bevy/multi_threaded",
164-
]
159+
required-features = ["lua54", "rhai"]
165160

166161
[[example]]
167162
name = "docgen"

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ fn main() {
5252
);
5353

5454
info!(
55-
"Computing all transitive dependencies for enabled top-level features: {}",
56-
args.features.join(",")
55+
"Computing all transitive dependencies for enabled top-level features: {}. using default features: {}",
56+
args.features.join(","),
57+
!args.no_default_features
5758
);
5859

5960
let dependencies = feature_graph

examples/game_of_life.rs

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use bevy::{
1616
};
1717
use bevy_console::{AddConsoleCommand, ConsoleCommand, ConsoleOpen, ConsolePlugin, make_layer};
1818
use bevy_mod_scripting::{core::bindings::AllocatorDiagnosticPlugin, prelude::*};
19+
use bevy_mod_scripting_core::{commands::RemoveStaticScript, script::StaticScripts};
1920
use clap::Parser;
2021

2122
// CONSOLE SETUP
@@ -41,8 +42,7 @@ fn run_script_cmd(
4142
mut commands: Commands,
4243
asset_server: Res<AssetServer>,
4344
script_comps: Query<(Entity, &ScriptComponent)>,
44-
mut static_lua_scripts: Local<Vec<ScriptId>>,
45-
mut static_rhai_scripts: Local<Vec<ScriptId>>,
45+
static_scripts: Res<StaticScripts>,
4646
) {
4747
if let Some(Ok(command)) = log.take() {
4848
match command {
@@ -53,58 +53,27 @@ fn run_script_cmd(
5353
// create an entity with the script component
5454
bevy::log::info!("Using game of life script game_of_life.{}", language);
5555

56-
let script_path = format!("scripts/game_of_life.{}", language);
56+
let script_path = format!("scripts/game_of_life.{language}");
5757
if !use_static_script {
5858
bevy::log::info!("Spawning an entity with ScriptComponent");
5959
commands.spawn(ScriptComponent::new(vec![asset_server.load(script_path)]));
6060
} else {
6161
bevy::log::info!("Using static script instead of spawning an entity");
6262
let handle = asset_server.load(script_path);
63-
if language == "lua" {
64-
static_lua_scripts.push(handle.id());
65-
} else {
66-
static_rhai_scripts.push(handle.id());
67-
}
6863
commands.queue(AddStaticScript::new(handle))
6964
}
7065
}
7166
GameOfLifeCommand::Stop => {
7267
// we can simply drop the handle, or manually delete, I'll just drop the handle
73-
bevy::log::info!("Stopping game of life by dropping the handles to all scripts");
74-
for (id, script_component) in &script_comps {
75-
for script in &script_component.0 {
76-
match script
77-
.path()
78-
.and_then(|p| p.get_full_extension())
79-
.unwrap_or_default()
80-
.as_str()
81-
{
82-
"lua" => {
83-
commands
84-
.entity(id)
85-
.queue(DeleteScript::<LuaScriptingPlugin>::new(script.id()));
86-
}
87-
"rhai" => {
88-
#[cfg(feature = "rhai")]
89-
commands
90-
.entity(id)
91-
.queue(DeleteScript::<RhaiScriptingPlugin>::new(script.id()));
92-
}
93-
ext => {
94-
warn!("Can't delete script with extension {ext:?}.");
95-
}
96-
}
97-
}
68+
bevy::log::info!(
69+
"Stopping game of life by detaching each script and static script"
70+
);
71+
for (id, _) in &script_comps {
9872
commands.entity(id).despawn();
9973
}
10074

101-
for script in static_lua_scripts.drain(..) {
102-
commands.queue(DeleteScript::<LuaScriptingPlugin>::new(script));
103-
}
104-
105-
#[cfg(feature = "rhai")]
106-
for script in static_rhai_scripts.drain(..) {
107-
commands.queue(DeleteScript::<RhaiScriptingPlugin>::new(script));
75+
for script in static_scripts.values() {
76+
commands.queue(RemoveStaticScript::new(script.clone()));
10877
}
10978
}
11079
}

xtask/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl Default for Features {
129129
// should be kept up to date with the default feature + lua54 on top of anything that is handy to run locally every time
130130
Features::new(vec![
131131
Feature::Lua54,
132+
Feature::Rhai,
132133
Feature::CoreFunctions,
133134
Feature::BevyEcsBindings,
134135
Feature::BevyInputBindings,
@@ -997,9 +998,11 @@ impl Xtasks {
997998
clippy_args.push("--message-format=json");
998999
}
9991000

1001+
clippy_args.extend(["--all-targets", "--examples"]);
1002+
10001003
let keep_going = std::env::var(XTASK_KEEP_GOING).is_ok();
10011004
if !keep_going {
1002-
clippy_args.extend(vec!["--all-targets", "--", "-D", "warnings"]);
1005+
clippy_args.extend(vec!["--", "-D", "warnings"]);
10031006
}
10041007

10051008
Self::run_workspace_command(

0 commit comments

Comments
 (0)