aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py50
1 files changed, 41 insertions, 9 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 700849e8..bdfec8ed 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -20,7 +20,26 @@ if '\n' in EM_CONFIG:
else:
CONFIG_FILE = os.path.expanduser(EM_CONFIG)
if not os.path.exists(CONFIG_FILE):
- shutil.copy(path_from_root('tools', 'settings_template_readonly.py'), 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..."
+ 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!
@@ -29,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
@@ -47,12 +71,19 @@ except Exception, e:
EXPECTED_LLVM_VERSION = (3,1)
+def check_clang_version():
+ expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))
+ actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0]
+ if expected in actual:
+ return True
+
+ print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected)
+ return False
+
+
def check_llvm_version():
try:
- expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))
- actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0][0:len(expected)]
- if expected != actual:
- print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected)
+ check_clang_version();
except Exception, e:
print >> sys.stderr, 'warning: Could not verify LLVM version: %s' % str(e)
@@ -240,7 +271,8 @@ if USE_EMSDK:
'-Xclang', '-isystem' + path_from_root('system', 'include', 'net'),
'-Xclang', '-isystem' + path_from_root('system', 'include', 'SDL'),
] + [
- '-U__APPLE__', '-U__linux__'
+ '-U__APPLE__', '-U__linux__',
+ '-D_LIBCPP_HAS_NO_DELETED_FUNCTIONS' # otherwise libc++ has errors with --std=c++11
]
COMPILER_OPTS += EMSDK_OPTS
else: