diff options
-rw-r--r-- | tools/validate_asmjs.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/validate_asmjs.py b/tools/validate_asmjs.py index 85bf69ce..ea909fbd 100644 --- a/tools/validate_asmjs.py +++ b/tools/validate_asmjs.py @@ -12,10 +12,20 @@ # This script depends on the SpiderMonkey JS engine, which must be present in PATH in order for this script to function. import subprocess, sys, re, tempfile, os, time +import shared + +# Looks up SpiderMonkey engine using the variable SPIDERMONKEY_ENGINE in ~/.emscripten, and if not set up there, via PATH. +def find_spidermonkey_engine(): + sm_engine = shared.SPIDERMONKEY_ENGINE if hasattr(shared, 'SPIDERMONKEY_ENGINE') else [''] + if not sm_engine or len(sm_engine[0]) == 0 or not os.path.exists(sm_engine[0]): + sm_engine[0] = shared.Building.which('js') + if sm_engine[0] == None: + return ['js-not-found'] + return sm_engine # Given a .js file, returns True/False depending on if that file is valid asm.js def validate_asmjs_jsfile(filename, muteOutput): - process = subprocess.Popen(['js', '-c', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + process = subprocess.Popen(find_spidermonkey_engine() + ['-c', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) (stdout, stderr) = process.communicate() if not muteOutput: if len(stdout.strip()) > 0: |