aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemscripten.py9
-rw-r--r--src/jsifier.js4
2 files changed, 9 insertions, 4 deletions
diff --git a/emscripten.py b/emscripten.py
index 3a0c6a8f..e8020788 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -224,6 +224,10 @@ def emscript(infile, settings, outfile, libraries=[]):
funcs_js = ''.join([output[0] for output in outputs])
if settings.get('ASM_JS'):
+ exports = []
+ for export in settings['EXPORTED_FUNCTIONS'] + settings['EXPORTED_GLOBALS']:
+ exports.append("'%s': %s" % (export, export))
+ exports = '{ ' + ', '.join(exports) + ' }'
funcs_js = '''
var asm = (function(env, buffer) {
'use asm';
@@ -236,9 +240,10 @@ var asm = (function(env, buffer) {
var HEAPF32 = new env.Float32Array(buffer);
var HEAPF64 = new env.Float64Array(buffer);
''' + funcs_js.replace('\n', '\n ') + '''
- return {};
+ return %s;
})({}, buffer);
-'''
+for (var export in asm) Module[export] = asm[export];
+''' % exports
for func_js, curr_forwarded_data in outputs:
# merge forwarded data
diff --git a/src/jsifier.js b/src/jsifier.js
index ce094e1e..a7c04c89 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -333,7 +333,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
js += '\n' + makePointer('[0]', null, allocator, ['void*'], index) + ';';
}
- if (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS)) {
+ if (!ASM_JS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
js += '\nModule["' + item.ident + '"] = ' + item.ident + ';';
}
if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
@@ -704,7 +704,7 @@ function JSify(data, functionsOnly, givenFunctions) {
func.JS += '\n//FUNCTION_END_MARKER_OF_SOURCE_FILE_' + associatedSourceFile + '\n';
}
- if (EXPORT_ALL || (func.ident in EXPORTED_FUNCTIONS)) {
+ if (!ASM_JS && (EXPORT_ALL || (func.ident in EXPORTED_GLOBALS))) {
func.JS += 'Module["' + func.ident + '"] = ' + func.ident + ';';
}