From 959d0d259146c943fe3db61fd1664169303c6394 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 8 Aug 2020 14:08:56 +0200 Subject: [PATCH] Review Makefiles for WEB compilation --- examples/Makefile | 5 ++++- templates/advance_game/Makefile | 4 +--- templates/simple_game/Makefile | 14 ++++++-------- templates/standard_game/Makefile | 14 ++++++-------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index e3cf1c5f2..6824b5d99 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -176,6 +176,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) MAKE = make endif + ifeq ($(PLATFORM_OS),OSX) + MAKE = make + endif endif # Define compiler flags: @@ -196,7 +199,7 @@ ifeq ($(BUILD_MODE),DEBUG) endif else ifeq ($(PLATFORM),PLATFORM_WEB) - CFLAGS += -O3 + CFLAGS += -Os else CFLAGS += -s -O1 endif diff --git a/templates/advance_game/Makefile b/templates/advance_game/Makefile index ff67ea74d..5d11f44b9 100644 --- a/templates/advance_game/Makefile +++ b/templates/advance_game/Makefile @@ -229,14 +229,12 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=67108864 --preload-file resources + CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 -s FORCE_FILESYSTEM=1 --preload-file resources # Define a custom shell .html and output extension CFLAGS += --shell-file $(RAYLIB_PATH)/src/shell.html diff --git a/templates/simple_game/Makefile b/templates/simple_game/Makefile index 9614aeb58..1d77f6fe7 100644 --- a/templates/simple_game/Makefile +++ b/templates/simple_game/Makefile @@ -116,10 +116,10 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin + EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten + CLANG_PATH = $(EMSDK_PATH)/upstream/bin + PYTHON_PATH = $(EMSDK_PATH)/python/3.7.4_64bit + NODE_PATH = $(EMSDK_PATH)/node/12.18.1_64bit/bin export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) endif @@ -229,16 +229,14 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 + CFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=16777216 -s FORCE_FILESYSTEM=1 - # NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way, + # NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way, # we can compile same code for ALL platforms with no change required, but, working on bigger # projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw # logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference. diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index 4a576e819..64b8f22c8 100644 --- a/templates/standard_game/Makefile +++ b/templates/standard_game/Makefile @@ -116,10 +116,10 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables EMSDK_PATH ?= C:/emsdk - EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/fastcomp/emscripten - CLANG_PATH = $(EMSDK_PATH)/fastcomp/bin - PYTHON_PATH = $(EMSDK_PATH)/python/2.7.13.1_64bit/python-2.7.13.amd64 - NODE_PATH = $(EMSDK_PATH)/node/12.9.1_64bit/bin + EMSCRIPTEN_PATH ?= $(EMSDK_PATH)/upstream/emscripten + CLANG_PATH = $(EMSDK_PATH)/upstream/bin + PYTHON_PATH = $(EMSDK_PATH)/python/3.7.4_64bit + NODE_PATH = $(EMSDK_PATH)/node/12.18.1_64bit/bin export PATH = $(EMSDK_PATH);$(EMSCRIPTEN_PATH);$(CLANG_PATH);$(NODE_PATH);$(PYTHON_PATH);C:\raylib\MinGW\bin:$$(PATH) endif @@ -229,16 +229,14 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) # -s USE_PTHREADS=1 # multithreading support # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 + CFLAGS += -s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=16777216 -s FORCE_FILESYSTEM=1 - # NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way, + # NOTE: Simple raylib examples are compiled to be interpreter with asyncify, that way, # we can compile same code for ALL platforms with no change required, but, working on bigger # projects, code needs to be refactored to avoid a blocking while() loop, moving Update and Draw # logic to a self contained function: UpdateDrawFrame(), check core_basic_window_web.c for reference.