Two optional modules, each an interface library with a _none twin and a REAKTOR_<NAME> option that defaults on, so an application that wants neither links neither. Locale reads a catalog per language from assets/locale, or compiles them in with REAKTOR_LOCALE_EMBED: key = value lines, gettext plural rules, and numbers, money and dates written the way each catalog says. The atlas bakes what the catalogs use that Aileron has, and --lang picks the language. Text draws what the atlas cannot. A string with any character the atlas lacks is measured and drawn by core/text/text.c instead of Nuklear: direction by mojibake's bidirectional algorithm, shaping by kb_text_shape, glyphs from the first font that has them, rasterized at the size they are drawn, and lines broken by UAX #14. Both libraries come in as submodules. M PLUS 1p is vendored with its OFL notice for the showcase's Japanese, and --font-fallback adds more. The showcase gains a Translations page: the opening of The Ugly Duckling in English, Polish and Japanese, beside a date, a number, money in three currencies and a plural count, each formatted the way that language writes it. A clean-up pass followed: shared helpers for what was duplicated, and comments cut to the few one-liners that guard against a bug. Screenshots and --a11y-dump of all ten tabs, of Polish and Japanese, and of a right-to-left sample were compared before and after it and are byte-identical. The seven tests pass, localetest and texttest among them, and the native and WebAssembly builds both link. The docs follow. DOCUMENTATION.md covers both modules and the formatting keys, DEMO.md shows each of the four applications, benchmarks/README.md becomes BENCHMARKS.md, PERFORMANCE.md drops the per-machine CPU column and the history of the old chart, and the GitHub Pages workflow is added. The showcase and bench windows are titled Showcase and Bench, as notepad and simple already were. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
86 lines
2.7 KiB
Bash
Executable File
86 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
out="$root/build-wasm"
|
|
serve=0
|
|
port=8000
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--serve|-s) serve=1 ;;
|
|
--port|-p)
|
|
shift
|
|
[ $# -gt 0 ] || { echo "build-wasm.sh: --port needs a number" >&2; exit 2; }
|
|
port="$1" ;;
|
|
--help|-h) echo "usage: build-wasm.sh [--serve] [--port N] [-- CMAKE_ARGS]"; exit 0 ;;
|
|
--) shift; break ;;
|
|
*) echo "build-wasm.sh: unknown argument: $1 (try --help)" >&2; exit 2 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
emsdk="${EMSDK:-}"
|
|
if [ -z "$emsdk" ] && command -v emcc >/dev/null 2>&1; then
|
|
emcc_path=$(command -v emcc)
|
|
emsdk=$(CDPATH= cd -- "$(dirname -- "$emcc_path")/../.." && pwd)
|
|
fi
|
|
[ -n "$emsdk" ] || emsdk="$HOME/emsdk"
|
|
|
|
toolchain="$emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
|
|
|
if [ ! -f "$toolchain" ] && command -v emcc >/dev/null 2>&1; then
|
|
emcc_bin=$(command -v emcc)
|
|
emcc_dir=$(dirname -- "$emcc_bin")
|
|
packaged=$(readlink -f "$emcc_bin" 2>/dev/null || echo "")
|
|
if [ -n "$packaged" ]; then
|
|
packaged=$(dirname -- "$packaged")
|
|
fi
|
|
for candidate in "$packaged" "$emcc_dir/../lib/emscripten" "$emcc_dir/../share/emscripten"; do
|
|
[ -n "$candidate" ] || continue
|
|
[ -f "$candidate/cmake/Modules/Platform/Emscripten.cmake" ] || continue
|
|
emsdk=$(CDPATH= cd -- "$candidate" && pwd)
|
|
toolchain="$emsdk/cmake/Modules/Platform/Emscripten.cmake"
|
|
break
|
|
done
|
|
fi
|
|
|
|
if [ ! -f "$toolchain" ]; then
|
|
echo "build-wasm.sh: no Emscripten found (looked for an emsdk at $emsdk)" >&2
|
|
echo " clone https://github.com/emscripten-core/emsdk, run './emsdk install latest'" >&2
|
|
echo " then './emsdk activate latest', or set EMSDK to an existing one" >&2
|
|
echo " or install your system's emscripten package" >&2
|
|
exit 1
|
|
fi
|
|
|
|
command -v cmake >/dev/null 2>&1 || {
|
|
echo "build-wasm.sh: cmake not found on PATH" >&2; exit 1; }
|
|
|
|
if [ ! -f "$root/external/SDL/CMakeLists.txt" ]; then
|
|
echo "build-wasm.sh: submodules missing - run: git submodule update --init --recursive" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -f "$emsdk/emsdk_env.sh" ]; then
|
|
# shellcheck disable=SC1091
|
|
. "$emsdk/emsdk_env.sh" >/dev/null 2>&1
|
|
fi
|
|
|
|
if command -v ninja >/dev/null 2>&1; then
|
|
set -- -G Ninja "$@"
|
|
fi
|
|
|
|
cmake -S "$root" -B "$out" \
|
|
-DCMAKE_TOOLCHAIN_FILE="$toolchain" \
|
|
-DCMAKE_BUILD_TYPE=Release "$@"
|
|
cmake --build "$out" --parallel
|
|
|
|
echo
|
|
echo "built: $out/showcase.html (plus simple.html and notepad.html)"
|
|
echo "a file:// page cannot fetch the .wasm, so serve it:"
|
|
echo " python3 -m http.server -d $out $port"
|
|
|
|
if [ "$serve" -eq 1 ]; then
|
|
exec python3 -m http.server -d "$out" "$port"
|
|
fi
|