diff options
author | max99x <max99x@gmail.com> | 2011-07-31 04:48:43 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-31 04:48:43 +0300 |
commit | 7f735afe5ee57f693602b661e8e6286dcc914c72 (patch) | |
tree | b2600adf0702544c40453febbf8fd5e09e048102 | |
parent | 4477fc67dea3cf0e6d54f4ae59946a70b069e7ae (diff) | |
parent | 3928f293b817a48797faf10b10a69240236de767 (diff) |
Merge remote-tracking branch 'upstream/master'
-rwxr-xr-x | emscripten.py | 13 | ||||
-rw-r--r-- | src/compiler.js | 18 | ||||
-rw-r--r-- | src/library.js | 9 | ||||
-rw-r--r-- | src/preamble.js | 9 | ||||
-rw-r--r-- | src/shell.js | 12 | ||||
-rw-r--r-- | tests/runner.py | 5 | ||||
-rw-r--r-- | tools/shared.py | 4 |
7 files changed, 39 insertions, 31 deletions
diff --git a/emscripten.py b/emscripten.py index b77c361d..022068c8 100755 --- a/emscripten.py +++ b/emscripten.py @@ -150,13 +150,12 @@ def emscript(infile, settings, outfile): defined in src/settings.js. outfile: The file where the output is written. """ - data = open(infile, 'r').read() + settings_file = get_temp_file('.txt').name # Save settings to a file to work around v8 issue 1579 + s = open(settings_file, 'w') + s.write(settings) + s.close() compiler = path_from_root('src', 'compiler.js') - subprocess.Popen(shared.COMPILER_ENGINE + [compiler], - stdin=subprocess.PIPE, - stdout=outfile, - cwd=path_from_root('src'), - stderr=subprocess.STDOUT).communicate(settings + '\n' + data) + shared.run_js(shared.COMPILER_ENGINE, compiler, [settings_file, infile], stdout=outfile, stderr=subprocess.STDOUT, cwd=path_from_root('src')) outfile.close() @@ -220,7 +219,7 @@ if __name__ == '__main__': keywords, positional = parser.parse_args() if len(positional) != 1: raise RuntimeError('Must provide exactly one positional argument.') - keywords.infile = positional[0] + keywords.infile = os.path.abspath(positional[0]) if isinstance(keywords.outfile, basestring): keywords.outfile = open(keywords.outfile, 'w') diff --git a/src/compiler.js b/src/compiler.js index 8cb023d9..8980da93 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -12,6 +12,9 @@ if (!this['load']) { if (!this['read']) { read = function(f) { snarf(f) }; } +if (!this['arguments']) { + arguments = scriptArgs; +} // Basic utilities @@ -21,7 +24,10 @@ load('utility.js'); load('settings.js'); -var settings = JSON.parse(readline()); +var settings_file = arguments[0]; +var ll_file = arguments[1]; + +var settings = JSON.parse(read(settings_file)); for (setting in settings) { this[setting] = settings[setting]; } @@ -64,13 +70,9 @@ eval(processMacros(preprocess(read('runtime.js')))); // Read llvm -var lines = []; -var line; -do { - line = readline(); - if (line == null) break; - lines.push(line); -} while(true); +var raw = read(ll_file); +var lines = raw.split('\n'); +raw = null; // Do it diff --git a/src/library.js b/src/library.js index a1bd16ae..dcd1e22c 100644 --- a/src/library.js +++ b/src/library.js @@ -264,10 +264,15 @@ LibraryManager.library = { // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. var xhr = new XMLHttpRequest(); xhr.open('GET', obj.url, false); - xhr.overrideMimeType('text/plain; charset=x-user-defined'); // Binary. + xhr.responseType = 'arraybuffer'; // hint to the browser that we want binary data + xhr.overrideMimeType('text/plain; charset=x-user-defined'); // another hint xhr.send(null); if (xhr.status != 200 && xhr.status != 0) success = false; - obj.contents = intArrayFromString(xhr.responseText || '', true); + if (xhr.response) { + obj.contents = new Uint8Array(xhr.response); + } else { + obj.contents = intArrayFromString(xhr.responseText || '', true); + } } else if (typeof read !== 'undefined') { // Command-line. try { diff --git a/src/preamble.js b/src/preamble.js index 99288244..d4f5e570 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -549,13 +549,8 @@ function String_copy(ptr, addZero) { // Tools -function jrint(label, obj) { // XXX manual debugging - if (!obj) { - obj = label; - label = ''; - } else - label = label + ' : '; - print(label + JSON.stringify(obj)); +if (typeof print === 'undefined') { + print = console.log; // we are on the web } // This processes a JS string into a C-line array of numbers, 0-terminated. diff --git a/src/shell.js b/src/shell.js index 06cf4175..222aba26 100644 --- a/src/shell.js +++ b/src/shell.js @@ -12,13 +12,15 @@ if (!this['Module']) { this['Module'] = {}; } -try { - Module.arguments = scriptArgs; -} catch(e) { +if (!Module.arguments) { try { - Module.arguments = arguments; + Module.arguments = scriptArgs; } catch(e) { - Module.arguments = []; + try { + Module.arguments = arguments; + } catch(e) { + Module.arguments = []; + } } } //*/ diff --git a/tests/runner.py b/tests/runner.py index e7659760..330c0726 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -181,6 +181,7 @@ class RunnerCore(unittest.TestCase): pass settings = ['-s %s=%s' % (k, json.dumps(v)) for k, v in exported_settings.items()] compiler_output = timeout_run(Popen([EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE, stderr=STDOUT), TIMEOUT, 'Compiling') + #print compiler_output # Detect compilation crashes and errors if compiler_output is not None and 'Traceback' in compiler_output and 'in test_' in compiler_output: print compiler_output; assert 0 @@ -2740,6 +2741,7 @@ if 'benchmark' not in sys.argv: self.do_ll_test(path_from_root('tests', 'lua', 'lua.ll'), 'hello lua world!\n17\n1\n2\n3\n4\n7', + js_engines=[V8_ENGINE], # XXX Moz bug 675269 args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''], output_nicerizer=lambda string: string.replace('\n\n', '\n').replace('\n\n', '\n')) @@ -2928,6 +2930,7 @@ if 'benchmark' not in sys.argv: global USE_TYPED_ARRAYS global CORRECT_SIGNS if USE_TYPED_ARRAYS == 2: + return self.skip() # XXX Moz bug 675269 CORRECT_SIGNS = 1 else: CORRECT_SIGNS = 2 @@ -3008,6 +3011,7 @@ if 'benchmark' not in sys.argv: os.path.join(self.get_building_dir(), 'openjpeg')], force_c=True, post_build=post, + js_engines=[V8_ENGINE], # XXX Moz bug 675269 output_nicerizer=image_compare)# build_ll_hook=self.do_autodebug) def test_python(self): @@ -3021,6 +3025,7 @@ if 'benchmark' not in sys.argv: self.do_ll_test(path_from_root('tests', 'python', 'python.ll'), 'hello python world!\n[0, 2, 4, 6]\n5\n22\n5.470000', + js_engines=[V8_ENGINE], # XXX Moz bug 675269 args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t; print (lambda x: x*2)(11); print '%f' % 5.47''']) # Test cases in separate files. Note that these files may contain invalid .ll! diff --git a/tools/shared.py b/tools/shared.py index dcf6eb31..811f56f5 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -43,9 +43,9 @@ def timeout_run(proc, timeout, note): raise Exception("Timed out: " + note) return proc.communicate()[0] -def run_js(engine, filename, args, check_timeout=False, stdout=PIPE, stderr=STDOUT): +def run_js(engine, filename, args, check_timeout=False, stdout=PIPE, stderr=STDOUT, cwd=None): return timeout_run(Popen(engine + [filename] + (['--'] if 'v8' in engine[0] else []) + args, - stdout=stdout, stderr=stderr), 15*60 if check_timeout else None, 'Execution') + stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution') def to_cc(cxx): # By default, LLVM_GCC and CLANG are really the C++ versions. This gets an explicit C version |