Skip to content

Commit

Permalink
Merge pull request #38 from vitorio/housekeeping
Browse files Browse the repository at this point in the history
More housekeeping
  • Loading branch information
vitorio committed Dec 16, 2013
2 parents 2e9f04c + dae5c4e commit be611d7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
7 changes: 6 additions & 1 deletion make/common.mak
Expand Up @@ -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))
Expand Down
13 changes: 10 additions & 3 deletions makefile
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions pre.js

This file was deleted.

1 change: 1 addition & 0 deletions templates/default/index.html
Expand Up @@ -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>
Expand Down
7 changes: 6 additions & 1 deletion post.js → templates/default/post.js
Expand Up @@ -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');
10 changes: 10 additions & 0 deletions templates/default/pre.js
@@ -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.