Files
harfbuzz/util/gpu/web/build.sh
T
Behdad EsfahbodandClaude Opus 4.6 e96cbf4a12 [gpu] Shrink web demo WASM with HB_LEAN
Add config.h with HB_LEAN and config-override.h to re-enable
draw, metrics, and variable font support. Strips color, paint,
math, bitmap, deprecated APIs, and other unused features.

WebGL: 635KB → 513KB (-19%)
WebGPU: 655KB → 533KB (-19%)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 22:18:06 -06:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Build the hb-gpu web demo with Emscripten.
# Prerequisites: source emsdk/emsdk_env.sh
set -e
SRCDIR="$(cd "$(dirname "$0")/../../.." && pwd)"
OUTDIR="$(dirname "$0")/out"
mkdir -p "$OUTDIR"
em++ \
-std=c++17 \
-Oz -flto \
-I"$SRCDIR/src" \
-I"$SRCDIR/util/gpu/web" \
-DHAVE_CONFIG_H \
-DHB_GPU_ATLAS_2D \
"$SRCDIR/src/harfbuzz-world.cc" \
"$SRCDIR/util/gpu/demo-atlas.cc" \
"$SRCDIR/util/gpu/demo-buffer.cc" \
"$SRCDIR/util/gpu/demo-font.cc" \
"$SRCDIR/util/gpu/demo-glstate.cc" \
"$SRCDIR/util/gpu/demo-renderer-gl.cc" \
"$SRCDIR/util/gpu/demo-shader.cc" \
"$SRCDIR/util/gpu/demo-view.cc" \
"$SRCDIR/util/gpu/web/hb-gpu-web.cc" \
-sUSE_GLFW=3 \
-sUSE_WEBGL2=1 \
-sFULL_ES3=1 \
-sALLOW_MEMORY_GROWTH=1 \
-sEXPORTED_FUNCTIONS='["_main","_web_load_font","_web_set_text","_web_get_text","_web_toggle_animation","_web_reset","_web_request_redraw","_web_cancel_gesture","_web_pinch","_malloc","_free"]' \
-sEXPORTED_RUNTIME_METHODS='["UTF8ToString","lengthBytesUTF8","stringToUTF8"]' \
--shell-file "$SRCDIR/util/gpu/web/shell.html" \
-o "$OUTDIR/index.html"
echo "Built: $OUTDIR/index.html"
echo "Serve: python3 -m http.server -d $OUTDIR"
cp "$SRCDIR/util/gpu/web/dom.html" "$OUTDIR/"