diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-10 17:30:40 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-10 17:30:40 -0700 |
commit | bc234c204c0a1d6d02363e9a60418dd52a6c3c87 (patch) | |
tree | 6af91989fd966c57e7eb023b6e914b330a338b0b | |
parent | f57081e7f1f4e8ab3b4be047a2a1f7217bb4dce3 (diff) |
do not use memory init file without ta2, since we lay out memory in ta2 format in binary files
-rwxr-xr-x | emcc | 49 |
1 files changed, 26 insertions, 23 deletions
@@ -1444,30 +1444,33 @@ try: open(final, 'w').write(src) if memory_init_file: - memfile = target + '.mem' - seen_memory_init = False - def repl(m): - seen_memory_init = True - # handle chunking of the memory initializer - s = re.sub('[\[\]\n\(\)\. ]', '', m.groups(0)[0]) - s = s.replace('concat', ',') - if s[-1] == ',': s = s[:-1] - open(memfile, 'wb').write(''.join(map(lambda x: chr(int(x or '0')), s.split(',')))) + if shared.Settings.USE_TYPED_ARRAYS != 2: + if type(memory_init_file) == int: print >> sys.stderr, 'emcc: warning: memory init file requires typed arrays mode 2' + else: + memfile = target + '.mem' + seen_memory_init = False + def repl(m): + seen_memory_init = True + # handle chunking of the memory initializer + s = re.sub('[\[\]\n\(\)\. ]', '', m.groups(0)[0]) + s = s.replace('concat', ',') + if s[-1] == ',': s = s[:-1] + open(memfile, 'wb').write(''.join(map(lambda x: chr(int(x or '0')), s.split(',')))) + if DEBUG: + # Copy into temp dir as well, so can be run there too + temp_memfile = os.path.join(shared.EMSCRIPTEN_TEMP_DIR, os.path.basename(memfile)) + if os.path.abspath(memfile) != os.path.abspath(memfile): + shutil.copyfile(memfile, temp_memfile) + return 'loadMemoryInitializer("%s");' % os.path.basename(memfile) + src = re.sub('/\* memory initializer \*/ allocate\(([\d,\.concat\(\)\[\]\\n ]+)"i8", ALLOC_NONE, TOTAL_STACK\)', repl, src, count=1) + open(final + '.mem.js', 'w').write(src) + final += '.mem.js' if DEBUG: - # Copy into temp dir as well, so can be run there too - temp_memfile = os.path.join(shared.EMSCRIPTEN_TEMP_DIR, os.path.basename(memfile)) - if os.path.abspath(memfile) != os.path.abspath(memfile): - shutil.copyfile(memfile, temp_memfile) - return 'loadMemoryInitializer("%s");' % os.path.basename(memfile) - src = re.sub('/\* memory initializer \*/ allocate\(([\d,\.concat\(\)\[\]\\n ]+)"i8", ALLOC_NONE, TOTAL_STACK\)', repl, src, count=1) - open(final + '.mem.js', 'w').write(src) - final += '.mem.js' - if DEBUG: - if seen_memory_init: - save_intermediate('meminit') - print >> sys.stderr, 'emcc: wrote memory initialization to %s' % memfile - else: - print >> sys.stderr, 'emcc: did not see memory initialization' + if seen_memory_init: + save_intermediate('meminit') + print >> sys.stderr, 'emcc: wrote memory initialization to %s' % memfile + else: + print >> sys.stderr, 'emcc: did not see memory initialization' # If we were asked to also generate HTML, do that if final_suffix == 'html': |