diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-18 11:58:16 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-18 11:58:16 -0500 |
| commit | 064652034c988b5568196450330eeab97dd10280 (patch) | |
| tree | 5a77f9bf7512bd922724b2d80fe968fc4641a09c | |
| parent | wasm: fix canvas height (diff) | |
| download | DungeonCrawl-064652034c988b5568196450330eeab97dd10280.tar.gz DungeonCrawl-064652034c988b5568196450330eeab97dd10280.tar.bz2 DungeonCrawl-064652034c988b5568196450330eeab97dd10280.zip | |
wasm: add build version/date
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | game/www/index.html | 5 | ||||
| -rw-r--r-- | game/www/style.css | 1 |
3 files changed, 14 insertions, 6 deletions
@@ -1,7 +1,6 @@ .PHONY: web test dist clean realclean -ASSETS_SRC = $(wildcard game/www/*) -ASSETS_DST = $(patsubst game/www/%,dist/%,$(ASSETS_SRC)) +ASSETS = $(wildcard game/www/*) TEST_PORT ?= 8000 @@ -13,7 +12,10 @@ EMCC_CFLAGS := -O3 \ -sGL_ENABLE_GET_PROC_ADDRESS=1 \ -sEXPORTED_RUNTIME_METHODS=HEAPF32,ccall,cwrap,callMain -web: dist $(ASSETS_DST) +BUILD_DATE := $(shell date) +BUILD_VERSION := $(shell cargo pkgid -p game | cut -d '#' -f2) + +web: dist test: web cd dist && python3 -m http.server $(TEST_PORT) @@ -26,9 +28,9 @@ dist: mkdir -p dist cp ./target/wasm32-unknown-emscripten/wasm/game.js dist/game.js cp ./target/wasm32-unknown-emscripten/wasm/game.wasm dist/game.wasm - -dist/%: game/www/% - cp -r $< $@ + cp $(ASSETS) dist/ + sed -i 's/BUILD_VERSION/$(BUILD_VERSION)/' dist/index.html + sed -i 's/BUILD_DATE/$(BUILD_DATE)/' dist/index.html clean: rm -rf dist diff --git a/game/www/index.html b/game/www/index.html index 6210bb7..3c1805e 100644 --- a/game/www/index.html +++ b/game/www/index.html @@ -82,11 +82,16 @@ Module.callMain(args) } + function onRuntimeInitialized() { + outputLog('Loaded DungeonCrawl vBUILD_VERSION, built BUILD_DATE'); + } + var Module = { canvas, print: outputLog, printErr: errorLog, noInitialRun: true, + onRuntimeInitialized, }; </script> <script src="game.js"></script> diff --git a/game/www/style.css b/game/www/style.css index 70595a4..82ae311 100644 --- a/game/www/style.css +++ b/game/www/style.css @@ -23,6 +23,7 @@ body, html { height: 100%; + min-width: 700px; margin: 0; padding: 0; overflow: hidden; |