Left: | ||
Right: |
OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import json | 3 import json |
4 import os | 4 import os |
5 import re | 5 import re |
6 import subprocess | 6 import subprocess |
7 import warnings | 7 import warnings |
8 | 8 |
9 EMSCRIPTEN_PATH = '../emscripten' | 9 EMSCRIPTEN_PATH = '../emscripten' |
10 SOURCE_DIR = './compiled' | 10 SOURCE_DIR = './compiled' |
11 SOURCE_FILES = [ | 11 SOURCE_FILES = [ |
12 os.path.join(path, f) | 12 os.path.join(path, f) |
13 for (path, dirs, files) in os.walk(SOURCE_DIR) | 13 for (path, dirs, files) in os.walk(SOURCE_DIR) |
14 for f in files | 14 for f in files |
15 if f.endswith('.cpp') | 15 if f.endswith('.cpp') |
16 ] | 16 ] |
17 BINDINGS_FILE = os.path.join(SOURCE_DIR, 'bindings.cpp') | 17 BINDINGS_FILE = os.path.join(SOURCE_DIR, 'bindings.cpp') |
18 BINDINGS_GENERATOR = os.path.join(SOURCE_DIR, 'bindings.cpp.js') | 18 BINDINGS_GENERATOR = os.path.join(SOURCE_DIR, 'bindings.cpp.js') |
19 BINDINGS_OUTPUT = os.path.join(SOURCE_DIR, 'bindings.js') | 19 BINDINGS_OUTPUT = os.path.join(SOURCE_DIR, 'bindings.js') |
20 COMPILER_OUTPUT = './lib/compiled.js' | 20 COMPILER_OUTPUT = './lib/compiled.js' |
21 GENERATION_PARAMS = { | 21 GENERATION_PARAMS = { |
22 'SHELL_FILE': "'%s'" % os.path.abspath(os.path.join(SOURCE_DIR, 'shell.js')), | 22 'SHELL_FILE': "'%s'" % os.path.abspath(os.path.join(SOURCE_DIR, 'shell.js')), |
23 'ASM_JS': 2, # "almost asm" | 23 'ASM_JS': 2, # "almost asm" |
24 'TOTAL_MEMORY': 16*1024*1024, | 24 'TOTAL_MEMORY': 16*1024*1024, |
25 'TOTAL_STACK': 1*1024*1024, | 25 'TOTAL_STACK': 1*1024*1024, |
26 'ALLOW_MEMORY_GROWTH': 1, | 26 'ALLOW_MEMORY_GROWTH': 1, |
27 'NO_EXIT_RUNTIME': 1, | 27 'NO_EXIT_RUNTIME': 1, |
28 'NO_DYNAMIC_EXECUTION': 1, | 28 'NO_DYNAMIC_EXECUTION': 1, |
29 'NO_BROWSER': 1, | |
30 'NO_FILESYSTEM': 1, | 29 'NO_FILESYSTEM': 1, |
31 'INVOKE_RUN': 0, | 30 'INVOKE_RUN': 0, |
32 'NODE_STDOUT_FLUSH_WORKAROUND': 0, | 31 'TEXTDECODER': 0, |
Wladimir Palant
2017/03/15 11:02:48
TextDecoder is only used for functions that aren't
| |
32 'EXPORTED_RUNTIME_METHODS': ['cwrap', 'ccall', 'stringToAscii'], | |
Wladimir Palant
2017/03/15 11:02:48
This reduces code size a bit, almost no functions
| |
33 } | 33 } |
34 DEFINES = [] | 34 DEFINES = [] |
35 ADDITIONAL_PARAMS = ['-O3', '-m32', '-std=gnu++14', '--memory-init-file', '0', | 35 ADDITIONAL_PARAMS = ['-O3', '-m32', '-std=gnu++14', '--memory-init-file', '0', |
36 '--emit-symbol-map'] | 36 '--emit-symbol-map'] |
37 | 37 |
38 def getenv(): | 38 def getenv(): |
39 path = [] | 39 path = [] |
40 env = {} | 40 env = {} |
41 output = subprocess.check_output([ | 41 output = subprocess.check_output([ |
42 '/bin/bash', '-c', os.path.join(EMSCRIPTEN_PATH, 'emsdk_env.sh')]) | 42 '/bin/bash', '-c', os.path.join(EMSCRIPTEN_PATH, 'emsdk_env.sh')]) |
(...skipping 28 matching lines...) Expand all Loading... | |
71 params.extend('-D' + flag for flag in DEFINES) | 71 params.extend('-D' + flag for flag in DEFINES) |
72 for key, value in GENERATION_PARAMS.iteritems(): | 72 for key, value in GENERATION_PARAMS.iteritems(): |
73 params.extend(['-s', '%s=%s' % (key, str(value))]) | 73 params.extend(['-s', '%s=%s' % (key, str(value))]) |
74 params.extend(ADDITIONAL_PARAMS) | 74 params.extend(ADDITIONAL_PARAMS) |
75 subprocess.check_call(params, env=env) | 75 subprocess.check_call(params, env=env) |
76 | 76 |
77 if __name__ == '__main__': | 77 if __name__ == '__main__': |
78 env = getenv() | 78 env = getenv() |
79 generate_bindings(env) | 79 generate_bindings(env) |
80 run_compiler(env) | 80 run_compiler(env) |
OLD | NEW |