aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py16
-rw-r--r--tools/settings_template_readonly.py8
-rw-r--r--tools/shared.py30
3 files changed, 43 insertions, 11 deletions
diff --git a/tests/runner.py b/tests/runner.py
index c0283c05..475acbe3 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -8828,17 +8828,27 @@ 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 %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('It contains our best guesses for the important paths, which are:', output)
+ self.assertContained('LLVM_ROOT', output)
+ self.assertContained('NODE_JS', output)
+ self.assertContained('Please edit the file if any of those are incorrect', output)
self.assertContained('This command will now exit. When you are done editing those paths, re-run it.', output)
assert output.split()[-1].endswith('===='), 'We should have stopped: ' + output
config_file = open(CONFIG_FILE).read()
template_file = open(path_from_root('tools', 'settings_template_readonly.py')).read()
self.assertNotContained('~/.emscripten', config_file)
self.assertContained('~/.emscripten', template_file)
+ self.assertNotContained('{{{', config_file)
+ self.assertNotContained('}}}', config_file)
+ self.assertContained('{{{', template_file)
+ self.assertContained('}}}', template_file)
for content in ['EMSCRIPTEN_ROOT', 'LLVM_ROOT', 'NODE_JS', 'TEMP_DIR', 'COMPILER_ENGINE', 'JS_ENGINES']:
self.assertContained(content, config_file)
- self.assertContained(config_file, template_file)
+
+ # The guessed config should be ok XXX This depends on your local system! it is possible `which` guesses wrong
+ try_delete('a.out.js')
+ output = Popen(['python', EMCC, path_from_root('tests', 'hello_world.c')], stdout=PIPE, stderr=PIPE).communicate()
+ self.assertContained('hello, world!', run_js('a.out.js'), output)
# Second run, with bad EM_CONFIG
for settings in ['blah', 'LLVM_ROOT="blarg"; JS_ENGINES=[]; COMPILER_ENGINE=NODE_JS=SPIDERMONKEY_ENGINE=[]']:
diff --git a/tools/settings_template_readonly.py b/tools/settings_template_readonly.py
index 8d03237e..9102fe40 100644
--- a/tools/settings_template_readonly.py
+++ b/tools/settings_template_readonly.py
@@ -1,15 +1,15 @@
-# This file will be copied to ~/.emscripten if that file doesn't exist.
+# This file will be edited (the {{{ }}} things), and then ~/.emscripten created with the result, if ~/.emscripten doesn't exist.
# Note: If you put paths relative to the home directory, do not forget os.path.expanduser
import os
# this helps projects using emscripten find it
-EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN') or '/opt/emscripten')
-LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '/usr/bin')
+EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN') or '{{{ EMSCRIPTEN_ROOT }}}')
+LLVM_ROOT = os.path.expanduser(os.getenv('LLVM') or '{{{ LLVM_ROOT }}}')
# See below for notes on which JS engine(s) you need
-NODE_JS = 'node'
+NODE_JS = '{{{ NODE }}}'
SPIDERMONKEY_ENGINE = [
os.path.expanduser(os.getenv('SPIDERMONKEY') or 'js'), '-m', '-n']
V8_ENGINE = os.path.expanduser(os.getenv('V8') or 'd8')
diff --git a/tools/shared.py b/tools/shared.py
index e46b10b9..89ab76a1 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -22,7 +22,24 @@ else:
if not os.path.exists(CONFIG_FILE):
config_file = open(path_from_root('tools', 'settings_template_readonly.py')).read().split('\n')
config_file = config_file[1:] # remove "this file will be copied..."
- open(CONFIG_FILE, 'w').write('\n'.join(config_file))
+ config_file = '\n'.join(config_file)
+ # autodetect some default paths
+ config_file = config_file.replace('{{{ EMSCRIPTEN_ROOT }}}', __rootpath__)
+ llvm_root = '/usr/bin'
+ try:
+ llvm_root = os.path.dirname(Popen(['which', 'clang'], stdout=PIPE).communicate()[0].replace('\n', ''))
+ except:
+ pass
+ config_file = config_file.replace('{{{ LLVM_ROOT }}}', llvm_root)
+ node = 'node'
+ try:
+ node = Popen(['which', 'node'], stdout=PIPE).communicate()[0].replace('\n', '')
+ except:
+ pass
+ config_file = config_file.replace('{{{ NODE }}}', node)
+
+ # write
+ open(CONFIG_FILE, 'w').write(config_file)
print >> sys.stderr, '''
==============================================================================
Welcome to Emscripten!
@@ -31,12 +48,17 @@ This is the first time any of the Emscripten tools has been run.
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.
+It contains our best guesses for the important paths, which are:
+
+ LLVM_ROOT = %s
+ NODE_JS = %s
+ EMSCRIPTEN_ROOT = %s
+
+Please edit the file if any of those are incorrect.
This command will now exit. When you are done editing those paths, re-run it.
==============================================================================
-''' % (EM_CONFIG, CONFIG_FILE)
+''' % (EM_CONFIG, CONFIG_FILE, llvm_root, node, __rootpath__)
sys.exit(0)
try:
config_text = open(CONFIG_FILE, 'r').read() if CONFIG_FILE else EM_CONFIG