diff options
102 files changed, 52868 insertions, 100 deletions
@@ -58,5 +58,5 @@ a license to everyone to use it as detailed in LICENSE.) * Felix H. Dahlke <fhd@ubercode.de> * Éloi Rivard <azmeuk@gmail.com> * Alexander Gladysh <ag@logiceditor.com> - +* Arlo Breault <arlolra@gmail.com> @@ -470,6 +470,11 @@ Options that are modified or new in %s include: libraries, and after any link-time optimizations (if any). + --memory-init-file <on> If on, we generate a separate memory initialization + file. This is more efficient than storing the + memory initialization data embedded inside + JavaScript as text. (default is on) + The target file, if specified (-o <target>), defines what will be generated: @@ -716,6 +721,7 @@ try: bind = False jcache = False save_bc = False + memory_init_file = False # XXX TODO True if use_cxx: default_cxx_std = '-std=c++03' # Enforce a consistent C++ standard when compiling .cpp files, if user does not specify one on the cmdline. @@ -849,6 +855,11 @@ try: save_bc = newargs[i+1] newargs[i] = '' newargs[i+1] = '' + elif newargs[i] == '--memory-init-file': + check_bad_eq(newargs[i]) + memory_init_file = int(newargs[i+1]) + newargs[i] = '' + newargs[i+1] = '' elif newargs[i].startswith(('-I/', '-L/')): if not absolute_warning_shown: print >> sys.stderr, 'emcc: warning: -I or -L of an absolute path encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)' # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not @@ -1429,6 +1440,32 @@ try: src = re.sub(r'\n+[ \n]*\n+', '\n', src) 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 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 we were asked to also generate HTML, do that if final_suffix == 'html': if DEBUG: print >> sys.stderr, 'emcc: generating HTML' diff --git a/src/jsifier.js b/src/jsifier.js index ce089334..50030268 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1524,6 +1524,8 @@ function JSify(data, functionsOnly, givenFunctions) { }); // write out the singleton big memory initialization value print('/* memory initializer */ ' + makePointer(memoryInitialization, null, 'ALLOC_NONE', 'i8', 'TOTAL_STACK', true)); // we assert on TOTAL_STACK == GLOBAL_BASE + } else { + print('/* memory initializer */'); // test purposes } } diff --git a/src/library_browser.js b/src/library_browser.js index 099516a8..c1add740 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -379,7 +379,7 @@ mergeInto(LibraryManager.library, { xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.onload = function() { - if (xhr.status == 200) { + if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 onload(xhr.response); } else { onerror(); diff --git a/src/library_glfw.js b/src/library_glfw.js index 71552cd8..8bf3616f 100644 --- a/src/library_glfw.js +++ b/src/library_glfw.js @@ -32,7 +32,6 @@ var LibraryGLFW = { resizeFunc: null, closeFunc: null, refreshFunc: null, - mouseFunc: null, params: null, initTime: null, wheelPos: 0, @@ -470,7 +469,7 @@ var LibraryGLFW = { }, glfwSetMousePosCallback: function(cbfun) { - GLFW.mouseFunc = cbfun; + GLFW.mousePosFunc = cbfun; }, glfwSetMouseWheelCallback: function(cbfun) { diff --git a/src/library_openal.js b/src/library_openal.js index 0b6e9b2f..6a97fce7 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -13,11 +13,30 @@ var LibraryOpenAL = { alcMakeContextCurrent: function(context) { if (context == 0) { AL.currentContext = null; + return 0; } else { AL.currentContext = AL.contexts[context - 1]; + return 1; } }, < |