1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

Move shell scripts into sh/ subfolder

This commit is contained in:
Emil Ernerfeldt
2021-05-09 13:28:24 +02:00
parent 38186fe23e
commit 6ad6f56cb1
9 changed files with 34 additions and 4 deletions

53
sh/build_demo_web.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
# Usage: build_demo_web.sh [--open]
CRATE_NAME="egui_demo_app"
# This is required to enable the web_sys clipboard API which egui_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
FEATURES="http,persistence,screen_reader"
cargo build \
-p ${CRATE_NAME} \
--release \
--lib \
--target wasm32-unknown-unknown \
--features ${FEATURES}
echo "Generating JS bindings for wasm…"
TARGET_NAME="${CRATE_NAME}.wasm"
wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
--out-dir docs --no-modules --no-typescript
# to get wasm-strip: apt/brew/dnf install wabt
# wasm-strip docs/${CRATE_NAME}_bg.wasm
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
echo "Finished docs/${CRATE_NAME}_bg.wasm"
if [[ "${1:-}" == "--open" ]]; 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

31
sh/check.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
set -eux
# Checks all tests, lints etc.
# Basically does what the CI does.
cargo check --workspace --all-targets
cargo test --workspace --doc
cargo check --workspace --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_INCREMENTAL=0 cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
cargo test --workspace --all-targets --all-features
cargo fmt --all -- --check
cargo doc -p emath -p epaint -p egui -p eframe -p epi -p egui_web -p egui_glium --lib --no-deps --all-features
cargo doc -p egui_web --target wasm32-unknown-unknown --lib --no-deps --all-features
# ------------------------------------------------------------
#
# For finding bloat:
# cargo bloat --release --bin demo_glium -n 200 | rg egui
# what compiles slowly?
# cargo clean; cargo +nightly build -p egui -Z timings
# what compiles slowly?
# cargo llvm-lines --lib -p egui | head -20

9
sh/docs.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
cargo doc -p egui_web --target wasm32-unknown-unknown --lib --no-deps --all-features
cargo doc -p emath -p epaint -p egui -p eframe -p epi -p egui_web -p egui_glium --lib --no-deps --all-features --open
# cargo watch -c -x 'doc -p emath -p epaint -p egui --lib --no-deps --all-features'

6
sh/find_bloat.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/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 "

9
sh/setup_web.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/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 -f wasm-bindgen-cli
cargo update -p wasm-bindgen

16
sh/start_server.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/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`.
echo "ensuring basic-http-server is installed..."
cargo install basic-http-server
echo "staritng server..."
echo "serving at http://localhost:8888"
(cd docs && basic-http-server --addr 127.0.0.1:8888 .)
# (cd docs && python3 -m http.server 8888 --bind 127.0.0.1)

6
sh/wasm_size.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path"
./build_demo_web.sh && ls -l ../docs/*.wasm