aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-16 17:50:47 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-16 17:50:47 -0800
commit49e00037f0d7adefe33fd8f0b967b1920a89e5cc (patch)
treeedf8a9dc0ab30c0af45cdee5c3fcecaee9c99c1c /tools
parentb01d1845c4a4155db54da713691d86e2d2f42040 (diff)
parentc4ce1f71e699c32f3a50edd06c619a8dc4e768ac (diff)
Merge branch 'em_config' of github.com:juj/emscripten into incoming
Conflicts: emcc
Diffstat (limited to 'tools')
-rw-r--r--tools/shared.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/shared.py b/tools/shared.py
index cbeb3eda..443ff4c7 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -176,13 +176,28 @@ if WINDOWS:
else:
logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)
-# Emscripten configuration is done through the EM_CONFIG environment variable.
-# If the string value contained in this environment variable contains newline
-# separated definitions, then these definitions will be used to configure
+# Emscripten configuration is done through the --em-config command line option or
+# the EM_CONFIG environment variable. If the specified string value contains newline
+# or semicolon-separated definitions, then these definitions will be used to configure
# Emscripten. Otherwise, the string is understood to be a path to a settings
# file that contains the required definitions.
-EM_CONFIG = os.environ.get('EM_CONFIG')
+try:
+ EM_CONFIG = sys.argv[sys.argv.index('--em-config')+1]
+ # Emscripten compiler spawns other processes, which can reimport shared.py, so make sure that
+ # those child processes get the same configuration file by setting it to the currently active environment.
+ os.environ['EM_CONFIG'] = EM_CONFIG
+except:
+ EM_CONFIG = os.environ.get('EM_CONFIG')
+
+if EM_CONFIG and not os.path.isfile(EM_CONFIG):
+ if EM_CONFIG.startswith('-'):
+ raise Exception('Passed --em-config without an argument. Usage: --em-config /path/to/.emscripten or --em-config EMSCRIPTEN_ROOT=/path/;LLVM_ROOT=/path;...')
+ if not '=' in EM_CONFIG:
+ raise Exception('File ' + EM_CONFIG + ' passed to --em-config does not exist!')
+ else:
+ EM_CONFIG = EM_CONFIG.replace(';', '\n') + '\n'
+
if not EM_CONFIG:
EM_CONFIG = '~/.emscripten'
if '\n' in EM_CONFIG: