diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-28 15:29:43 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-28 15:48:55 -0500 |
commit | 35a874392b9c117cf462260aab5dee3f56100e5c (patch) | |
tree | 0542de31e714a405c92757caa11a8fbcf78cd0cf | |
parent | dc84a84b531b3d2b79709dbe89ee3e1d34b19d6d (diff) |
Enable the EM_CONFIG environment variable to override ~/.emscripten
This commit fixes issue #180.
-rwxr-xr-x | tests/runner.py | 18 | ||||
-rwxr-xr-x | tools/emmaken.py | 2 | ||||
-rw-r--r-- | tools/shared.py | 31 |
3 files changed, 27 insertions, 24 deletions
diff --git a/tests/runner.py b/tests/runner.py index 4e260bf5..3611f74c 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -30,7 +30,7 @@ sys.path += [path_from_root('')] 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 @@ -280,7 +280,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) @@ -5890,10 +5890,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(): @@ -5938,7 +5938,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) @@ -5949,14 +5949,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) @@ -5964,7 +5964,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 @@ -6000,7 +6000,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/tools/emmaken.py b/tools/emmaken.py index 0759c2d3..447a7d6d 100755 --- a/tools/emmaken.py +++ b/tools/emmaken.py @@ -223,6 +223,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/shared.py b/tools/shared.py index f20fc75c..3e989844 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): |