aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc49
1 files changed, 26 insertions, 23 deletions
diff --git a/emcc b/emcc
index 15c38cd4..adca1266 100755
--- a/emcc
+++ b/emcc
@@ -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':