Skip to content

Commit ea5d631

Browse files
authored
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
1 parent 5a8f597 commit ea5d631

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ RUN cd /root/ \
2020
&& /root/emsdk/emsdk activate latest-upstream \
2121
&& source /root/emsdk/emsdk_env.sh --build=Release \
2222
&& emcc hello_world.cpp -s WASM_OBJECT_FILES=1 \
23+
&& python -c "import os ; assert open(os.path.expanduser('~/.emscripten')).read().count('LLVM_ROOT') == 1" \
24+
&& python -c "import os ; assert 'upstream' in open(os.path.expanduser('~/.emscripten')).read()" \
2325
&& echo "test fastcomp (waterfall)" \
2426
&& /root/emsdk/emsdk install latest-fastcomp \
2527
&& /root/emsdk/emsdk activate latest-fastcomp \
@@ -28,4 +30,3 @@ RUN cd /root/ \
2830
&& emcc hello_world.cpp -s WASM=0 \
2931
&& echo "test binaryen source build" \
3032
&& /root/emsdk/emsdk install --build=Release binaryen-master-64bit
31-

emsdk

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,13 +1051,26 @@ def generate_dot_emscripten(active_tools):
10511051
if embedded:
10521052
cfg += "emsdk_path=os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n"
10531053

1054+
# Different tools may provide the same activated configs; the latest to be
1055+
# activated is the relevant one.
1056+
activated_keys_in_order = []
1057+
activated_key_values = {}
1058+
10541059
for tool in active_tools:
10551060
tool_cfg = tool.activated_config()
10561061
if tool_cfg:
1057-
tool_cfg = tool_cfg.replace(';', '\n')
1058-
if 'SPIDERMONKEY_ENGINE=' in tool_cfg: has_spidermonkey = True
1059-
if 'NODE_JS=' in tool_cfg: has_node = True
1060-
cfg += tool_cfg + '\n'
1062+
for specific_cfg in tool_cfg.split(';'):
1063+
name, value = specific_cfg.split('=')
1064+
if name not in activated_key_values:
1065+
activated_keys_in_order.append(name)
1066+
activated_key_values[name] = value
1067+
1068+
for name in activated_keys_in_order:
1069+
if name == 'SPIDERMONKEY_ENGINE':
1070+
has_spidermonkey = True
1071+
if name == 'NODE_JS':
1072+
has_node = True
1073+
cfg += name + ' = ' + activated_key_values[name] + '\n'
10611074

10621075
# These two vars must always be defined, even though they might not exist.
10631076
if not has_spidermonkey: cfg += "SPIDERMONKEY_ENGINE = ''\n"

0 commit comments

Comments
 (0)