Update
This commit is contained in:
commit
7a83face87
191 changed files with 355618 additions and 0 deletions
59
build_web.sh
Executable file
59
build_web.sh
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash -eu
|
||||
|
||||
PROJECT_NAME="transformation_visualizer"
|
||||
ASSETS_DIR="src/assets"
|
||||
RAYLIB_PATH="src/libraries/raylib"
|
||||
EMSCRIPTEN_SDK_DIR="$HOME/programs/emsdk"
|
||||
OUT_DIR="build/web"
|
||||
INDEX_TEMPLATE_PATH="src/web/index_template.html"
|
||||
|
||||
if [[ -v 1 ]]; then
|
||||
if [ "$1" = "DEBUG" ]; then
|
||||
ODIN_FLAGS="-debug"
|
||||
EMCC_FLAGS="-O0"
|
||||
elif [ "$1" = "RELEASE" ]; then
|
||||
ODIN_FLAGS="-o:size"
|
||||
EMCC_FLAGS="-O2"
|
||||
else
|
||||
echo "Usage: <script> <DEBUG/RELEASE>"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Usage: <script> <DEBUG/RELEASE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WASM_OBJ_NAME="transformation_visualizer.wasm.obj"
|
||||
rm -r $OUT_DIR
|
||||
mkdir -p $OUT_DIR
|
||||
|
||||
export EMSDK_QUIET=1
|
||||
[[ -f "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh" ]] && . "$EMSCRIPTEN_SDK_DIR/emsdk_env.sh"
|
||||
|
||||
# Note RAYLIB_WASM_LIB=env.o -- env.o is an internal WASM object file. You can
|
||||
# see how RAYLIB_WASM_LIB is used inside <odin>/vendor/raylib/raylib.odin.
|
||||
#
|
||||
# The emcc call will be fed the actual raylib library file. That stuff will end
|
||||
# up in env.o
|
||||
ODIN_DEFINES="-define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o"
|
||||
odin build src/web/ -target:js_wasm32 -target-features:simd128 -build-mode:obj $ODIN_DEFINES $ODIN_FLAGS -out:$OUT_DIR/$WASM_OBJ_NAME
|
||||
|
||||
ODIN_PATH=$(odin root)
|
||||
|
||||
cp $ODIN_PATH/core/sys/wasm/js/odin.js $OUT_DIR
|
||||
|
||||
files="$OUT_DIR/$WASM_OBJ_NAME $RAYLIB_PATH/wasm/libraylib.a $RAYLIB_PATH/wasm/libraygui.a"
|
||||
|
||||
# index_template.html contains the javascript code that calls the procedures in
|
||||
# source/main_web/main_web.odin
|
||||
# TODO (synthas): Investigate why emcc's emscripten flag causes a linker error on itch.io
|
||||
EMCC_SETTINGS="-sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0"
|
||||
flags="$EMCC_FLAGS $EMCC_SETTINGS --shell-file $INDEX_TEMPLATE_PATH --preload-file src/assets"
|
||||
|
||||
# For debugging: Add `-g` to `emcc` (gives better error callstack in chrome)
|
||||
emcc -o $OUT_DIR/index.html $files $flags
|
||||
|
||||
rm -f $OUT_DIR/$WASM_OBJ_NAME
|
||||
zip -r $OUT_DIR/${PROJECT_NAME}.zip $OUT_DIR
|
||||
|
||||
echo "Web build created in ${OUT_DIR}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue