OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import os | 3 import os |
4 import re | 4 import re |
5 import subprocess | 5 import subprocess |
6 | 6 |
7 EMSCRIPTEN_PATH = '../emscripten' | 7 BASE_DIR = os.path.dirname(__file__) |
8 SOURCE_DIR = './compiled' | 8 EMSCRIPTEN_PATH = os.path.join(BASE_DIR, '..', 'emscripten') |
| 9 SOURCE_DIR = os.path.join(BASE_DIR, 'compiled') |
9 SOURCE_FILES = [ | 10 SOURCE_FILES = [ |
10 os.path.join(path, f) | 11 os.path.join(path, f) |
11 for (path, dirs, files) in os.walk(SOURCE_DIR) | 12 for (path, dirs, files) in os.walk(SOURCE_DIR) |
12 for f in files | 13 for f in files |
13 if f.endswith('.cpp') | 14 if f.endswith('.cpp') |
14 ] | 15 ] |
15 BINDINGS_FILE = os.path.join(SOURCE_DIR, 'bindings.cpp') | 16 BINDINGS_FILE = os.path.join(SOURCE_DIR, 'bindings.cpp') |
16 BINDINGS_GENERATOR = os.path.join(SOURCE_DIR, 'bindings.cpp.js') | 17 BINDINGS_GENERATOR = os.path.join(SOURCE_DIR, 'bindings.cpp.js') |
17 BINDINGS_OUTPUT = os.path.join(SOURCE_DIR, 'bindings.js') | 18 BINDINGS_OUTPUT = os.path.join(SOURCE_DIR, 'bindings.js') |
18 COMPILER_OUTPUT = './lib/compiled.js' | 19 COMPILER_OUTPUT = os.path.join(BASE_DIR, 'lib', 'compiled.js') |
19 GENERATION_PARAMS = { | 20 GENERATION_PARAMS = { |
20 'SHELL_FILE': "'{}'".format(os.path.abspath(os.path.join(SOURCE_DIR, | 21 'SHELL_FILE': "'{}'".format(os.path.abspath(os.path.join(SOURCE_DIR, |
21 'shell.js'))), | 22 'shell.js'))), |
22 'ASM_JS': 2, # "almost asm" | 23 'ASM_JS': 2, # "almost asm" |
23 'TOTAL_MEMORY': 16*1024*1024, | 24 'TOTAL_MEMORY': 16*1024*1024, |
24 'TOTAL_STACK': 1*1024*1024, | 25 'TOTAL_STACK': 1*1024*1024, |
25 'ALLOW_MEMORY_GROWTH': 1, | 26 'ALLOW_MEMORY_GROWTH': 1, |
26 'NO_EXIT_RUNTIME': 1, | 27 'NO_EXIT_RUNTIME': 1, |
27 'NO_DYNAMIC_EXECUTION': 1, | 28 'NO_DYNAMIC_EXECUTION': 1, |
28 'NO_FILESYSTEM': 1, | 29 'NO_FILESYSTEM': 1, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 for key, value in GENERATION_PARAMS.iteritems(): | 77 for key, value in GENERATION_PARAMS.iteritems(): |
77 params.extend(['-s', '{}={}'.format(key, str(value))]) | 78 params.extend(['-s', '{}={}'.format(key, str(value))]) |
78 params.extend(ADDITIONAL_PARAMS) | 79 params.extend(ADDITIONAL_PARAMS) |
79 subprocess.check_call(params, env=env) | 80 subprocess.check_call(params, env=env) |
80 | 81 |
81 | 82 |
82 if __name__ == '__main__': | 83 if __name__ == '__main__': |
83 env = getenv() | 84 env = getenv() |
84 generate_bindings(env) | 85 generate_bindings(env) |
85 run_compiler(env) | 86 run_compiler(env) |
OLD | NEW |