only handle bin examples in showcase (#18374)

# Objective

- Some examples are now build as lib to be usable in other examples
since https://github.com/bevyengine/bevy/pull/18288
- Those examples are not correctly handled in the showcase as it tries
to run them

## Solution

- Ignore lib examples in showcase when taking screenshots or building
for the website
This commit is contained in:
François Mockers 2025-03-18 01:52:42 +01:00 committed by GitHub
parent 31d2b6539c
commit ac53e4c482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -275,6 +275,7 @@ fn main() {
examples_to_run
.iter()
.filter(|example| example.category != "Stress Tests" || !ignore_stress_tests)
.filter(|example| example.example_type == ExampleType::Bin)
.filter(|example| {
example_list.is_none() || example_filter.contains(&example.technical_name)
})
@ -503,6 +504,10 @@ header_message = \"Examples (WebGL2)\"
let mut categories = HashMap::new();
for to_show in examples_to_run {
if to_show.example_type != ExampleType::Bin {
continue;
}
if !to_show.wasm {
continue;
}
@ -659,6 +664,7 @@ header_message = \"Examples ({})\"
examples_to_build
.iter()
.filter(|to_build| to_build.wasm)
.filter(|to_build| to_build.example_type == ExampleType::Bin)
.skip(cli.page.unwrap_or(0) * cli.per_page.unwrap_or(0))
.take(cli.per_page.unwrap_or(usize::MAX))
};
@ -804,6 +810,22 @@ fn parse_examples() -> Vec<Example> {
.collect()
})
.unwrap_or_default(),
example_type: match val.get("crate-type") {
Some(crate_type) => {
match crate_type
.as_array()
.unwrap()
.get(0)
.unwrap()
.as_str()
.unwrap()
{
"lib" => ExampleType::Lib,
_ => ExampleType::Bin,
}
}
None => ExampleType::Bin,
},
})
})
.collect()
@ -833,4 +855,12 @@ struct Example {
wasm: bool,
/// List of commands to run before the example. Can be used for example to specify data to download
setup: Vec<Vec<String>>,
/// Type of example
example_type: ExampleType,
}
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
enum ExampleType {
Lib,
Bin,
}