diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/bindings_generator.py | 29 | ||||
-rw-r--r-- | tools/shared.py | 31 |
2 files changed, 34 insertions, 26 deletions
diff --git a/tools/bindings_generator.py b/tools/bindings_generator.py index 3fbff13d..0c7c814f 100755 --- a/tools/bindings_generator.py +++ b/tools/bindings_generator.py @@ -671,25 +671,22 @@ def generate_class(generating_classname, classname, clazz): # TODO: deprecate ge has_string_convs = False - # We can assume that NULL is passed for null pointers, so object arguments can always - # have .ptr done on them - justargs_fixed = justargs(args)[:] - for i in range(len(args)): - arg = args[i] - clean = clean_type(arg['type']) - if clean in classes: - justargs_fixed[i] += '.ptr' - elif arg['type'].replace(' ', '').endswith('char*'): - justargs_fixed[i] = 'ensureString(' + justargs_fixed[i] + ')' - has_string_convs = True - calls = '' - if has_string_convs: - calls += 'var stack = Runtime.stackSave();\n'; - calls += 'try {\n' #print 'js loopin', params, '|', len(args)#, args for args in params: + # We can assume that NULL is passed for null pointers, so object arguments can always + # have .ptr done on them + justargs_fixed = justargs(args)[:] + for i in range(len(args)): + arg = args[i] + clean = clean_type(arg['type']) + if clean in classes: + justargs_fixed[i] += '.ptr' + elif arg['type'].replace(' ', '').endswith('char*'): + justargs_fixed[i] = 'ensureString(' + justargs_fixed[i] + ')' + has_string_convs = True + i = len(args) if args != params[0]: calls += ' else ' @@ -715,7 +712,7 @@ def generate_class(generating_classname, classname, clazz): # TODO: deprecate ge calls += '\n' if has_string_convs: - calls += '} finally { Runtime.stackRestore(stack) }\n'; + calls = 'var stack = Runtime.stackSave();\ntry {\n' + calls + '} finally { Runtime.stackRestore(stack) }\n'; print 'Maekin:', classname, generating_classname, mname, mname_suffixed if constructor: diff --git a/tools/shared.py b/tools/shared.py index 69343cc2..c8998b5a 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -81,9 +81,9 @@ def check_sanity(force=False): sys.exit(0) try: - subprocess.call(['java', '-version'], stdout=PIPE, stderr=PIPE) + subprocess.call([JAVA, '-version'], stdout=PIPE, stderr=PIPE) except: - print >> sys.stderr, 'WARNING: java does not seem to exist, required for closure compiler. -O2 and above will fail.' + print >> sys.stderr, 'WARNING: java does not seem to exist, required for closure compiler. -O2 and above will fail. You need to define JAVA in ~/.emscripten (see settings.py)' if not os.path.exists(CLOSURE_COMPILER): print >> sys.stderr, 'WARNING: Closure compiler (%s) does not exist, check the paths in %s. -O2 and above will fail' % (CLOSURE_COMPILER, EM_CONFIG) @@ -172,6 +172,12 @@ try: except: CLOSURE_COMPILER = path_from_root('third_party', 'closure-compiler', 'compiler.jar') +try: + JAVA +except: + print >> sys.stderr, 'JAVA not defined in ~/.emscripten, using "java"' + JAVA = 'java' + # Additional compiler options try: @@ -504,13 +510,18 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e if configure: # Useful in debugging sometimes to comment this out (and the lines below up to and including the |link| call) Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'), stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env) - Building.make(make + make_args, stdout=open(os.path.join(project_dir, 'make_'), 'w'), - stderr=open(os.path.join(project_dir, 'make_err'), 'w'), env=env) - if cache is not None: - cache[cache_name] = [] - for f in generated_libs: - basename = os.path.basename(f) - cache[cache_name].append((basename, open(f, 'rb').read())) + for i in range(2): # workaround for some build systems that need to be run twice to succeed (e.g. poppler) + Building.make(make + make_args, stdout=open(os.path.join(project_dir, 'make_' + str(i)), 'w'), + stderr=open(os.path.join(project_dir, 'make_err' + str(i)), 'w'), env=env) + try: + if cache is not None: + cache[cache_name] = [] + for f in generated_libs: + basename = os.path.basename(f) + cache[cache_name].append((basename, open(f, 'rb').read())) + break + except: + if i > 0: raise Exception('could not build library ' + name) if old_dir: os.chdir(old_dir) return generated_libs @@ -830,7 +841,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # Something like this (adjust memory as needed): # java -Xmx1024m -jar CLOSURE_COMPILER --compilation_level ADVANCED_OPTIMIZATIONS --variable_map_output_file src.cpp.o.js.vars --js src.cpp.o.js --js_output_file src.cpp.o.cc.js - args = ['java', + args = [JAVA, '-Xmx1024m', '-jar', CLOSURE_COMPILER, '--compilation_level', 'ADVANCED_OPTIMIZATIONS', |