diff options
author | alon@honor <none@none> | 2010-09-09 20:03:24 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-09 20:03:24 -0700 |
commit | a523ad539ccf91b7a162ac1ac18f9e1bf88f5147 (patch) | |
tree | 6d4df206e9d337081d4406cecdecf81beb9a2e5a /emscripten.py | |
parent | dd766e9a45b5b548600db35065d3ffa471919982 (diff) |
emscripten.py
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/emscripten.py b/emscripten.py new file mode 100755 index 00000000..3bbbb8c9 --- /dev/null +++ b/emscripten.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +import os, sys, subprocess + +COMPILER = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'src', 'parser.js') + +def emscripten(filename, output_filename, js_engine): + cwd = os.getcwd() + os.chdir(os.path.dirname(COMPILER)) + if output_filename is not None: + subprocess.Popen([js_engine] + [COMPILER], stdin=open(filename, 'r'), stdout=open(output_filename, 'w'), stderr=subprocess.STDOUT).communicate()[0] + else: + subprocess.Popen([js_engine] + [COMPILER], stdin=open(filename, 'r')).communicate()[0] + os.chdir(cwd) + +if __name__ == '__main__':
+ if sys.argv.__len__() != 3: + print '''\nEmscripten usage: emscripten.py INFILE PATH-TO-JS-ENGINE\n''' + else: + emscripten(sys.argv[1], None, sys.argv[2]) + |