diff options
| author | Henry <mail@henrygressmann.de> | 2026-05-02 15:40:47 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-05-02 15:45:44 +0200 |
| commit | 5ed8982ad2cb4b348046aa11c527ce6a51f02e0e (patch) | |
| tree | c5427ac3ffdeedfa37b698eeb4f2dac09859b4a6 /examples/doom/build.sh | |
| parent | 361b715de9ea6a859aaafe84d4bcd3d46ed70797 (diff) | |
feat: add doom example, fix import argument order
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'examples/doom/build.sh')
| -rwxr-xr-x | examples/doom/build.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/doom/build.sh b/examples/doom/build.sh new file mode 100755 index 0000000..a6b6c01 --- /dev/null +++ b/examples/doom/build.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(dirname "$0")" + +upstream_dir="upstream/PureDOOM" +out_dir="out" +wrapper_src="guest/tinywasm_puredoom.c" +output="$out_dir/puredoom.wasm" + +if ! command -v git >/dev/null 2>&1; then + printf 'missing required tool: git\n' >&2 + exit 1 +fi + +if ! command -v clang >/dev/null 2>&1; then + printf 'missing required tool: clang\n' >&2 + exit 1 +fi + +mkdir -p "upstream" "$out_dir" + +if [[ ! -d "$upstream_dir/.git" ]]; then + git clone --depth 1 https://github.com/Daivuk/PureDOOM.git "$upstream_dir" +else + git -C "$upstream_dir" pull --ff-only +fi + +clang \ + --target=wasm32-unknown-unknown \ + -O2 \ + -nostdlib \ + -fno-builtin \ + -w \ + -Wl,--no-entry \ + -Wl,--allow-undefined \ + -Wl,--export=tinywasm_doom_init \ + -Wl,--export=tinywasm_doom_update \ + -Wl,--export=tinywasm_doom_framebuffer \ + -Wl,--export=tinywasm_doom_sound_buffer \ + -Wl,--export=tinywasm_doom_tick_midi \ + -Wl,--export=tinywasm_doom_wad_path_buf \ + -Wl,--export=tinywasm_doom_key_down \ + -Wl,--export=tinywasm_doom_key_up \ + -Wl,--export=memory \ + -Wl,--export=__heap_base \ + -Wl,--export=__data_end \ + -Wl,--initial-memory=16777216 \ + -Wl,--max-memory=268435456 \ + -Wl,--stack-first \ + -I"$upstream_dir" \ + "$wrapper_src" \ + -o "$output" + +printf 'built %s\n' "$output" |
