Change project structure for cross build

This commit is contained in:
Synthasmagoria 2026-09-01 14:12:06 +02:00
commit 80b3e83d4d
17 changed files with 44 additions and 43 deletions

View file

@ -4,13 +4,13 @@ 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"
elif [ "$1" = "RELEASE" ]; then
# unsure if this will work
ODIN_FLAGS="-o:minimal"
ODIN_FLAGS=""
else
echo "Usage: <script> <DEBUG/RELEASE>"
exit 1
@ -32,7 +32,7 @@ export EMSDK_QUIET=1
# 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/ -target:js_wasm32 -build-mode:obj $ODIN_DEFINES $ODIN_FLAGS -out:$OUT_DIR/$WASM_OBJ_NAME
odin build src/web/ -target:js_wasm32 -build-mode:obj $ODIN_DEFINES $ODIN_FLAGS -out:$OUT_DIR/$WASM_OBJ_NAME
ODIN_PATH=$(odin root)
@ -42,10 +42,10 @@ files="$OUT_DIR/$WASM_OBJ_NAME $RAYLIB_PATH/wasm/libraylib.a $RAYLIB_PATH/wasm/l
# 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 src/assets"
flags="-O0 -sEXPORTED_RUNTIME_METHODS=['HEAPF32'] -sUSE_GLFW=3 -sWASM_BIGINT -sWARN_ON_UNDEFINED_SYMBOLS=0 --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
emcc -g -o $OUT_DIR/index.html $files $flags
rm -f $OUT_DIR/$WASM_OBJ_NAME