From 8697dff5c3c48adaf471575f5d832d26c575268a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Mon, 14 Sep 2015 20:44:47 +0300 Subject: [PATCH] Prefer 'nodejs' as Node fallback if it exists. Closes #20. Don't redundantly duplicate Node.js and SpiderMonkey specifiers. --- emsdk | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/emsdk b/emsdk index 473752d..bac6e53 100755 --- a/emsdk +++ b/emsdk @@ -720,17 +720,27 @@ def generate_dot_emscripten(active_tools): else: temp_dir = tempfile.gettempdir().replace('\\', '/') + has_spidermonkey = False + has_node = False + cfg = 'import os\n' - cfg += '''SPIDERMONKEY_ENGINE = '' -NODE_JS = 'node' -''' 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' + # These two vars must always be defined, even though they might not exist. + if not has_spidermonkey: cfg += "SPIDERMONKEY_ENGINE = ''\n" + if not has_node: + node_fallback = which('nodejs') + if not node_fallback: + node_fallback = 'node' + cfg += "NODE_JS = '" + node_fallback + "'\n" + cfg += '''V8_ENGINE = '' TEMP_DIR = ''' + "'" + temp_dir + "'" + ''' COMPILER_ENGINE = NODE_JS