From 69e3d63ed5db1009bbe4853b5eac9678ac8493f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 15 Nov 2023 23:30:54 +0100 Subject: [PATCH 1/2] support specifying features when building examples for wasm --- tools/build-wasm-example/src/main.rs | 6 +++++- tools/example-showcase/src/main.rs | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/build-wasm-example/src/main.rs b/tools/build-wasm-example/src/main.rs index fbb472958c35f..8093f161f41d4 100644 --- a/tools/build-wasm-example/src/main.rs +++ b/tools/build-wasm-example/src/main.rs @@ -33,6 +33,10 @@ struct Args { #[arg(short, long)] /// Optimize the wasm file for size with wasm-opt optimize_size: bool, + + #[arg(long)] + /// Additional features to enable + features: Vec, } fn main() { @@ -41,7 +45,7 @@ fn main() { assert!(!cli.examples.is_empty(), "must have at least one example"); let mut default_features = true; - let mut features = vec![]; + let mut features: Vec<&str> = cli.features.iter().map(|f| f.as_str()).collect(); if let Some(frames) = cli.frames { let mut file = File::create("ci_testing_config.ron").unwrap(); file.write_fmt(format_args!("(exit_after: Some({frames}))")) diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index a69505d2b7685..9ec804473c9c0 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -581,17 +581,26 @@ header_message = \"Examples ({})\" for to_build in work_to_do() { let sh = Shell::new().unwrap(); let example = &to_build.technical_name; + let required_features = if to_build.required_features.is_empty() { + vec![] + } else { + vec![ + "--features".to_string(), + to_build.required_features.join(","), + ] + }; + if optimize_size { cmd!( sh, - "cargo run -p build-wasm-example -- --api {api} {example} --optimize-size" + "cargo run -p build-wasm-example -- --api {api} {example} --optimize-size {required_features...}" ) .run() .unwrap(); } else { cmd!( sh, - "cargo run -p build-wasm-example -- --api {api} {example}" + "cargo run -p build-wasm-example -- --api {api} {example} {required_features...}" ) .run() .unwrap(); From c8223c0d1dc22e8425f86c6f8b40f3fda3a89804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 16 Nov 2023 00:02:03 +0100 Subject: [PATCH 2/2] example hot_asset_reloading doesn't work in wasm --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5fe0449660fe0..c6dd76738a655 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1109,7 +1109,7 @@ required-features = ["file_watcher"] name = "Hot Reloading of Assets" description = "Demonstrates automatic reloading of assets when modified on disk" category = "Assets" -wasm = true +wasm = false [[example]] name = "asset_processing"