.PHONY: web test dist clean realclean ASSETS = $(wildcard game/www/*) TEST_PORT ?= 8000 EMCC_CFLAGS := -O3 \ -sUSE_GLFW=3 \ -sASSERTIONS=1 \ -sWASM=1 \ -sASYNCIFY \ -sGL_ENABLE_GET_PROC_ADDRESS=1 \ -sEXPORTED_RUNTIME_METHODS=HEAPF32,ccall,cwrap,callMain 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) dist: env \ CC=emcc \ EMCC_CFLAGS="$(EMCC_CFLAGS)" \ cargo build --target wasm32-unknown-emscripten --profile wasm 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 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 realclean: clean cargo clean