From 2367b57294f3a731eb82474aaeb163b72f6dd57a Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 18 Aug 2023 15:13:47 +0900 Subject: [PATCH] wasm_build/Makefile: build objects seperately --- wasm_build/.gitignore | 1 + wasm_build/Makefile | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wasm_build/.gitignore b/wasm_build/.gitignore index 3a3e077..913a119 100644 --- a/wasm_build/.gitignore +++ b/wasm_build/.gitignore @@ -2,3 +2,4 @@ /jumpartifact.com_demo_0.js /jumpartifact.com_demo_0.wasm /jumpartifact.com_demo_0.data +/objdir/ diff --git a/wasm_build/Makefile b/wasm_build/Makefile index 261aeec..df315f1 100644 --- a/wasm_build/Makefile +++ b/wasm_build/Makefile @@ -4,6 +4,8 @@ else OTHER_FLAGS = -Og endif +OBJDIR = objdir + SOURCES = \ ../src/main.cc \ ../src/ems.cc \ @@ -24,11 +26,13 @@ HEADERS = \ ../src/3d_helpers.h \ ../src/walker.h +OBJECTS = $(addprefix ${OBJDIR}/,$(subst ..,PREVDIR,$(subst .cc,.cc.o,${SOURCES}))) + CXX = source ${HOME}/git/emsdk/emsdk_env.sh && em++ all: | format jumpartifact.com_demo_0.html -jumpartifact.com_demo_0.html: ${SOURCES} ${HEADERS} +jumpartifact.com_demo_0.html: ${OBJECTS} ${HEADERS} ${CXX} -std=c++20 -o jumpartifact.com_demo_0.html \ -s USE_GLFW=3 -I../wasm_include -L../wasm_lib -lraylib \ --shell-file custom_shell.html \ @@ -36,7 +40,7 @@ jumpartifact.com_demo_0.html: ${SOURCES} ${HEADERS} -sEXPORTED_RUNTIME_METHODS=ccall \ --preload-file ../res \ ${OTHER_FLAGS} \ - ${SOURCES} + ${OBJECTS} .PHONY: clean format @@ -45,6 +49,13 @@ clean: rm -f jumpartifact.com_demo_0.js rm -f jumpartifact.com_demo_0.wasm rm -f jumpartifact.com_demo_0.data + rm -rf "${OBJDIR}" format: clang-format -i --style=google ${SOURCES} ${HEADERS} + +.SECONDEXPANSION: + +${OBJDIR}/%.cc.o: $$(subst PREVDIR,..,%.cc) ${HEADERS} + @mkdir -p "${OBJDIR}/$(dir $(subst ..,PREVDIR,$<))" + ${CXX} -std=c++20 -I../wasm_include -c ${OTHER_FLAGS} -o $@ $<