[HTML5] Scons now expects "emcc" to be in PATH.

No longer parse emscripten/emsdk config to detect emcc/node paths.
Use WhereIs to find "emcc" and "node", look for "node_modules" in "emcc"
path.

(cherry picked from commit 7998745237)
This commit is contained in:
Fabio Alessandrelli 2020-10-03 15:46:52 +02:00 committed by Rémi Verschelde
parent 6c4a02479d
commit 2d5f9c53b0
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 6 additions and 25 deletions

View file

@ -1,6 +1,7 @@
import os import os
from emscripten_helpers import parse_config, run_closure_compiler, create_engine_file from emscripten_helpers import run_closure_compiler, create_engine_file
from SCons.Util import WhereIs
def is_active(): def is_active():
@ -12,7 +13,7 @@ def get_name():
def can_build(): def can_build():
return "EM_CONFIG" in os.environ or os.path.exists(os.path.expanduser("~/.emscripten")) return WhereIs("emcc") is not None
def get_opts(): def get_opts():
@ -100,9 +101,6 @@ def configure(env):
# Closure compiler extern and support for ecmascript specs (const, let, etc). # Closure compiler extern and support for ecmascript specs (const, let, etc).
env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT6" env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT6"
em_config = parse_config()
env.PrependENVPath("PATH", em_config["EMCC_ROOT"])
env["CC"] = "emcc" env["CC"] = "emcc"
env["CXX"] = "em++" env["CXX"] = "em++"
env["LINK"] = "emcc" env["LINK"] = "emcc"

View file

@ -1,28 +1,11 @@
import os import os
from SCons.Util import WhereIs
def parse_config():
em_config_file = os.getenv("EM_CONFIG") or os.path.expanduser("~/.emscripten")
if not os.path.exists(em_config_file):
raise RuntimeError("Emscripten configuration file '%s' does not exist" % em_config_file)
normalized = {}
em_config = {}
with open(em_config_file) as f:
try:
# Emscripten configuration file is a Python file with simple assignments.
exec(f.read(), em_config)
except StandardError as e:
raise RuntimeError("Emscripten configuration file '%s' is invalid:\n%s" % (em_config_file, e))
normalized["EMCC_ROOT"] = em_config.get("EMSCRIPTEN_ROOT")
normalized["NODE_JS"] = em_config.get("NODE_JS")
normalized["CLOSURE_BIN"] = os.path.join(normalized["EMCC_ROOT"], "node_modules", ".bin", "google-closure-compiler")
return normalized
def run_closure_compiler(target, source, env, for_signature): def run_closure_compiler(target, source, env, for_signature):
cfg = parse_config() closure_bin = os.path.join(os.path.dirname(WhereIs("emcc")), "node_modules", ".bin", "google-closure-compiler")
cmd = [cfg["NODE_JS"], cfg["CLOSURE_BIN"]] cmd = [WhereIs("node"), closure_bin]
cmd.extend(["--compilation_level", "ADVANCED_OPTIMIZATIONS"]) cmd.extend(["--compilation_level", "ADVANCED_OPTIMIZATIONS"])
for f in env["JSEXTERNS"]: for f in env["JSEXTERNS"]:
cmd.extend(["--externs", f.get_abspath()]) cmd.extend(["--externs", f.get_abspath()])