diff options
-rw-r--r-- | src/library.js | 2 | ||||
-rw-r--r-- | src/library_gl.js | 4 | ||||
-rw-r--r-- | src/library_sdl.js | 6 | ||||
-rw-r--r-- | src/parseTools.js | 4 | ||||
-rw-r--r-- | tests/hello_world_gles_shell.html | 6 | ||||
-rwxr-xr-x | tests/runner.py | 30 | ||||
-rw-r--r-- | tools/shared.py | 2 |
7 files changed, 35 insertions, 19 deletions
diff --git a/src/library.js b/src/library.js index 4096ba75..6385507c 100644 --- a/src/library.js +++ b/src/library.js @@ -2177,7 +2177,7 @@ LibraryManager.library = { // ========================================================================== _isFloat: function(text) { - return !!(/^[+]?[0-9]*\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text)); + return !!(/^[+-]?[0-9]*\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text)); }, // TODO: Document. diff --git a/src/library_gl.js b/src/library_gl.js index 811601ec..84c49d83 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -531,6 +531,7 @@ var LibraryGLUT = { }, glutCreateWindow: function(name) { +#if USE_TYPED_ARRAYS try { var ctx = Module.canvas.getContext('experimental-webgl'); if (!ctx) throw 'Could not create canvas :('; @@ -541,6 +542,9 @@ var LibraryGLUT = { } catch (e) { Module.print('(canvas not available)'); } +#else + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); +#endif }, glutInitDisplayMode: function(mode) {}, diff --git a/src/library_sdl.js b/src/library_sdl.js index 35c619b8..7b413c13 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -173,6 +173,12 @@ mergeInto(LibraryManager.library, { }, createContext: function(useWebGL) { +#if !USE_TYPED_ARRAYS + if (useWebGL) { + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); + return null; + } +#endif try { var ctx = Module.canvas.getContext(useWebGL ? 'experimental-webgl' : '2d'); if (!ctx) throw 'Could not create canvas :('; diff --git a/src/parseTools.js b/src/parseTools.js index e58dad6a..67602687 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -397,7 +397,7 @@ function cleanSegment(segment) { return segment; } -var PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint', 'mul', 'icmp', 'zext', 'sub', 'add', 'div'); +var PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast', 'inttoptr', 'ptrtoint', 'mul', 'icmp', 'zext', 'sub', 'add', 'div', 'or'); // Parses a function call of form // TYPE functionname MODIFIERS (...) @@ -1300,7 +1300,7 @@ function finalizeLLVMFunctionCall(item, noIndexizeFunctions) { // from one file to another, would be enough to fix this), or, do not pass structs by value (which in general // is inefficient, and worth avoiding if you can). } - case 'icmp': case 'mul': case 'zext': case 'add': case 'sub': case 'div': case 'inttoptr': case 'ptrtoint': + case 'icmp': case 'mul': case 'zext': case 'add': case 'sub': case 'div': case 'inttoptr': case 'ptrtoint': case 'or': var temp = { op: item.intertype, variant: item.variant, diff --git a/tests/hello_world_gles_shell.html b/tests/hello_world_gles_shell.html index 7f0b2013..d3429e3a 100644 --- a/tests/hello_world_gles_shell.html +++ b/tests/hello_world_gles_shell.html @@ -25,9 +25,6 @@ canvas: document.getElementById('canvas') }; - // The compiled code - {{{ SCRIPT_CODE }}} - // Test code function simulateKeyEvent(keyCode) { var event = document.createEvent("KeyboardEvent"); @@ -50,6 +47,9 @@ }, 0); } addEventListener("load", doTest, false); + + // The compiled code + {{{ SCRIPT_CODE }}} </script> </body> </html> diff --git a/tests/runner.py b/tests/runner.py index a1fa8690..23937974 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3289,13 +3289,16 @@ at function.:blag printf("%f, %f\n", atof("1.234567"), atof("cheez")); + float a = -1; + sscanf("-3.03", "%f", &a); + printf("%.4f\n", a); + return 0; } ''' - self.do_run(src, 'en-us : 2*en-r : 99*en : 3*1.234567, 0.000000', - output_nicerizer = lambda x: x.replace('\n', '*')) + self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300') - # Part 2: doubles (issue 148) + # Part 2: doubles if Settings.USE_TYPED_ARRAYS == 2: for ftype in ['float', 'double']: src = r''' @@ -5645,16 +5648,8 @@ f.close() class TestServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(s): assert s.path == expectedResult, 'Expected %s, got %s' % (expectedResult, s.path) - httpd.shutdown() - def handle_timeout(): - assert False, 'Timed out while waiting for the browser test to finish' - httpd.shutdown() httpd = BaseHTTPServer.HTTPServer(('localhost', 8888), TestServerHandler) - httpd.timeout = 5; - server_thread = threading.Thread(target=httpd.serve_forever) - server_thread.daemon = True - server_thread.start() - server_thread.join(5.5) + httpd.handle_request() # Finally, do some web browser tests def run_browser(html_file, message, expectedResult = None): @@ -5707,6 +5702,17 @@ f.close() assert os.path.exists('something.html'), output run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true') + # Make sure that OpenGL ES is not available if typed arrays are not used + clear() + output = Popen([EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html', + '-DHAVE_BUILTIN_SINCOS', + '-s', 'USE_TYPED_ARRAYS=0', + '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')], + stdout=PIPE, stderr=PIPE).communicate() + assert len(output[0]) == 0, output[0] + assert os.path.exists('something.html'), output + run_browser('something.html', 'You should not see animating gears.', '/report_gl_result?false') + def test_eliminator(self): input = open(path_from_root('tools', 'eliminator', 'eliminator-test.js')).read() expected = open(path_from_root('tools', 'eliminator', 'eliminator-test-output.js')).read() diff --git a/tools/shared.py b/tools/shared.py index dc84bce3..45400581 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -395,7 +395,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)'''.replace('$EMSCRIPTEN_ROOT', path_ if env is None: env = Building.get_building_env() env['EMMAKEN_JUST_CONFIGURE'] = '1' - if args[0].find('cmake') > -1: + if 'cmake' in sys.argv[0]: args = Building.handle_CMake_toolchain(args) Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()[0] del env['EMMAKEN_JUST_CONFIGURE'] |