Building for web again
This commit is contained in:
49
build_web.sh
49
build_web.sh
@@ -1,9 +1,46 @@
|
||||
#!/usr/bin/bash
|
||||
set -e
|
||||
|
||||
incs="-Isrc/external/SDL/include -Isrc/external/lua/src -Isrc/external/glad -Lsrc/external/SDL/build_web -Isrc"
|
||||
wasmflags="-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb -msimd128 -sTOTAL_STACK=5MB -sINITIAL_MEMORY=256mb -sUSE_WEBGL2 -sFULL_ES3=1 -sUSE_SDL=3 -sASYNCIFY -sASSERTIONS=2"
|
||||
flags="-Wall -Wno-missing-braces -Wno-writable-strings -nostdlib++ -fno-exceptions -fdiagnostics-absolute-paths"
|
||||
dbg="-g -DDEBUG_BUILD=1 -gsource-map"
|
||||
rel="-O3 -DDEBUG_BUILD=0"
|
||||
for arg in "$@"; do declare "$arg"='1'; done
|
||||
if [ ! -v release ]; then debug=1; fi
|
||||
if [ -v debug ]; then echo "[web debug build]"; fi
|
||||
if [ -v release ]; then echo "[web release build]"; fi
|
||||
|
||||
emcc -o text_editor.html --shell-file=data/shell.html $flags $incs $wasmflags $dbg -lm -lSDL3 src/text_editor/text_editor.cpp
|
||||
# If emsdk is installed but not sourced in this shell, try the common location.
|
||||
if ! command -v emcc >/dev/null 2>&1; then
|
||||
if [ -f "$HOME/emsdk/emsdk_env.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
source "$HOME/emsdk/emsdk_env.sh" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! command -v emcc >/dev/null 2>&1; then
|
||||
echo "error: emcc not found. Source emsdk_env.sh or add emcc to PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p build_web
|
||||
|
||||
incs="-Isrc -Isrc/external/glad"
|
||||
flags="-Wall -Wextra -Werror -Wno-error=experimental -Wno-error=unused-parameter -Wformat=2 -Wundef -Wshadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-writable-strings \
|
||||
-fdiagnostics-absolute-paths \
|
||||
-nostdlib++ -fno-exceptions"
|
||||
wasmflags="-sALLOW_MEMORY_GROWTH=0 -sTOTAL_STACK=5MB -sINITIAL_MEMORY=256MB \
|
||||
-sUSE_SDL=3 -sUSE_WEBGL2=1 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES3=1 \
|
||||
-sASYNCIFY=1 -sASSERTIONS=2 \
|
||||
-sEXIT_RUNTIME=0 \
|
||||
-msimd128"
|
||||
|
||||
if [ -v debug ]; then
|
||||
flags="$flags -g -gsource-map -DDEBUG_BUILD=1"
|
||||
else
|
||||
flags="$flags -O3 -DDEBUG_BUILD=0"
|
||||
fi
|
||||
|
||||
emcc -o build_web/text_editor.html \
|
||||
--shell-file data/shell.html \
|
||||
$flags $incs $wasmflags \
|
||||
src/text_editor.cpp \
|
||||
-lm
|
||||
|
||||
echo "Wrote build_web/text_editor.html"
|
||||
|
||||
@@ -56,6 +56,7 @@ struct BlockArena {
|
||||
operator Allocator() { return {BlockArenaAllocatorProc, this}; }
|
||||
};
|
||||
|
||||
API void Init(BlockArena *arena);
|
||||
API void *PushSize(BlockArena *arena, size_t size);
|
||||
API void Release(BlockArena *arena);
|
||||
API void Unwind(BlockArena *arena, U8 *pos);
|
||||
|
||||
@@ -217,7 +217,7 @@ void IndentedNewLine(View *view) {
|
||||
For(view->carets) {
|
||||
Int front = GetFront(it);
|
||||
Int indent = GetLineIndent(buffer, PosToLine(buffer, front));
|
||||
String string = Format(scratch, "\n%.*s", indent, " ");
|
||||
String string = Format(scratch, "\n%.*s", (int)indent, " ");
|
||||
String16 string16 = ToString16(scratch, string);
|
||||
AddEdit(&edits, it.range, string16);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user