From 93f2e138610d735cbae7004d43f1370abeae101e Mon Sep 17 00:00:00 2001 From: Jukka Jylänki Date: Thu, 5 Dec 2013 16:27:02 +0200 Subject: Add new emcc command line parameter --em-config that allows specifying the location of the .emscripten configuration file from the command line. This overrides and has the same meaning as the environment variable EM_CONFIG. --- tools/shared.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/shared.py b/tools/shared.py index 3456ab18..e4fb7e08 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -176,13 +176,25 @@ 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] +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: -- cgit v1.2.3-18-g5258 From c4ce1f71e699c32f3a50edd06c619a8dc4e768ac Mon Sep 17 00:00:00 2001 From: Jukka Jylänki Date: Fri, 13 Dec 2013 14:39:43 +0200 Subject: Fix an issue with the --em-config cmdline option where the option was not seen by child processes spawned by emcc. To make sure all child processes see the same config file, the --em-config parameter is stored in the environment for current and child processes. --- tools/shared.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools') diff --git a/tools/shared.py b/tools/shared.py index e4fb7e08..ca31d39c 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -184,6 +184,9 @@ else: 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') -- cgit v1.2.3-18-g5258