Move Odin renderer into gui/ with per-project Makefiles
Each sub-project (gui, api, infra) now owns its own Makefile, and the root Makefile is a lean delegator for the base commands (run, build, test, clean, fmt). Odin source, deps, and web assets live under gui/ (gui/src, gui/lib, gui/www), with scripts kept under gui/scripts for build tooling only.
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the WebAssembly ("web") build of DESI Explorer with Odin
|
||||
# (js_wasm32) + emscripten. Output: build/web/index.html (+ index.wasm,
|
||||
# odin.js) at the repo root. Run via `make -C gui build-web`.
|
||||
#
|
||||
# Requires:
|
||||
# - `odin` on PATH with the js_wasm32 target
|
||||
# - emcc / emscripten active in PATH
|
||||
# Optional:
|
||||
# - ODIN_ROOT (defaults to `odin root`)
|
||||
# - OUT_DIR (defaults to <repo>/build/web)
|
||||
set -euo pipefail
|
||||
|
||||
# Resolve the gui/ project root so this script works regardless of CWD.
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
GUI_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
ROOT_DIR="$(cd "${GUI_DIR}/.." && pwd)"
|
||||
|
||||
OUT_DIR="${OUT_DIR:-${ROOT_DIR}/build/web}"
|
||||
ODIN_ROOT="${ODIN_ROOT:-$(odin root)}"
|
||||
|
||||
mkdir -p "${GUI_DIR}/lib/local"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
# The Odin compiler emits a wasm object; raylib's C code is linked later by
|
||||
# emcc. `-define:RAYLIB_WASM_LIB=env.o` stops the compiler from trying to
|
||||
# link the raylib lib itself (emcc does that; it ends up in the final module).
|
||||
odin build "${GUI_DIR}/src" \
|
||||
-target:js_wasm32 \
|
||||
-build-mode:obj \
|
||||
-define:RAYLIB_WASM_LIB=env.o \
|
||||
-o:speed \
|
||||
-collection:lib="${GUI_DIR}/lib/local" \
|
||||
-out:"${OUT_DIR}/game"
|
||||
|
||||
# Odin's JS runtime glue; the generated module imports functions from it.
|
||||
cp "${ODIN_ROOT}/core/sys/wasm/js/odin.js" "${OUT_DIR}/odin.js"
|
||||
|
||||
# Link with emscripten against raylib's prebuilt web library. Flags mirror the
|
||||
# known-good karl-zylinski/odin-raylib-web template.
|
||||
emcc \
|
||||
-o "${OUT_DIR}/index.html" \
|
||||
"${OUT_DIR}/game.obj" \
|
||||
"${ODIN_ROOT}/vendor/raylib/wasm/libraylib.web.a" \
|
||||
--shell-file "${GUI_DIR}/www/index_template.html" \
|
||||
-sEXPORTED_RUNTIME_METHODS="['HEAPF32']" \
|
||||
-sUSE_GLFW=3 \
|
||||
-sWASM_BIGINT \
|
||||
-sWARN_ON_UNDEFINED_SYMBOLS=0 \
|
||||
-sASSERTIONS
|
||||
|
||||
rm -f "${OUT_DIR}/game.obj"
|
||||
|
||||
echo "Web build created in ${OUT_DIR}"
|
||||
Reference in New Issue
Block a user