From ea5d631a5446632e195765d89a53ead71cd6de45 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 18 Jan 2019 16:29:08 -0800 Subject: [PATCH] Deduplicate activated configs in the .emscripten file (#198) While doing so, we: * keep the latest activation (e.g., the user may have activated latest and then latest-upstream, then the upstream LLVM is what is desired). * keep the order of keys fixed (so the relative order of lines in the .emscripten file is fixed) This adds some assertions in the Dockerfile, to verify we have one LLVM_ROOT command, and it is the right one. Fixes #194 --- Dockerfile | 3 ++- emsdk | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e3b4c2e..b989670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ RUN cd /root/ \ && /root/emsdk/emsdk activate latest-upstream \ && source /root/emsdk/emsdk_env.sh --build=Release \ && emcc hello_world.cpp -s WASM_OBJECT_FILES=1 \ + && python -c "import os ; assert open(os.path.expanduser('~/.emscripten')).read().count('LLVM_ROOT') == 1" \ + && python -c "import os ; assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()" \ && echo "test fastcomp (waterfall)" \ && /root/emsdk/emsdk install latest-fastcomp \ && /root/emsdk/emsdk activate latest-fastcomp \ @@ -28,4 +30,3 @@ RUN cd /root/ \ && emcc hello_world.cpp -s WASM=0 \ && echo "test binaryen source build" \ && /root/emsdk/emsdk install --build=Release binaryen-master-64bit - diff --git a/emsdk b/emsdk index e9cbd9d..2544cc5 100755 --- a/emsdk +++ b/emsdk @@ -1051,13 +1051,26 @@ def generate_dot_emscripten(active_tools): if embedded: cfg += "emsdk_path=os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n" + # Different tools may provide the same activated configs; the latest to be + # activated is the relevant one. + activated_keys_in_order = [] + activated_key_values = {} + for tool in active_tools: tool_cfg = tool.activated_config() if tool_cfg: - tool_cfg = tool_cfg.replace(';', '\n') - if 'SPIDERMONKEY_ENGINE=' in tool_cfg: has_spidermonkey = True - if 'NODE_JS=' in tool_cfg: has_node = True - cfg += tool_cfg + '\n' + for specific_cfg in tool_cfg.split(';'): + name, value = specific_cfg.split('=') + if name not in activated_key_values: + activated_keys_in_order.append(name) + activated_key_values[name] = value + + for name in activated_keys_in_order: + if name == 'SPIDERMONKEY_ENGINE': + has_spidermonkey = True + if name == 'NODE_JS': + has_node = True + cfg += name + ' = ' + activated_key_values[name] + '\n' # These two vars must always be defined, even though they might not exist. if not has_spidermonkey: cfg += "SPIDERMONKEY_ENGINE = ''\n"