aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 3456ab18..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:
@@ -926,7 +941,7 @@ class Building:
@staticmethod
- def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
+ def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args='help', cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
''' Build a library into a .bc file. We build the .bc file once and cache it for all our tests. (We cache in
memory since the test directory is destroyed and recreated for each test. Note that we cache separately
for different compilers).
@@ -934,6 +949,8 @@ class Building:
if type(generated_libs) is not list: generated_libs = [generated_libs]
if source_dir is None: source_dir = path_from_root('tests', name.replace('_native', ''))
+ if make_args == 'help':
+ make_args = ['-j', str(multiprocessing.cpu_count())]
temp_dir = build_dir
if copy_project: