From 62dad32020a9cac9d65125c08493c29ed4dd9715 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 13 Dec 2023 23:44:05 -0800 Subject: [PATCH] Added wasm options to makefiles --- VortexEngine/Makefile | 10 ++++++++-- VortexEngine/VortexCLI/Makefile | 3 ++- VortexEngine/VortexCLI/VortexCLI.cpp | 2 +- VortexEngine/VortexLib/Makefile | 14 +++++++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/VortexEngine/Makefile b/VortexEngine/Makefile index ce19cbd704..d829b8cb14 100644 --- a/VortexEngine/Makefile +++ b/VortexEngine/Makefile @@ -10,8 +10,7 @@ RANLIB=ranlib # target files TARGETS=\ - vortex \ - vortex.a + vortex .PHONY: $(TARGETS) @@ -21,6 +20,10 @@ all: $(TARGETS) # unit test target tests: $(TESTS) +# force sub-build of wasm +wasm: FORCE + env WASM=1 $(MAKE) + vortex.a: $(MAKE) -C VortexLib cp -f VortexLib/vortex.a . @@ -29,6 +32,9 @@ vortex: $(MAKE) -C VortexCLI cp -f VortexCLI/vortex . +# emptry rule forces stuff to re reun every time +FORCE: + # generic clean target clean: @$(RM) $(TARGETS) $(TESTS) vortex.exe diff --git a/VortexEngine/VortexCLI/Makefile b/VortexEngine/VortexCLI/Makefile index 54d6fc0e6a..5b4dc85bf4 100644 --- a/VortexEngine/VortexCLI/Makefile +++ b/VortexEngine/VortexCLI/Makefile @@ -31,6 +31,7 @@ INCLUDES=\ ifdef WASM DEFINES += -D WASM +CFLAGS += -s DISABLE_EXCEPTION_CATCHING=0 --bind endif ifdef TESTFRAMEWORK @@ -125,7 +126,7 @@ FORCE: # generic clean target clean: - @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) *.txt FlashStorage.flash + @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) vortex.wasm *.txt FlashStorage.flash $(MAKE) -C ../VortexLib clean # Now include our target dependency files diff --git a/VortexEngine/VortexCLI/VortexCLI.cpp b/VortexEngine/VortexCLI/VortexCLI.cpp index 64e629c56a..9097f621a8 100644 --- a/VortexEngine/VortexCLI/VortexCLI.cpp +++ b/VortexEngine/VortexCLI/VortexCLI.cpp @@ -137,7 +137,7 @@ static void wasm_init() emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback); emscripten_set_main_loop(do_run, 0, true); // turn colored output off in the wasm version - g_pVortexCLI->setColoredOuptut(false); + //g_pVortexCLI->setColoredOuptut(false); } #endif // ifdef WASM diff --git a/VortexEngine/VortexLib/Makefile b/VortexEngine/VortexLib/Makefile index c596f256a8..d3e58ef22c 100644 --- a/VortexEngine/VortexLib/Makefile +++ b/VortexEngine/VortexLib/Makefile @@ -31,6 +31,7 @@ INCLUDES=\ ifdef WASM DEFINES += -D WASM +CFLAGS += --bind -s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME='VortexLib' endif ifdef TESTFRAMEWORK @@ -91,8 +92,12 @@ DEPS=\ TESTS=\ # target files -TARGETS=\ - vortex.a \ +ifdef WASM +TARGETS=VortexLib.js \ + vortex.a +else +TARGETS=vortex.a +endif # Default target for 'make' command all: $(TARGETS) @@ -108,6 +113,9 @@ wasm: FORCE vortex.a: $(DEPS) $(AR) $@ $^ +VortexLib.js: $(DEPS) + $(CC) $(CFLAGS) $^ -o $@ $(LLIBS) + # catch-all make target to generate .o and .d files %.o: %.cpp $(CC) $(CFLAGS) -MMD -c $< -o $@ @@ -124,7 +132,7 @@ FORCE: # generic clean target clean: - @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) + @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) VortexLib.js vortex.wasm # Now include our target dependency files # the hyphen means ignore non-existent files