From dcc681924c90923c7db0267dab1d7e4c7d799b51 Mon Sep 17 00:00:00 2001 From: laund Date: Wed, 1 Oct 2025 16:53:54 +0200 Subject: [PATCH 1/5] build_wasm_examples_debug script, use zola config for wasm url --- README.md | 2 + config.local.toml | 34 +++++++++++++ config.toml | 2 + .../build_wasm_examples_debug.sh | 48 +++++++++++++++++++ .../generate_wasm_examples.sh | 12 +++-- templates/example-webgpu.html | 2 +- templates/example.html | 2 +- 7 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 config.local.toml create mode 100755 generate-wasm-examples/build_wasm_examples_debug.sh diff --git a/README.md b/README.md index 5acb1e19a4..b978f2621f 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,5 @@ A local server should start and you should be able to access a local version of ### Assets, Errors, and Examples pages These pages need to be generated in a separate step by running the shell scripts in the `generate-assets`, `generate-errors`, and `generate-wasm-examples` directories. On Windows, you can use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) or [git bash](https://gitforwindows.org/). + +The Examples page uses the same WASM binaries as https://bevy.org/examples by default. To build examples locally, have a look at `generate-wasm-examples/build_wasm_examples_debug.sh`. After running it, start zola with `zola --config config.local.toml serve` to use the locally built examples. diff --git a/config.local.toml b/config.local.toml new file mode 100644 index 0000000000..42554b36be --- /dev/null +++ b/config.local.toml @@ -0,0 +1,34 @@ +# Zola config for compiling examples locally + +# The URL the site will be built for +base_url = "http://127.0.0.1:1111" + +# Used for the Atom feed +title = "Bevy Engine" + +# Whether to automatically compile all Sass files in the sass directory +compile_sass = true + +# When set to "true", the generated HTML files are minified. +minify_html = true + +# Whether to build a search index to be used later on by a JavaScript library +build_search_index = true + +generate_feeds = true +feed_limit = 1000 + +taxonomies = [{ name = "news", feed = true }] + +[markdown] +# Whether to do syntax highlighting +# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola +highlight_code = true +highlight_theme = "css" + +# Load extra syntaxes (e.g. WGSL) for syntax highlighting +extra_syntaxes_and_themes = ["syntaxes"] + +[extra] +wasm_webgl2_base_url = "http://127.0.0.1:1111/assets/examples/wasm_webgl2" +wasm_webgpu_base_url = "http://127.0.0.1:1111/assets/examples/wasm_webgpu" diff --git a/config.toml b/config.toml index 5fe42055be..75a9a02df9 100644 --- a/config.toml +++ b/config.toml @@ -29,3 +29,5 @@ extra_syntaxes_and_themes = ["syntaxes"] [extra] # Put all your custom variables here +wasm_webgl2_base_url = "https://bevy-webgl2-examples.pages.dev" +wasm_webgpu_base_url = "https://bevy-webgpu-examples.pages.dev" diff --git a/generate-wasm-examples/build_wasm_examples_debug.sh b/generate-wasm-examples/build_wasm_examples_debug.sh new file mode 100755 index 0000000000..51f35216ed --- /dev/null +++ b/generate-wasm-examples/build_wasm_examples_debug.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# locally build wasm examples for testing +# usage: +# ./build_wasm-examples_debug.sh 6 # builds the first 6 examples + +if ! command -v wasm-bindgen >/dev/null 2>&1 +then + echo "wasm-bindgen could not be found - install it using: cargo install wasm-bindgen-cli" + exit 1 +fi + +if [ -z "$1" ] + then + echo "Missing example amount, use: './build_wasm_examples_debug.sh 5' to build the first 5 examples" + exit 1 +fi + +# Switch to script's directory, letting it be called from any folder. +cd $(dirname $0) + +# generate_wasm_examples will clone the bevy repo to ./bevy by default. +# If you want to use your fork or local changes, clone, symlink or copy your own bevy repo/folder: +# git clone https://github.com//bevy bevy +# cp ~/projects/bevy ./bevy +./generate_wasm_examples.sh --no-pull + +cd bevy + +git reset HEAD --hard +CARGO_PROFILE_RELEASE_OPT_LEVEL='z' CARGO_PROFILE_RELEASE_DEBUG="true" cargo run -p example-showcase -- --per-page $1 --page 0 build-wasm-examples --content-folder ../../static/assets/examples/wasm_webgl2 --api webgl2 --website-hacks +CARGO_PROFILE_RELEASE_OPT_LEVEL='z' CARGO_PROFILE_RELEASE_DEBUG="true" cargo run -p example-showcase -- --per-page $1 --page 0 build-wasm-examples --content-folder ../../static/assets/examples/wasm_webgpu --api webgpu + +# remove the examples which this did not build, to make it easier to find which is which +remove_missing() { + for d in "$1"/*; do + [[ -d "$d" ]] || continue + local base=$(basename "$d") + local match=$(find "$2" -maxdepth 1 -type d -iname "${base/-/?}" | head -n1) + if [[ -z "$match" ]]; then + rm -rf "$d" + else + remove_missing "$d" "$match" + fi + done +} +cd .. +remove_missing "../content/examples" "../static/assets/examples/wasm_webgl2" diff --git a/generate-wasm-examples/generate_wasm_examples.sh b/generate-wasm-examples/generate_wasm_examples.sh index 304eb47cda..ac0c1d0661 100755 --- a/generate-wasm-examples/generate_wasm_examples.sh +++ b/generate-wasm-examples/generate_wasm_examples.sh @@ -7,13 +7,19 @@ cd $(dirname $0) # If Bevy folder already exists, pull the latest changes. if [[ -d bevy ]]; then - echo Bevy folder already exists, attempting to fetch latest changes. + echo Bevy folder already exists. cd bevy - # Attempts to fetch the latest commits, which should only happen every Bevy release. - git pull --depth=1 + if [[ $* != *--no-pull* ]]; then + # Attempts to fetch the latest commits, which should only happen every Bevy release. + git pull --depth=1 + fi else + if [[ $* == *--no-pull* ]]; then + echo "--no-pull was specified, but Bevy folder doesn't exist" + exit 1 + fi echo Bevy folder does not exist, cloning repository. # Clone Bevy's latest branch from scratch, only downloading the latest commit. diff --git a/templates/example-webgpu.html b/templates/example-webgpu.html index 8ee5cf7689..a8122bf966 100644 --- a/templates/example-webgpu.html +++ b/templates/example-webgpu.html @@ -1,7 +1,7 @@ {% extends "layouts/example.html" %} {% block examples_url %}/examples-webgpu{% endblock examples_url %} -{% block wasm_base_url %}https://bevy-webgpu-examples.pages.dev{% endblock wasm_base_url %} +{% block wasm_base_url %}{{ config.extra.wasm_webgpu_base_url | safe }}{% endblock wasm_base_url %} {% block callout_modifier %}warning{% endblock callout_modifier %} {% block callout %} Support Warning. diff --git a/templates/example.html b/templates/example.html index 4d3ed30330..174fc81c08 100644 --- a/templates/example.html +++ b/templates/example.html @@ -1,7 +1,7 @@ {% extends "layouts/example.html" %} {% block examples_url %}/examples{% endblock examples_url %} -{% block wasm_base_url %}https://bevy-webgl2-examples.pages.dev{% endblock wasm_base_url %} +{% block wasm_base_url %}{{ config.extra.wasm_webgl2_base_url | safe }}{% endblock wasm_base_url %} {% block callout_modifier %}info{% endblock callout_modifier %} {% block callout %} This example is running in WebGL2 and should work in most browsers. From f16e8c535e38b14f8f2e5811cc7acbb8ad84642f Mon Sep 17 00:00:00 2001 From: laund Date: Wed, 1 Oct 2025 21:02:32 +0200 Subject: [PATCH 2/5] Update README.md Co-authored-by: Rob Parrett --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b978f2621f..6bcbcbb2b7 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ A local server should start and you should be able to access a local version of These pages need to be generated in a separate step by running the shell scripts in the `generate-assets`, `generate-errors`, and `generate-wasm-examples` directories. On Windows, you can use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) or [git bash](https://gitforwindows.org/). -The Examples page uses the same WASM binaries as https://bevy.org/examples by default. To build examples locally, have a look at `generate-wasm-examples/build_wasm_examples_debug.sh`. After running it, start zola with `zola --config config.local.toml serve` to use the locally built examples. +The Examples page uses the same Wasm binaries as https://bevy.org/examples by default. To build examples locally, have a look at `generate-wasm-examples/build_wasm_examples_debug.sh`. After running it, start zola with `zola --config config.local.toml serve` to use the locally built examples. From c3778fb4616fbb48ef6906cec1dd063d38d3f7e6 Mon Sep 17 00:00:00 2001 From: laund Date: Wed, 1 Oct 2025 21:26:41 +0200 Subject: [PATCH 3/5] Clarify readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b978f2621f..c61908891b 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ A local server should start and you should be able to access a local version of These pages need to be generated in a separate step by running the shell scripts in the `generate-assets`, `generate-errors`, and `generate-wasm-examples` directories. On Windows, you can use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) or [git bash](https://gitforwindows.org/). -The Examples page uses the same WASM binaries as https://bevy.org/examples by default. To build examples locally, have a look at `generate-wasm-examples/build_wasm_examples_debug.sh`. After running it, start zola with `zola --config config.local.toml serve` to use the locally built examples. +By default, the examples will load the same pre-built Wasm binaries also used for https://bevy.org/examples. If you want to build examples locally instead, for example to include debug info, have a look at `generate-wasm-examples/build_wasm_examples_debug.sh`. After its finished, you can start zola with `zola --config config.local.toml serve` to use the locally built examples. From 41d57a284f103e418878661e49c4248042e8d36d Mon Sep 17 00:00:00 2001 From: Tim Pepper Date: Fri, 14 Nov 2025 15:10:27 -0800 Subject: [PATCH 4/5] update doc to clarify where to place bevy dir to generate examples locally --- generate-wasm-examples/build_wasm_examples_debug.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generate-wasm-examples/build_wasm_examples_debug.sh b/generate-wasm-examples/build_wasm_examples_debug.sh index 51f35216ed..505f563546 100755 --- a/generate-wasm-examples/build_wasm_examples_debug.sh +++ b/generate-wasm-examples/build_wasm_examples_debug.sh @@ -19,10 +19,11 @@ fi # Switch to script's directory, letting it be called from any folder. cd $(dirname $0) -# generate_wasm_examples will clone the bevy repo to ./bevy by default. +# generate_wasm_examples will clone the bevy repo to bevy-website/generate-wasm-examples/bevy by default. # If you want to use your fork or local changes, clone, symlink or copy your own bevy repo/folder: -# git clone https://github.com//bevy bevy -# cp ~/projects/bevy ./bevy +# 1. $ git clone https://github.com//bevy bevy +# 2. Make relevant changes to your local bevy repository +# 3. $ cp ~/projects/bevy ~/projects/bevy-website/generate-wasm-examples/bevy ./generate_wasm_examples.sh --no-pull cd bevy From 3d9bff06ebf3e5eded4a4824e8ae1b4627ed79f4 Mon Sep 17 00:00:00 2001 From: laund Date: Sat, 15 Nov 2025 00:27:55 +0100 Subject: [PATCH 5/5] Update build_wasm_examples_debug.sh --- generate-wasm-examples/build_wasm_examples_debug.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/generate-wasm-examples/build_wasm_examples_debug.sh b/generate-wasm-examples/build_wasm_examples_debug.sh index 505f563546..c6a307591c 100755 --- a/generate-wasm-examples/build_wasm_examples_debug.sh +++ b/generate-wasm-examples/build_wasm_examples_debug.sh @@ -19,11 +19,13 @@ fi # Switch to script's directory, letting it be called from any folder. cd $(dirname $0) -# generate_wasm_examples will clone the bevy repo to bevy-website/generate-wasm-examples/bevy by default. -# If you want to use your fork or local changes, clone, symlink or copy your own bevy repo/folder: -# 1. $ git clone https://github.com//bevy bevy -# 2. Make relevant changes to your local bevy repository -# 3. $ cp ~/projects/bevy ~/projects/bevy-website/generate-wasm-examples/bevy +# generate_wasm_examples will clone the bevy repo to ./generate-wasm-examples/bevy by default. +# If you want to use your fork or local changes, clone, symlink or copy your own bevy repo/folder +# to ./generate-wasm-examples/bevy: +# 1. $ cd ./generate-wasm-examples +# 2. $ git clone https://github.com//bevy +# OR +# 1. $ cp ~/projects/my-bevy-fork ./generate-wasm-examples/bevy ./generate_wasm_examples.sh --no-pull cd bevy