Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

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.
34 changes: 34 additions & 0 deletions config.local.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Zola config for compiling examples locally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we shouldn't maintain a separate nearly identical copy of this file just for this purpose. I would move the local versions of wasm_webgl2_base_url to comments in config.toml.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, i'd love to not need either, but Zola is limited in this regard. Maybe comments can work, but my goal was that there won't be a need to edit a git tracked file for at least the basic usecases.


# 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"
2 changes: 2 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
48 changes: 48 additions & 0 deletions generate-wasm-examples/build_wasm_examples_debug.sh
Original file line number Diff line number Diff line change
@@ -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/<username>/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
Comment on lines +31 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it's a bit unfortunate to repeat these invocations here in this new script. Would prefer that generate_wasm_example.sh handle the limiting.

Also, I think I or someone may have added a --debug option to example-showcase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but generate_wasm_examples.sh never calls example-showcase build-wasm-example? only the CI yaml has another version of this.

Copy link
Contributor Author

@laundmo laundmo Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think I or someone may have added a --debug option to example-showcase.

Just tried this: the option does exist, but its not implemented for the build-wasm-example command and silently gets ignored. Its only applied for the run command as far as I can tell: https://github.com/bevyengine/bevy/blob/0b8844a3a060b2a5b7c3302bd951e39fbf6aa1c3/tools/example-showcase/src/main.rs#L723

Copy link
Contributor

@rparrett rparrett Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, sorry!

And yeah, looks like the new debug option isn't piped through from example-showcase.


# 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"
12 changes: 9 additions & 3 deletions generate-wasm-examples/generate_wasm_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion templates/example-webgpu.html
Original file line number Diff line number Diff line change
@@ -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 %}
<strong>Support Warning.</strong>
Expand Down
2 changes: 1 addition & 1 deletion templates/example.html
Original file line number Diff line number Diff line change
@@ -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.
Expand Down