ems_rust_template/Makefile

42 lines
997 B
Makefile
Raw Normal View History

ifdef RELEASE
RUST_BUILD_TYPE := release
RUST_EXTRA_FLAGS := --release
C_OTHER_FLAGS := -DNDEBUG -O2
else
RUST_BUILD_TYPE := debug
RUST_EXTRA_FLAGS :=
C_OTHER_FLAGS := -Og
endif
CC := source ${HOME}/git/emsdk/emsdk_env.sh && emcc
CFLAGS := \
-Irust_src/include \
-sEXPORTED_FUNCTIONS=_main \
-sSTACK_SIZE=2097152 \
${C_OTHER_FLAGS}
# Check https://emscripten.org/docs/tools_reference/emcc.html for more compiler
# flags to pass to emcc.
HEADERS := \
rust_src/include/rust_src.h
all: dist
rust_src/target/wasm32-unknown-emscripten/${RUST_BUILD_TYPE}/libems_rust_template.a:
cd rust_src && cargo build --target=wasm32-unknown-emscripten ${RUST_EXTRA_FLAGS}
dist: rust_src/target/wasm32-unknown-emscripten/${RUST_BUILD_TYPE}/libems_rust_template.a src/main.c.o
@mkdir dist
${CC} -o dist/game.html ${CFLAGS} $^
ln -s game.html dist/index.html
.PHONY: clean
clean:
cd rust_src && cargo clean
rm -f src/*.c.o
rm -rf dist
%.c.o: %.c ${HEADERS}
${CC} -o $@ -c ${CFLAGS} $<