Better build and project file platform layer
This commit is contained in:
parent
db99033197
commit
2469b45694
8 changed files with 137 additions and 70 deletions
31
build_web.sh
31
build_web.sh
|
|
@ -1,9 +1,25 @@
|
|||
#!/bin/bash -eu
|
||||
|
||||
# Point this to where you installed emscripten. Optional on systems that already
|
||||
# have `emcc` in the path.
|
||||
if [[ -v 1 ]]; then
|
||||
if [ "$1" = "DEBUG" ]; then
|
||||
ODIN_FLAGS="-debug"
|
||||
elif [ "$1" = "RELEASE" ]; then
|
||||
ODIN_FLAGS="-no-bounds-check -disable-assert -o:size -extra-linker-flags:\"-Wl,--gc-sections,-s\""
|
||||
elif [ "$1" = "TEST" ]; then
|
||||
ODIN_FLAGS="-o:minimal -extra-linker-flags:\"-Wl,--gc-sections,-s\""
|
||||
else
|
||||
echo "Usage: <script> <DEBUG/RELEASE>"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Usage: <script> <DEBUG/RELEASE>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RAYLIB_PATH="src/libraries/raylib"
|
||||
EMSCRIPTEN_SDK_DIR="$HOME/programs/emsdk"
|
||||
OUT_DIR="build/web"
|
||||
WASM_OBJ_NAME="transformation_visulalizer.wasm.obj"
|
||||
|
||||
mkdir -p $OUT_DIR
|
||||
|
||||
|
|
@ -15,23 +31,22 @@ export EMSDK_QUIET=1
|
|||
#
|
||||
# The emcc call will be fed the actual raylib library file. That stuff will end
|
||||
# up in env.o
|
||||
#
|
||||
# Note that there is a rayGUI equivalent: -define:RAYGUI_WASM_LIB=env.o
|
||||
odin build . -target:js_wasm32 -build-mode:obj -define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o -vet -strict-style -out:$OUT_DIR/game.wasm.obj
|
||||
ODIN_DEFINES="-define:RAYLIB_WASM_LIB=env.o -define:RAYGUI_WASM_LIB=env.o"
|
||||
odin build src/ -target:js_wasm32 -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/game.wasm.obj libraries/raylib/wasm/libraylib.a libraries/raylib/wasm/libraygui.a"
|
||||
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
|
||||
flags="-Oz -sASSERTIONS=0 --closure 0 -sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 -sDECLARE_ASM_MODULE_EXPORTS=0 --shell-file index_template.html --preload-file assets"
|
||||
flags="-Oz -sASSERTIONS=0 --closure 0 -sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 -sDECLARE_ASM_MODULE_EXPORTS=0 --shell-file index_template.html --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 $OUT_DIR/game.wasm.obj
|
||||
rm -f $OUT_DIR/$WASM_OBJ_NAME
|
||||
|
||||
echo "Web build created in ${OUT_DIR}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue