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 /tools | |
parent | f6c2ee75635583e2652df34045464ce908645044 (diff) | |
parent | 195c3e39cc0fba69d551836e7806d1cb55b742f0 (diff) |
Merge branch 'master' into llvmopts
Diffstat (limited to 'tools')
-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 |
6 files changed, 36 insertions, 27 deletions
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): |