diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-31 18:11:28 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-31 18:11:28 -0800 |
commit | 88c3f163048d7f9107f314c98fc94abc9271d641 (patch) | |
tree | d94283c0e1b1de0f3c2aefa9db44040ec7885183 | |
parent | f6c2ee75635583e2652df34045464ce908645044 (diff) | |
parent | 195c3e39cc0fba69d551836e7806d1cb55b742f0 (diff) |
Merge branch 'master' into llvmopts
-rwxr-xr-x | emcc | 5 | ||||
-rw-r--r-- | src/library_sdl.js | 2 | ||||
-rw-r--r-- | src/parseTools.js | 7 | ||||
-rw-r--r-- | system/include/libc/sys/types.h | 2 | ||||
-rwxr-xr-x | tests/runner.py | 64 | ||||
-rw-r--r-- | tests/systypes/output.txt | 1 | ||||
-rw-r--r-- | tests/systypes/src.c | 20 | ||||
-rw-r--r-- | third_party/demangler.py | 5 | ||||
-rwxr-xr-x | tools/bindings_generator.py | 5 | ||||
-rwxr-xr-x | tools/emconfiguren.py | 5 | ||||
-rwxr-xr-x | tools/emmaken.py | 12 | ||||
-rwxr-xr-x | tools/emmakenxx.py | 5 | ||||
-rwxr-xr-x | tools/exec_llvm.py | 5 | ||||
-rw-r--r-- | tools/shared.py | 31 |
14 files changed, 121 insertions, 48 deletions
@@ -41,10 +41,11 @@ Example uses: * For SCons the shared.py can be imported like so: __file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy')) - __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + __rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) - exec(open(path_from_root('tools', 'shared.py'), 'r').read()) + sys.path += [path_from_root('')] + from tools.shared import * For using the Emscripten compilers/linkers/etc. you can do: env = Environment() diff --git a/src/library_sdl.js b/src/library_sdl.js index d438fc23..35c619b8 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -561,6 +561,8 @@ mergeInto(LibraryManager.library, { Mix_OpenAudio: function() { return -1 }, + SDL_InitSubSystem: function(flags) { return 0 }, + SDL_AddTimer: function(interval, callback, param) { return window.setTimeout(function() { FUNCTION_TABLE[callback](interval, param); diff --git a/src/parseTools.js b/src/parseTools.js index 38467270..a53ff1c0 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -390,7 +390,12 @@ function finalizeParam(param) { if (param.type == 'i64' && I64_MODE == 1) { return parseI64Constant(param.ident); } - return toNiceIdent(param.ident); + var ret = toNiceIdent(param.ident); + if (ret in Variables.globals && Variables.globals[ret].isString) { + ret = "STRING_TABLE." + ret; + } + + return ret; } } diff --git a/system/include/libc/sys/types.h b/system/include/libc/sys/types.h index 734004e7..ab6e895b 100644 --- a/system/include/libc/sys/types.h +++ b/system/include/libc/sys/types.h @@ -134,7 +134,7 @@ typedef unsigned long ino_t; /* XXX Emscripten */ #endif #endif /*__CYGWIN__*/ -#ifdef __MS_types__ +#if defined(__MS_types__) || defined(EMSCRIPTEN) typedef unsigned long vm_offset_t; typedef unsigned long vm_size_t; diff --git a/tests/runner.py b/tests/runner.py index d547cf92..02041ed4 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -14,23 +14,23 @@ will use 4 processes. To install nose do something like ''' from subprocess import Popen, PIPE, STDOUT -import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, tempfile, re, difflib, webbrowser, hashlib, BaseHTTPServer, threading +import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, tempfile, re, difflib, webbrowser, hashlib, BaseHTTPServer, threading, platform # Setup -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) - sys.path += [path_from_root('')] +import tools.shared +from tools.shared import * # Sanity check for config try: assert COMPILER_OPTS != None except: - raise Exception('Cannot find "COMPILER_OPTS" definition. Is ~/.emscripten set up properly? You may need to copy the template from settings.py into it.') + raise Exception('Cannot find "COMPILER_OPTS" definition. Is %s set up properly? You may need to copy the template from settings.py into it.' % EM_CONFIG) # Core test runner class, shared between normal tests and benchmarks @@ -41,7 +41,9 @@ class RunnerCore(unittest.TestCase): # Change this to None to get stderr reporting, for debugging purposes def setUp(self): + global Settings Settings.reset() + Settings = tools.shared.Settings self.banned_js_engines = [] if not self.save_dir: dirname = tempfile.mkdtemp(prefix='emscripten_test_' + self.__class__.__name__ + '_', dir=TEMP_DIR) @@ -68,6 +70,15 @@ class RunnerCore(unittest.TestCase): def get_dir(self): return self.working_dir + def get_shared_library_name(self, linux_name): + if platform.system() == 'Linux': + return linux_name + elif platform.system() == 'Darwin': + return linux_name.replace('.so', '') + '.dylib' + else: + print >> sys.stderr, 'get_shared_library_name needs to be implemented on %s' % platform.system() + return linux_name + def get_stdout_path(self): return os.path.join(self.get_dir(), 'stdout') @@ -280,7 +291,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): if Settings.USE_TYPED_ARRAYS: js_engines = filter(lambda engine: engine != V8_ENGINE, js_engines) # V8 issue 1822 js_engines = filter(lambda engine: engine not in self.banned_js_engines, js_engines) - if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check ~/.emscripten and settings.py and the paths therein.') + if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check %s and settings.py and the paths therein.' % EM_CONFIG) for engine in js_engines: engine = filter(lambda arg: arg != '-n', engine) # SpiderMonkey issue 716255 js_output = self.run_generated_code(engine, filename + '.o.js', args) @@ -3652,6 +3663,24 @@ def process(filename): ''' self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run_and_checks) + def test_direct_string_constant_usage(self): + if self.emcc_args is None: return self.skip('requires libcxx') + + src = ''' + #include <iostream> + template<int i> + void printText( const char (&text)[ i ] ) + { + std::cout << text; + } + int main() + { + printText( "some string constant" ); + return 0; + } + ''' + self.do_run(src, "some string constant") + def test_fs_base(self): Settings.INCLUDE_FULL_LIBRARY = 1 try: @@ -3858,6 +3887,11 @@ def process(filename): expected = open(path_from_root('tests', 'env', 'output.txt'), 'r').read() self.do_run(src, expected) + def test_systypes(self): + src = open(path_from_root('tests', 'systypes', 'src.c'), 'r').read() + expected = open(path_from_root('tests', 'systypes', 'output.txt'), 'r').read() + self.do_run(src, expected) + def test_getloadavg(self): src = r''' #include <stdio.h> @@ -4319,7 +4353,7 @@ def process(filename): freetype = self.get_freetype() poppler = self.get_library('poppler', - [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0'), + [os.path.join('poppler', '.libs', self.get_shared_library_name('libpoppler.so.13')), os.path.join('goo', '.libs', 'libgoo.a'), os.path.join('fofi', '.libs', 'libfofi.a'), os.path.join('splash', '.libs', 'libsplash.a'), @@ -4364,7 +4398,7 @@ def process(filename): shutil.copy(path_from_root('tests', 'openjpeg', 'opj_config.h'), self.get_dir()) lib = self.get_library('openjpeg', - [os.path.join('bin', 'libopenjpeg.so.1.4.0'), + [os.path.join('bin', self.get_shared_library_name('libopenjpeg.so.1.4.0')), os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/index.c.o'.split('/')), os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/convert.c.o'.split('/')), os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'.split('/')), @@ -5927,10 +5961,10 @@ elif 'sanity' in str(sys.argv): print print 'Running sanity checks.' - print 'WARNING: This will modify ~/.emscripten, and in theory can break it although it should be restored properly. A backup will be saved in ~/.emscripten_backup' + print 'WARNING: This will modify %s, and in theory can break it although it should be restored properly. A backup will be saved in %s_backup' % (EM_CONFIG, EM_CONFIG) print - assert os.path.exists(CONFIG_FILE), 'To run these tests, we need a (working!) ~/.emscripten file to already exist' + assert os.path.exists(CONFIG_FILE), 'To run these tests, we need a (working!) %s file to already exist' % EM_CONFIG shutil.copyfile(CONFIG_FILE, CONFIG_FILE + '_backup') def restore(): @@ -5975,7 +6009,7 @@ elif 'sanity' in str(sys.argv): def test_aaa_normal(self): # this should be the very first thing that runs. if this fails, everything else is irrelevant! for command in commands: - # Your existing ~/.emscripten should work! + # Your existing EM_CONFIG should work! restore() self.check_working(command) @@ -5986,14 +6020,14 @@ elif 'sanity' in str(sys.argv): self.assertContained('Welcome to Emscripten!', output) self.assertContained('This is the first time any of the Emscripten tools has been run.', output) - self.assertContained('A settings file has been copied to ~/.emscripten, at absolute path: %s' % CONFIG_FILE, output) + self.assertContained('A settings file has been copied to %s, at absolute path: %s' % (EM_CONFIG, CONFIG_FILE), output) self.assertContained('Please edit that file and change the paths to fit your system', output) self.assertContained('make sure LLVM_ROOT and NODE_JS are correct', output) self.assertContained('This command will now exit. When you are done editing those paths, re-run it.', output) assert output.replace('\n', '').endswith('===='), 'We should have stopped: ' + output assert (open(CONFIG_FILE).read() == open(path_from_root('settings.py')).read()), 'Settings should be copied from settings.py' - # Second run, with bad ~/.emscripten + # Second run, with bad EM_CONFIG for settings in ['blah', 'LLVM_ROOT="blah"; JS_ENGINES=[]; COMPILER_ENGINE=NODE_JS=SPIDERMONKEY_ENGINE=[]']: f = open(CONFIG_FILE, 'w') f.write(settings) @@ -6001,7 +6035,7 @@ elif 'sanity' in str(sys.argv): output = self.do(command) if 'LLVM_ROOT' not in settings: - self.assertContained('Error in evaluating ~/.emscripten', output) + self.assertContained('Error in evaluating %s' % EM_CONFIG, output) else: self.assertContained('FATAL', output) # sanity check should fail @@ -6037,7 +6071,7 @@ elif 'sanity' in str(sys.argv): SANITY_MESSAGE = 'Emscripten: Running sanity checks' SANITY_FAIL_MESSAGE = 'sanity check failed to run' - # emcc should check sanity if no ~/.emscripten_sanity + # emcc should check sanity if no ${EM_CONFIG}_sanity restore() time.sleep(0.1) assert not os.path.exists(SANITY_FILE) # restore is just the settings, not the sanity diff --git a/tests/systypes/output.txt b/tests/systypes/output.txt new file mode 100644 index 00000000..2e9ba477 --- /dev/null +++ b/tests/systypes/output.txt @@ -0,0 +1 @@ +success diff --git a/tests/systypes/src.c b/tests/systypes/src.c new file mode 100644 index 00000000..a01ed578 --- /dev/null +++ b/tests/systypes/src.c @@ -0,0 +1,20 @@ +#include <sys/types.h> + +// Declare puts manually, we don't want to include any other headers here +#ifdef __cplusplus +extern "C" +#endif +int puts(const char*); + +int main() { + int8_t i8 = 0; + u_int8_t ui8 = 0; + int16_t i16 = 0; + u_int16_t ui16 = 0; + int32_t i32 = 0; + u_int32_t ui32 = 0; + int64_t i64 = 0; + u_int64_t ui64 = 0; + puts("success"); + return 0; +} diff --git a/third_party/demangler.py b/third_party/demangler.py index d875d9a5..1066643b 100644 --- a/third_party/demangler.py +++ b/third_party/demangler.py @@ -21,10 +21,11 @@ JS_ENGINE_PARAMS=[] import os, sys, subprocess, re -__rootpath__ = os.path.abspath(os.path.dirname(__file__)) +__rootpath__ = os.path.dirname(os.path.abspath(__file__)) def path_from_root(*pathelems): return os.path.join(os.path.sep, *(__rootpath__.split(os.sep)[:-1] + list(pathelems))) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * data = open(sys.argv[1], 'r').readlines() diff --git a/tools/bindings_generator.py b/tools/bindings_generator.py index 0dbcca8e..8146215c 100755 --- a/tools/bindings_generator.py +++ b/tools/bindings_generator.py @@ -50,10 +50,11 @@ NOTE: ammo.js is currently the biggest consumer of this code. For some import os, sys, glob, re -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * # Find ply and CppHeaderParser sys.path = [path_from_root('third_party', 'ply'), path_from_root('third_party', 'CppHeaderParser')] + sys.path diff --git a/tools/emconfiguren.py b/tools/emconfiguren.py index 2ea5669f..fd7b7549 100755 --- a/tools/emconfiguren.py +++ b/tools/emconfiguren.py @@ -9,10 +9,11 @@ This is a helper script for emmaken.py. See docs in that file for more info. import os, sys -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * Building.configure(sys.argv[1:]) diff --git a/tools/emmaken.py b/tools/emmaken.py index 0759c2d3..8e1bfdc8 100755 --- a/tools/emmaken.py +++ b/tools/emmaken.py @@ -56,10 +56,11 @@ Example uses: * For SCons the shared.py can be imported like so: __file__ = str(Dir('#/project_path_to_emscripten/dummy/dummy')) - __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + __rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) - exec(open(path_from_root('tools', 'shared.py'), 'r').read()) + sys.path += [path_from_root('')] + from tools.shared import * For using the Emscripten compilers/linkers/etc. you can do: env = Environment() @@ -99,10 +100,11 @@ import subprocess print >> sys.stderr, 'emmaken.py: ', ' '.join(sys.argv) -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * # If this is a configure-type thing, just do that CONFIGURE_CONFIG = os.environ.get('EMMAKEN_JUST_CONFIGURE') @@ -223,6 +225,6 @@ try: os.execvp(call, [call] + newargs) except Exception, e: - print 'Error in emmaken.py. (Is the config file ~/.emscripten set up properly?) Error:', e + print 'Error in emmaken.py. (Is the config file %s set up properly?) Error:' % EM_CONFIG, e raise diff --git a/tools/emmakenxx.py b/tools/emmakenxx.py index 31658df2..c9ab4ef4 100755 --- a/tools/emmakenxx.py +++ b/tools/emmakenxx.py @@ -6,10 +6,11 @@ see emmaken.py import os, sys -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * emmaken = path_from_root('tools', 'emmaken.py') os.environ['EMMAKEN_CXX'] = '1' diff --git a/tools/exec_llvm.py b/tools/exec_llvm.py index 5cf55e46..71c0f18d 100755 --- a/tools/exec_llvm.py +++ b/tools/exec_llvm.py @@ -33,10 +33,11 @@ useful when this fails. import os, sys from subprocess import Popen, PIPE, STDOUT -__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) -exec(open(path_from_root('tools', 'shared.py'), 'r').read()) +sys.path += [path_from_root('')] +from tools.shared import * Popen([LLVM_OPT, sys.argv[1], '-strip-debug', '-o=' + sys.argv[1]+'.clean.bc']).communicate()[0] diff --git a/tools/shared.py b/tools/shared.py index e673cfd3..1f184de7 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -7,7 +7,10 @@ def path_from_root(*pathelems): # Config file -CONFIG_FILE = os.path.expanduser('~/.emscripten') +EM_CONFIG = os.environ.get('EM_CONFIG') +if not EM_CONFIG: + EM_CONFIG = '~/.emscripten' +CONFIG_FILE = os.path.expanduser(EM_CONFIG) if not os.path.exists(CONFIG_FILE): shutil.copy(path_from_root('settings.py'), CONFIG_FILE) print >> sys.stderr, ''' @@ -16,25 +19,25 @@ Welcome to Emscripten! This is the first time any of the Emscripten tools has been run. -A settings file has been copied to ~/.emscripten, at absolute path: %s +A settings file has been copied to %s, at absolute path: %s Please edit that file and change the paths to fit your system. Specifically, make sure LLVM_ROOT and NODE_JS are correct. This command will now exit. When you are done editing those paths, re-run it. ============================================================================== -''' % CONFIG_FILE +''' % (EM_CONFIG, CONFIG_FILE) sys.exit(0) try: exec(open(CONFIG_FILE, 'r').read()) except Exception, e: - print >> sys.stderr, 'Error in evaluating ~/.emscripten (at %s): %s' % (CONFIG_FILE, str(e)) + print >> sys.stderr, 'Error in evaluating %s (at %s): %s' % (EM_CONFIG, CONFIG_FILE, str(e)) sys.exit(1) # Check that basic stuff we need (a JS engine to compile, Node.js, and Clang and LLVM) # exists. # The test runner always does this check (through |force|). emcc does this less frequently, -# only when ~/.emscripten_sanity does not exist or is older than ~/.emscripten (so, +# only when ${EM_CONFIG}_sanity does not exist or is older than EM_CONFIG (so, # we re-check sanity when the settings are changed) def check_sanity(force=False): try: @@ -51,21 +54,21 @@ def check_sanity(force=False): print >> sys.stderr, '(Emscripten: Running sanity checks)' if not check_engine(COMPILER_ENGINE): - print >> sys.stderr, 'FATAL: The JavaScript shell used for compiling (%s) does not seem to work, check the paths in ~/.emscripten' % COMPILER_ENGINE + print >> sys.stderr, 'FATAL: The JavaScript shell used for compiling (%s) does not seem to work, check the paths in %s' % (COMPILER_ENGINE, EM_CONFIG) sys.exit(0) if NODE_JS != COMPILER_ENGINE: if not check_engine(NODE_JS): - print >> sys.stderr, 'FATAL: Node.js (%s) does not seem to work, check the paths in ~/.emscripten' % NODE_JS + print >> sys.stderr, 'FATAL: Node.js (%s) does not seem to work, check the paths in %s' % (NODE_JS, EM_CONFIG) sys.exit(0) for cmd in [CLANG, LLVM_DIS]: if not os.path.exists(cmd) and not os.path.exists(cmd + '.exe'): # .exe extension required for Windows - print >> sys.stderr, 'FATAL: Cannot find %s, check the paths in ~/.emscripten' % cmd + print >> sys.stderr, 'FATAL: Cannot find %s, check the paths in %s' % (cmd, EM_CONFIG) sys.exit(0) if not os.path.exists(CLOSURE_COMPILER): - print >> sys.stderr, 'WARNING: Closure compiler (%s) does not exist, check the paths in ~/.emscripten. -O2 and above will fail' % CLOSURE_COMPILER + print >> sys.stderr, 'WARNING: Closure compiler (%s) does not exist, check the paths in %s. -O2 and above will fail' % (CLOSURE_COMPILER, EM_CONFIG) # Sanity check passed! @@ -121,9 +124,9 @@ try: print >> sys.stderr, 'Warning: Could not create temp dir (%s): %s' % (EMSCRIPTEN_TEMP_DIR, str(e)) except: EMSCRIPTEN_TEMP_DIR = tempfile.mkdtemp(prefix='emscripten_temp_') - print >> sys.stderr, 'Warning: TEMP_DIR not defined in ~/.emscripten, using %s' % EMSCRIPTEN_TEMP_DIR + print >> sys.stderr, 'Warning: TEMP_DIR not defined in %s, using %s' % (EM_CONFIG, EMSCRIPTEN_TEMP_DIR) -# ~/.emscripten stuff +# EM_CONFIG stuff try: JS_ENGINES @@ -131,13 +134,13 @@ except: try: JS_ENGINES = [JS_ENGINE] except Exception, e: - print 'ERROR: ~/.emscripten does not seem to have JS_ENGINES or JS_ENGINE set up' + print 'ERROR: %s does not seem to have JS_ENGINES or JS_ENGINE set up' % EM_CONFIG raise # Additional compiler options try: - COMPILER_OPTS # Can be set in ~/.emscripten, optionally + COMPILER_OPTS # Can be set in EM_CONFIG, optionally except: COMPILER_OPTS = [] # Force a simple, standard target as much as possible: target 32-bit linux, and disable various flags that hint at other platforms @@ -213,7 +216,7 @@ def check_engine(engine): try: return 'hello, world!' in run_js(path_from_root('tests', 'hello_world.js'), engine) except Exception, e: - print 'Checking JS engine %s failed. Check ~/.emscripten. Details: %s' % (str(engine), str(e)) + print 'Checking JS engine %s failed. Check %s. Details: %s' % (str(engine), EM_CONFIG, str(e)) return False def timeout_run(proc, timeout, note): |