From 0c19674621100564acbe97fc7b818d5eb2f70a25 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 9 Jul 2019 18:57:26 +0200 Subject: [PATCH] Better detect Emscripten toolchain. Emscripten is apparently changing the variables in its config file, causing potential breakage of our build system. Binaries of the latest/latest-upstream releases are located in a subfolder of BINARYEN_ROOT called emscripten. Binaries of the other releases (e.g. sdk-1.38.31-64bit) are instead placed under the EMSCRIPTEN_ROOT folder. This PR checks if BINARYEN_ROOT has a subfolder called emscripten, if that does not exists, it falls back to checking the EMSCRIPTEN_ROOT. This way we give precedence to the new releases, given that activating multiple releases sequentially might result in having mismatching BINARYEN_ROOT and EMSCRIPTEN_ROOT. --- platform/javascript/detect.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index c6afa02c6dc..10680ad1f52 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -69,9 +69,14 @@ def configure(env): exec(f.read(), em_config) except StandardError as e: raise RuntimeError("Emscripten configuration file '%s' is invalid:\n%s" % (em_config_file, e)) - if 'BINARYEN_ROOT' not in em_config and 'EMSCRIPTEN_ROOT' not in em_config: + if 'BINARYEN_ROOT' in em_config and os.path.isdir(os.path.join(em_config.get('BINARYEN_ROOT'), 'emscripten')): + # New style, emscripten path as a subfolder of BINARYEN_ROOT + env.PrependENVPath('PATH', os.path.join(em_config.get('BINARYEN_ROOT'), 'emscripten')) + elif 'EMSCRIPTEN_ROOT' in em_config: + # Old style (but can be there as a result from previous activation, so do last) + env.PrependENVPath('PATH', em_config.get('EMSCRIPTEN_ROOT')) + else: raise RuntimeError("'BINARYEN_ROOT' or 'EMSCRIPTEN_ROOT' missing in Emscripten configuration file '%s'" % em_config_file) - env.PrependENVPath('PATH', em_config.get('BINARYEN_ROOT', em_config.get('EMSCRIPTEN_ROOT'))) env['CC'] = 'emcc' env['CXX'] = 'em++'