mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Fix: request_repaint_after works even when called from background thread (#2939)
* Refactor repaint logic
* request_repaint_after also fires the request_repaint callback
* Bug fixes
* Add test to egui_demo_app
* build_demo_web: build debug unless --release is specified
* Fix the web backend too
* Run special clippy for wasm, forbidding some types/methods
* Remove wasm_bindgen_check.sh
* Fix typos
* Revert "Remove wasm_bindgen_check.sh"
This reverts commit 92dde25344.
* Only run cranky/clippy once
This commit is contained in:
@@ -3,29 +3,41 @@ set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
|
||||
./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
|
||||
|
||||
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
|
||||
BUILD=debug
|
||||
BUILD_FLAGS=""
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
echo "build_demo_web.sh [--optimize] [--open]"
|
||||
echo "build_demo_web.sh [--release] [--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 " --release: Build with --release, and enable extra optimization step"
|
||||
echo " Runs wasm-opt."
|
||||
echo " NOTE: --release 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)
|
||||
--release)
|
||||
shift
|
||||
OPTIMIZE=true
|
||||
BUILD="release"
|
||||
BUILD_FLAGS="--release"
|
||||
;;
|
||||
|
||||
--open)
|
||||
@@ -39,22 +51,14 @@ while test $# -gt 0; do
|
||||
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 \
|
||||
${BUILD_FLAGS} \
|
||||
--lib \
|
||||
--target wasm32-unknown-unknown \
|
||||
--no-default-features \
|
||||
|
||||
13
scripts/clippy_wasm.sh
Executable file
13
scripts/clippy_wasm.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# This scripts run clippy on the wasm32-unknown-unknown target,
|
||||
# using a special clippy.toml config file which forbids a few more things.
|
||||
|
||||
set -eu
|
||||
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
cd "$script_path/.."
|
||||
set -x
|
||||
|
||||
# Use scripts/clippy_wasm/clippy.toml
|
||||
export CLIPPY_CONF_DIR="scripts/clippy_wasm"
|
||||
|
||||
cargo cranky --all-features --target wasm32-unknown-unknown --target-dir target_wasm -p egui_demo_app --lib -- --deny warnings
|
||||
29
scripts/clippy_wasm/clippy.toml
Normal file
29
scripts/clippy_wasm/clippy.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
# This is used by `scripts/clippy_wasm.sh` so we can forbid some methods that are not available in wasm.
|
||||
#
|
||||
# We cannot forbid all these methods in the main `clippy.toml` because of
|
||||
# https://github.com/rust-lang/rust-clippy/issues/10406
|
||||
|
||||
msrv = "1.65"
|
||||
|
||||
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
|
||||
disallowed-methods = [
|
||||
"std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility
|
||||
"std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility
|
||||
"std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility
|
||||
|
||||
# Cannot spawn threads on wasm:
|
||||
"std::thread::spawn",
|
||||
]
|
||||
|
||||
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
|
||||
disallowed-types = [
|
||||
# Cannot spawn threads on wasm:
|
||||
"std::thread::Builder",
|
||||
]
|
||||
|
||||
# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
|
||||
doc-valid-idents = [
|
||||
# You must also update the same list in the root `clippy.toml`!
|
||||
"AccessKit",
|
||||
"..",
|
||||
]
|
||||
Reference in New Issue
Block a user