-
Notifications
You must be signed in to change notification settings - Fork 397
Allow building examples locally using helper script and zola config #2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Also, I think I or someone may have added a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but generate_wasm_examples.sh never calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just tried this: the option does exist, but its not implemented for the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
# 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" |
There was a problem hiding this comment.
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 inconfig.toml
.There was a problem hiding this comment.
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.