summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-04-03 10:33:33 +0200
committerGitHub <noreply@github.com>2018-04-03 10:33:33 +0200
commit3ef85ddb8d28c186495ff374762eb515d1ddf7da (patch)
tree6d07449735d7ed4e45073ae8890963971c81344e /platform
parent59710880cd21d79ae1329f04eb35ea48e646acb3 (diff)
parent5be7c3dcee2cfab95a02552726947744ed727037 (diff)
Merge pull request #17836 from eska014/detect-emconfig
Detect and configure JavaScript build per Emscripten configuration file
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/detect.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 851f4ecb49..be1866987a 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -12,7 +12,7 @@ def get_name():
def can_build():
- return 'EMSCRIPTEN_ROOT' in os.environ or 'EMSCRIPTEN' in os.environ
+ return 'EM_CONFIG' in os.environ or os.path.exists(os.path.expanduser('~/.emscripten'))
def get_opts():
@@ -67,10 +67,20 @@ def configure(env):
## Compiler configuration
env['ENV'] = os.environ
- if 'EMSCRIPTEN_ROOT' in os.environ:
- env.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT'])
- elif 'EMSCRIPTEN' in os.environ:
- env.PrependENVPath('PATH', os.environ['EMSCRIPTEN'])
+
+ 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)
+ with open(em_config_file) as f:
+ em_config = {}
+ 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))
+ if 'EMSCRIPTEN_ROOT' not in em_config:
+ raise RuntimeError("'EMSCRIPTEN_ROOT' missing in Emscripten configuration file '%s'" % em_config_file)
+ env.PrependENVPath('PATH', em_config['EMSCRIPTEN_ROOT'])
env['CC'] = 'emcc'
env['CXX'] = 'em++'