Skip to content

Commit 5726ccc

Browse files
authored
Remove JS_ENGINES and COMPILER_ENGINE from config file (#1354)
`COMPILER_ENGINE` was completely removed from emscripten in emscripten-core/emscripten#9469. `JS_ENGINES` is only used/needed for testing and is no longer needed as of emscripten-core/emscripten#9542.
1 parent 7815dca commit 5726ccc

File tree

1 file changed

+54
-33
lines changed

1 file changed

+54
-33
lines changed

emsdk.py

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,21 @@ def load_em_config():
14641464
pass
14651465

14661466

1467+
def find_emscripten_root(active_tools):
1468+
"""Find the currently active emscripten root.
1469+
1470+
If there is more than one tool that defines EMSCRIPTEN_ROOT (this
1471+
should not happen under normal circumstances), assume the last one takes
1472+
precedence.
1473+
"""
1474+
root = None
1475+
for tool in active_tools:
1476+
config = tool.activated_config()
1477+
if 'EMSCRIPTEN_ROOT' in config:
1478+
root = config['EMSCRIPTEN_ROOT']
1479+
return root
1480+
1481+
14671482
def generate_em_config(active_tools, permanently_activate, system):
14681483
cfg = 'import os\n'
14691484
cfg += "emsdk_path = os.path.dirname(os.getenv('EM_CONFIG')).replace('\\\\', '/')\n"
@@ -1484,10 +1499,17 @@ def generate_em_config(active_tools, permanently_activate, system):
14841499
for name, value in activated_config.items():
14851500
cfg += name + " = '" + value + "'\n"
14861501

1487-
cfg += '''\
1488-
COMPILER_ENGINE = NODE_JS
1489-
JS_ENGINES = [NODE_JS]
1490-
'''
1502+
emroot = find_emscripten_root(active_tools)
1503+
if emroot:
1504+
version = parse_emscripten_version(emroot)
1505+
# Older emscripten versions of emscripten depend on certain config
1506+
# keys that are no longer used.
1507+
# See https://github.com/emscripten-core/emscripten/pull/9469
1508+
if version < [1, 38, 46]:
1509+
cfg += 'COMPILER_ENGINE = NODE_JS\n'
1510+
# See https://github.com/emscripten-core/emscripten/pull/9542
1511+
if version < [1, 38, 48]:
1512+
cfg += 'JS_ENGINES = [NODE_JS]\n'
14911513

14921514
cfg = cfg.replace("'" + EMSDK_PATH, "emsdk_path + '")
14931515

@@ -2488,39 +2510,38 @@ def get_env_vars_to_add(tools_to_activate, system, user):
24882510
env_vars_to_add += [('EMSDK', EMSDK_PATH)]
24892511

24902512
for tool in tools_to_activate:
2491-
config = tool.activated_config()
2492-
if 'EMSCRIPTEN_ROOT' in config:
2493-
# For older emscripten versions that don't use an embedded cache by
2494-
# default we need to export EM_CACHE.
2495-
#
2496-
# Sadly, we can't put this in the config file since those older versions
2497-
# also didn't read the `CACHE` key from the config file:
2498-
#
2499-
# History:
2500-
# - 'CACHE' config started being honored in 1.39.16
2501-
# https://github.com/emscripten-core/emscripten/pull/11091
2502-
# - Default to embedded cache also started in 1.39.16
2503-
# https://github.com/emscripten-core/emscripten/pull/11126
2504-
# - Emscripten supports automatically locating the embedded
2505-
# config in 1.39.13:
2506-
# https://github.com/emscripten-core/emscripten/pull/10935
2507-
#
2508-
# Since setting EM_CACHE in the environment effects the entire machine
2509-
# we want to avoid this except when installing these older emscripten
2510-
# versions that really need it.
2511-
version = parse_emscripten_version(config['EMSCRIPTEN_ROOT'])
2512-
if version < [1, 39, 16]:
2513-
em_cache_dir = os.path.join(config['EMSCRIPTEN_ROOT'], 'cache')
2514-
env_vars_to_add += [('EM_CACHE', em_cache_dir)]
2515-
if version < [1, 39, 13]:
2516-
env_vars_to_add += [('EM_CONFIG', os.path.normpath(EM_CONFIG_PATH))]
2517-
2518-
envs = tool.activated_environment()
2519-
for env in envs:
2513+
for env in tool.activated_environment():
25202514
key, value = parse_key_value(env)
25212515
value = to_native_path(tool.expand_vars(value))
25222516
env_vars_to_add += [(key, value)]
25232517

2518+
emroot = find_emscripten_root(tools_to_activate)
2519+
if emroot:
2520+
# For older emscripten versions that don't use an embedded cache by
2521+
# default we need to export EM_CACHE.
2522+
#
2523+
# Sadly, we can't put this in the config file since those older versions
2524+
# also didn't read the `CACHE` key from the config file:
2525+
#
2526+
# History:
2527+
# - 'CACHE' config started being honored in 1.39.16
2528+
# https://github.com/emscripten-core/emscripten/pull/11091
2529+
# - Default to embedded cache also started in 1.39.16
2530+
# https://github.com/emscripten-core/emscripten/pull/11126
2531+
# - Emscripten supports automatically locating the embedded
2532+
# config in 1.39.13:
2533+
# https://github.com/emscripten-core/emscripten/pull/10935
2534+
#
2535+
# Since setting EM_CACHE in the environment effects the entire machine
2536+
# we want to avoid this except when installing these older emscripten
2537+
# versions that really need it.
2538+
version = parse_emscripten_version(emroot)
2539+
if version < [1, 39, 16]:
2540+
em_cache_dir = os.path.join(emroot, 'cache')
2541+
env_vars_to_add += [('EM_CACHE', em_cache_dir)]
2542+
if version < [1, 39, 13]:
2543+
env_vars_to_add += [('EM_CONFIG', os.path.normpath(EM_CONFIG_PATH))]
2544+
25242545
return env_vars_to_add
25252546

25262547

0 commit comments

Comments
 (0)