diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-29 15:05:41 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:20 -0800 |
commit | e944bb4580c4105a6653bcba4c0832d85f389843 (patch) | |
tree | aeab5a5779166d663ce524303342c78ccf76cc5c /emscripten.py | |
parent | df5d5b01426005ef577f5e7ddd9754804e53613c (diff) |
export global constructors from asm.js and get them dynamically in the outside scope
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/emscripten.py b/emscripten.py index b4e289d9..d7531ad1 100755 --- a/emscripten.py +++ b/emscripten.py @@ -128,10 +128,12 @@ def emscript(infile, settings, outfile, libraries=[]): # Save settings to a file to work around v8 issue 1579 settings_file = temp_files.get('.txt').name - settings_text = json.dumps(settings) - s = open(settings_file, 'w') - s.write(settings_text) - s.close() + def save_settings(): + settings_text = json.dumps(settings) + s = open(settings_file, 'w') + s.write(settings_text) + s.close() + save_settings() # Phase 1 - pre if DEBUG: t = time.time() @@ -169,6 +171,9 @@ def emscript(infile, settings, outfile, libraries=[]): if DEBUG: t = time.time() forwarded_json = json.loads(forwarded_data) indexed_functions = set() + if settings.get('ASM_JS'): + settings['EXPORTED_FUNCTIONS'] = forwarded_json['EXPORTED_FUNCTIONS'] + save_settings() chunks = shared.JCache.chunkify(funcs, chunk_size, 'emscript_files' if jcache else None) @@ -293,6 +298,7 @@ def emscript(infile, settings, outfile, libraries=[]): exports.append("'%s': %s" % (export, export)) exports = '{ ' + ', '.join(exports) + ' }' # calculate globals + del forwarded_json['Variables']['globals']['_llvm_global_ctors'] # not a true variable global_vars = forwarded_json['Variables']['globals'].keys() global_funcs = ['_' + x for x in forwarded_json['Functions']['libraryFunctions'].keys()] asm_globals = ''.join([' var ' + g + '=env.' + g + ';\n' for g in basics + global_funcs + global_vars]) |