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:
@@ -1,48 +0,0 @@
|
||||
#!/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).
|
||||
#
|
||||
# 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 build/web)
|
||||
set -euo pipefail
|
||||
|
||||
OUT_DIR="${OUT_DIR:-build/web}"
|
||||
ODIN_ROOT="${ODIN_ROOT:-$(odin root)}"
|
||||
|
||||
mkdir -p 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 src \
|
||||
-target:js_wasm32 \
|
||||
-build-mode:obj \
|
||||
-define:RAYLIB_WASM_LIB=env.o \
|
||||
-o:speed \
|
||||
-collection:lib=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 scripts/web/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}"
|
||||
@@ -1,50 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>DESI Explorer</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: #05050f;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" tabindex="-1" oncontextmenu="event.preventDefault()"></canvas>
|
||||
|
||||
<!-- Odin's JS runtime glue; required by the generated wasm module. -->
|
||||
<script src="odin.js"></script>
|
||||
|
||||
<script>
|
||||
var odinMemoryInterface = new odin.WasmMemoryInterface();
|
||||
odinMemoryInterface.setIntSize(4);
|
||||
var odinImports = odin.setupDefaultImports(odinMemoryInterface);
|
||||
|
||||
var Module = {
|
||||
instantiateWasm: function(imports, successCallback) {
|
||||
var newImports = Object.assign({}, odinImports, imports);
|
||||
return WebAssembly.instantiateStreaming(fetch("index.wasm"), newImports).then(
|
||||
function(output) {
|
||||
var e = output.instance.exports;
|
||||
odinMemoryInterface.setExports(e);
|
||||
odinMemoryInterface.setMemory(e.memory);
|
||||
return successCallback(output.instance);
|
||||
}
|
||||
);
|
||||
},
|
||||
onRuntimeInitialized: function() {
|
||||
var e = wasmExports;
|
||||
if (e._start) { e._start(); }
|
||||
},
|
||||
canvas: document.getElementById("canvas")
|
||||
};
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user