Permalink
Browse files

Merge pull request #38 from vitorio/housekeeping

More housekeeping
  • Loading branch information...
2 parents 2e9f04c + dae5c4e commit be611d751aa841d0f7b16fa970614cec33d9c874 @vitorio vitorio committed Dec 16, 2013
Showing with 33 additions and 11 deletions.
  1. +6 −1 make/common.mak
  2. +10 −3 makefile
  3. +0 −6 pre.js
  4. +1 −0 templates/default/index.html
  5. +6 −1 { → templates/default}/post.js
  6. +10 −0 templates/default/pre.js
View
@@ -44,8 +44,13 @@ NATIVE_AR := ar
# Final directory for built files.
OBJ_DIR := $(OBJ_DIR)/$(SUBTARGET)
JS_OBJ_DIR := $(OBJ_DIR)/$(SYSTEM)
+
+ifndef TEMPLATE
+TEMPLATE := default
+endif
+
# The HTML template we'll be using.
-TEMPLATE_DIR := $(CURDIR)/templates/default
+TEMPLATE_DIR := $(CURDIR)/templates/$(TEMPLATE)
# All of the files in the template directory. Allows for 'smart' HTML rebuilding
TEMPLATE_FILES := $(shell ls $(TEMPLATE_DIR))
TEMPLATE_FILES := $(foreach TFILE,$(TEMPLATE_FILES),$(TEMPLATE_DIR)/$(TFILE))
View
@@ -31,7 +31,10 @@ OBJ_DIR := $(CURDIR)/build
# The variables below are not intended to be changed by the user.
#-------------------------------------------------------------------------------
EMCC_FLAGS :=
+
+ifndef DEBUG_NAME
DEBUG_NAME :=
+endif
ifdef SYSTEM
include $(CURDIR)/make/systems/$(SYSTEM).mak
@@ -47,6 +50,8 @@ include $(CURDIR)/make/common.mak
# Flags passed to emcc
EMCC_FLAGS += -O2 -s DISABLE_EXCEPTION_CATCHING=0 -s ALIASING_FUNCTION_POINTERS=1 -s OUTLINING_LIMIT=20000
+EMCC_FLAGS += -s EXPORTED_FUNCTIONS="['_main', '_malloc', \
+'__Z15ui_set_show_fpsi', '__Z15ui_get_show_fpsv']"
# Flags shared between the native tools build and emscripten build of MESS.
SHARED_MESS_FLAGS := OSD=sdl # Set the onscreen display to use SDL.
@@ -139,6 +144,8 @@ $(JS_OBJ_DIR)/index.html: $(JS_OBJ_DIR) $(TEMPLATE_FILES) $(BIOS_FILES) $(OBJ_DI
@cp $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js $(JS_OBJ_DIR)/
-@cp $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js.map $(JS_OBJ_DIR)/
@cp -r $(TEMPLATE_DIR)/* $(JS_OBJ_DIR)/
+ @rm $(JS_OBJ_DIR)/pre.js
+ @rm $(JS_OBJ_DIR)/post.js
@$(call SED_I,'s/BIOS_FILES/$(BIOS)/g' $(JS_OBJ_DIR)/messloader.js)
@$(call SED_I,'s/MESS_SRC/$(MESS_EXE)$(DEBUG_NAME).js/g' $(JS_OBJ_DIR)/messloader.js)
@$(call SED_I,'s/MESS_ARGS/$(MESS_ARGS)/g' $(JS_OBJ_DIR)/messloader.js)
@@ -165,11 +172,11 @@ $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js.gz: $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).j
@gzip -f -c $< > $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js.gz
# Runs emcc on LLVM bitcode version of MESS.
-$(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js: mess/$(MESS_EXE)$(DEBUG_NAME).bc pre.js post.js
- $(EMCC) $(EMCC_FLAGS) $< -o $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js --pre-js pre.js --post-js post.js
+$(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js: mess/$(MESS_EXE)$(DEBUG_NAME).bc $(TEMPLATE_DIR)/pre.js $(TEMPLATE_DIR)/post.js
+ $(EMCC) $(EMCC_FLAGS) $< -o $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js --pre-js $(TEMPLATE_DIR)/pre.js --post-js $(TEMPLATE_DIR)/post.js
@$(call SED_I,'s/JSMESS_MESS_BUILD_VERSION/$(JSMESS_MESS_BUILD_VERSION)/' $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js)
@$(call SED_I,'s/JSMESS_EMCC_VERSION/$(JSMESS_EMCC_VERSION)/' $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js)
- @$(call SED_I,'s/JSMESS_EMCC_FLAGS/$(EMCC_FLAGS)/' $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js)
+ @$(call SED_I,'s/JSMESS_EMCC_FLAGS/$(subst ",\\", $(EMCC_FLAGS))/' $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js)
@$(call SED_I,'s/JSMESS_MESS_FLAGS/$(subst ",\\", $(subst /,\/, $(MESS_FLAGS)))/' $(OBJ_DIR)/$(MESS_EXE)$(DEBUG_NAME).js)
# Copies over the LLVM bitcode for MESS into a .bc file.
View
@@ -1,6 +0,0 @@
-if(!window.console){ window.console = {log: function(){} }; }
-console.log("MESS BUILD_VERSION == JSMESS_MESS_BUILD_VERSION");
-console.log("EMCC VERSION == JSMESS_EMCC_VERSION");
-console.log("EMCC_FLAGS == JSMESS_EMCC_FLAGS");
-console.log("MESS_FLAGS == JSMESS_MESS_FLAGS");
-
@@ -21,6 +21,7 @@
<h1 style="text-align: center;">MESS in a browser!</h1>
<div id='canvasholder' style="text-align: center;">
</div>
+ <div><a href="javascript:JSMESS.ui_set_show_fps(!JSMESS.ui_get_show_fps());">Toggle MESS performance indicator</a></div>
<div id='status' style="display:block;"></div>
<div id='output' style="display:block;"></div>
</body>
@@ -34,4 +34,9 @@ function _SDL_RenderCopy() {}
function _SDL_RenderPresent() {}
function _SDL_GL_LoadLibrary() {}
function _SDL_GL_DeleteContext() {}
-function _SDL_GL_DestroyWindow() {}
+function _SDL_GL_DestroyWindow() {}
+
+// MESS-JavaScript function mappings
+var JSMESS = JSMESS || {};
+JSMESS.ui_set_show_fps = Module.cwrap('_Z15ui_set_show_fpsi', '', ['number']);
+JSMESS.ui_get_show_fps = Module.cwrap('_Z15ui_get_show_fpsv', 'number');
@@ -0,0 +1,10 @@
+if(!window.console){ window.console = {log: function(){} }; }
+var JSMESS = JSMESS || {};
+JSMESS.MESS_BUILD_VERSION = "JSMESS_MESS_BUILD_VERSION";
+JSMESS.EMCC_VERSION = "JSMESS_EMCC_VERSION";
+JSMESS.EMCC_FLAGS = "JSMESS_EMCC_FLAGS";
+JSMESS.MESS_FLAGS = "JSMESS_MESS_FLAGS";
+console.log("MESS BUILD_VERSION == " + JSMESS.MESS_BUILD_VERSION);
+console.log("EMCC VERSION == " + JSMESS.EMCC_VERSION);
+console.log("EMCC_FLAGS == " + JSMESS.EMCC_FLAGS);
+console.log("MESS_FLAGS == " + JSMESS.MESS_FLAGS);

0 comments on commit be611d7

Please sign in to comment.