mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 04:25:00 +01:00
vendor
This commit is contained in:
parent
12163d1338
commit
550b1644cb
363 changed files with 84081 additions and 16 deletions
98
egui/scripts/build_demo_web.sh
Executable file
98
egui/scripts/build_demo_web.sh
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
CRATE_NAME="egui_demo_app"
|
||||
# NOTE: persistence use up about 400kB (10%) of the WASM!
|
||||
FEATURES="glow,http,persistence,web_screen_reader"
|
||||
|
||||
OPEN=false
|
||||
OPTIMIZE=false
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
echo "build_demo_web.sh [--optimize] [--open]"
|
||||
echo ""
|
||||
echo " --optimize: Enable optimization step"
|
||||
echo " Runs wasm-opt."
|
||||
echo " NOTE: --optimize also removes debug symbols which are otherwise useful for in-browser profiling."
|
||||
echo ""
|
||||
echo " --open: Open the result in a browser"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-O|--optimize)
|
||||
shift
|
||||
OPTIMIZE=true
|
||||
;;
|
||||
|
||||
--open)
|
||||
shift
|
||||
OPEN=true
|
||||
;;
|
||||
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
./scripts/setup_web.sh
|
||||
|
||||
# This is required to enable the web_sys clipboard API which eframe web uses
|
||||
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
|
||||
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
||||
export RUSTFLAGS=--cfg=web_sys_unstable_apis
|
||||
|
||||
# Clear output from old stuff:
|
||||
rm -f "docs/${CRATE_NAME}_bg.wasm"
|
||||
|
||||
echo "Building rust…"
|
||||
BUILD=release
|
||||
|
||||
(cd crates/$CRATE_NAME &&
|
||||
cargo build \
|
||||
--release \
|
||||
--lib \
|
||||
--target wasm32-unknown-unknown \
|
||||
--no-default-features \
|
||||
--features ${FEATURES}
|
||||
)
|
||||
|
||||
# Get the output directory (in the workspace it is in another location)
|
||||
TARGET=`cargo metadata --format-version=1 | jq --raw-output .target_directory`
|
||||
|
||||
echo "Generating JS bindings for wasm…"
|
||||
TARGET_NAME="${CRATE_NAME}.wasm"
|
||||
WASM_PATH="${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME"
|
||||
wasm-bindgen "${WASM_PATH}" --out-dir docs --no-modules --no-typescript
|
||||
|
||||
# if this fails with "error: cannot import from modules (`env`) with `--no-modules`", you can use:
|
||||
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg env
|
||||
# wasm2wat target/wasm32-unknown-unknown/release/egui_demo_app.wasm | rg "call .now\b" -B 20 # What calls `$now` (often a culprit)
|
||||
|
||||
# to get wasm-strip: apt/brew/dnf install wabt
|
||||
# wasm-strip docs/${CRATE_NAME}_bg.wasm
|
||||
|
||||
if [[ "${OPTIMIZE}" = true ]]; then
|
||||
echo "Optimizing wasm…"
|
||||
# to get wasm-opt: apt/brew/dnf install binaryen
|
||||
wasm-opt "docs/${CRATE_NAME}_bg.wasm" -O2 --fast-math -o "docs/${CRATE_NAME}_bg.wasm" # add -g to get debug symbols
|
||||
fi
|
||||
|
||||
echo "Finished docs/${CRATE_NAME}_bg.wasm"
|
||||
|
||||
if [[ "${OPEN}" == true ]]; then
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Linux, ex: Fedora
|
||||
xdg-open http://localhost:8888/index.html
|
||||
elif [[ "$OSTYPE" == "msys" ]]; then
|
||||
# Windows
|
||||
start http://localhost:8888/index.html
|
||||
else
|
||||
# Darwin/MacOS, or something else
|
||||
open http://localhost:8888/index.html
|
||||
fi
|
||||
fi
|
||||
19
egui/scripts/cargo-deny.sh
Executable file
19
egui/scripts/cargo-deny.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
set -x
|
||||
|
||||
# cargo install cargo-deny
|
||||
cargo deny --all-features --log-level error --target aarch64-apple-darwin check
|
||||
cargo deny --all-features --log-level error --target i686-pc-windows-gnu check
|
||||
cargo deny --all-features --log-level error --target i686-pc-windows-msvc check
|
||||
cargo deny --all-features --log-level error --target i686-unknown-linux-gnu check
|
||||
cargo deny --all-features --log-level error --target wasm32-unknown-unknown check
|
||||
cargo deny --all-features --log-level error --target x86_64-apple-darwin check
|
||||
cargo deny --all-features --log-level error --target x86_64-pc-windows-gnu check
|
||||
cargo deny --all-features --log-level error --target x86_64-pc-windows-msvc check
|
||||
cargo deny --all-features --log-level error --target x86_64-unknown-linux-gnu check
|
||||
cargo deny --all-features --log-level error --target x86_64-unknown-linux-musl check
|
||||
cargo deny --all-features --log-level error --target x86_64-unknown-redox check
|
||||
76
egui/scripts/check.sh
Executable file
76
egui/scripts/check.sh
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env bash
|
||||
# This scripts runs various CI-like checks in a convenient way.
|
||||
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
set -x
|
||||
|
||||
# Checks all tests, lints etc.
|
||||
# Basically does what the CI does.
|
||||
|
||||
cargo install cargo-cranky # Uses lints defined in Cranky.toml. See https://github.com/ericseppanen/cargo-cranky
|
||||
|
||||
# web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses,
|
||||
# as well as by the wasm32-backend of the wgpu crate.
|
||||
export RUSTFLAGS="--cfg=web_sys_unstable_apis -D warnings"
|
||||
export RUSTDOCFLAGS="-D warnings" # https://github.com/emilk/egui/pull/1454
|
||||
|
||||
cargo check --all-targets
|
||||
cargo check --all-targets --all-features
|
||||
cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown
|
||||
cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown --all-features
|
||||
cargo cranky --all-targets --all-features -- -D warnings
|
||||
cargo test --all-targets --all-features
|
||||
cargo test --doc # slow - checks all doc-tests
|
||||
cargo fmt --all -- --check
|
||||
|
||||
cargo doc --lib --no-deps --all-features
|
||||
cargo doc --document-private-items --no-deps --all-features
|
||||
|
||||
(cd crates/eframe && cargo check --no-default-features --features "glow")
|
||||
(cd crates/eframe && cargo check --no-default-features --features "wgpu")
|
||||
(cd crates/egui && cargo check --no-default-features --features "serde")
|
||||
(cd crates/egui_demo_app && cargo check --no-default-features --features "glow")
|
||||
(cd crates/egui_demo_app && cargo check --no-default-features --features "wgpu")
|
||||
(cd crates/egui_demo_lib && cargo check --no-default-features)
|
||||
(cd crates/egui_extras && cargo check --no-default-features)
|
||||
(cd crates/egui_glow && cargo check --no-default-features)
|
||||
(cd crates/egui-winit && cargo check --no-default-features --features "wayland")
|
||||
(cd crates/egui-winit && cargo check --no-default-features --features "winit/x11")
|
||||
(cd crates/emath && cargo check --no-default-features)
|
||||
(cd crates/epaint && cargo check --no-default-features --release)
|
||||
(cd crates/epaint && cargo check --no-default-features)
|
||||
|
||||
(cd crates/eframe && cargo check --all-features)
|
||||
(cd crates/egui && cargo check --all-features)
|
||||
(cd crates/egui_demo_app && cargo check --all-features)
|
||||
(cd crates/egui_extras && cargo check --all-features)
|
||||
(cd crates/egui_glow && cargo check --all-features)
|
||||
(cd crates/egui-winit && cargo check --all-features)
|
||||
(cd crates/emath && cargo check --all-features)
|
||||
(cd crates/epaint && cargo check --all-features)
|
||||
|
||||
./scripts/wasm_bindgen_check.sh
|
||||
|
||||
cargo cranky --target wasm32-unknown-unknown --all-features -p egui_demo_app --lib -- -D warnings
|
||||
|
||||
./scripts/cargo_deny.sh
|
||||
|
||||
# TODO(emilk): consider using https://github.com/taiki-e/cargo-hack or https://github.com/frewsxcv/cargo-all-features
|
||||
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
|
||||
# For finding bloat:
|
||||
# cargo bloat --release --bin egui_demo_app -n 200 | rg egui
|
||||
# Also try https://github.com/google/bloaty
|
||||
|
||||
# what compiles slowly?
|
||||
# cargo clean && time cargo build -p eframe --timings
|
||||
# https://fasterthanli.me/articles/why-is-my-rust-build-so-slow
|
||||
|
||||
# what compiles slowly?
|
||||
# cargo llvm-lines --lib -p egui | head -20
|
||||
|
||||
echo "All checks passed."
|
||||
9
egui/scripts/docs.sh
Executable file
9
egui/scripts/docs.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
cargo doc -p eframe --target wasm32-unknown-unknown --lib --no-deps
|
||||
cargo doc -p emath -p epaint -p egui -p eframe -p egui-winit -p egui_extras -p egui_glow --lib --no-deps --all-features --open
|
||||
|
||||
# cargo watch -c -x 'doc -p emath -p epaint -p egui --lib --no-deps --all-features'
|
||||
8
egui/scripts/find_bloat.sh
Executable file
8
egui/scripts/find_bloat.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
cargo bloat --release --bin egui_demo_app -n 200 | rg "egui "
|
||||
|
||||
cargo llvm-lines -p egui_demo_lib | rg egui | head -30
|
||||
13
egui/scripts/generate_example_screenshots.sh
Executable file
13
egui/scripts/generate_example_screenshots.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
# This script generates screenshots for all the examples in examples/
|
||||
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
cd examples
|
||||
for EXAMPLE_NAME in $(ls -1d */ | sed 's/\/$//'); do
|
||||
if [ ${EXAMPLE_NAME} != "hello_world_par" ]; then
|
||||
EFRAME_SCREENSHOT_TO="$EXAMPLE_NAME/screenshot.png" cargo run -p $EXAMPLE_NAME
|
||||
fi
|
||||
done
|
||||
8
egui/scripts/setup_web.sh
Executable file
8
egui/scripts/setup_web.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
# Pre-requisites:
|
||||
rustup target add wasm32-unknown-unknown
|
||||
cargo install wasm-bindgen-cli --version 0.2.84
|
||||
18
egui/scripts/start_server.sh
Executable file
18
egui/scripts/start_server.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
# Starts a local web-server that serves the contents of the `doc/` folder,
|
||||
# i.e. the web-version of `egui_demo_app`.
|
||||
|
||||
PORT=8888
|
||||
|
||||
echo "ensuring basic-http-server is installed…"
|
||||
cargo install basic-http-server
|
||||
|
||||
echo "starting server…"
|
||||
echo "serving at http://localhost:${PORT}"
|
||||
|
||||
(cd docs && basic-http-server --addr 127.0.0.1:${PORT} .)
|
||||
# (cd docs && python3 -m http.server ${PORT} --bind 127.0.0.1)
|
||||
45
egui/scripts/wasm_bindgen_check.sh
Executable file
45
egui/scripts/wasm_bindgen_check.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
if [[ $* == --skip-setup ]]
|
||||
then
|
||||
echo "Skipping setup_web.sh"
|
||||
else
|
||||
echo "Running setup_web.sh"
|
||||
./scripts/setup_web.sh
|
||||
fi
|
||||
|
||||
CRATE_NAME="egui_demo_app"
|
||||
FEATURES="glow,http,persistence,web_screen_reader"
|
||||
|
||||
# This is required to enable the web_sys clipboard API which eframe web uses
|
||||
# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html
|
||||
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
||||
export RUSTFLAGS=--cfg=web_sys_unstable_apis
|
||||
|
||||
echo "Building rust…"
|
||||
BUILD=debug # debug builds are faster
|
||||
|
||||
(cd crates/$CRATE_NAME &&
|
||||
cargo build \
|
||||
--lib \
|
||||
--target wasm32-unknown-unknown \
|
||||
--no-default-features \
|
||||
--features ${FEATURES}
|
||||
)
|
||||
|
||||
TARGET="target"
|
||||
|
||||
echo "Generating JS bindings for wasm…"
|
||||
|
||||
rm -f "${CRATE_NAME}_bg.wasm" # Remove old output (if any)
|
||||
|
||||
TARGET_NAME="${CRATE_NAME}.wasm"
|
||||
wasm-bindgen "${TARGET}/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
|
||||
--out-dir . --no-modules --no-typescript
|
||||
|
||||
# Remove output:
|
||||
rm -f "${CRATE_NAME}_bg.wasm"
|
||||
rm -f "${CRATE_NAME}.js"
|
||||
6
egui/scripts/wasm_size.sh
Executable file
6
egui/scripts/wasm_size.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path"
|
||||
|
||||
./build_demo_web.sh && ls -lh ../docs/*.wasm
|
||||
Loading…
Add table
Add a link
Reference in a new issue