diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js_optimizer.py | 2 | ||||
-rw-r--r-- | tools/shared.py | 23 |
2 files changed, 17 insertions, 8 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index 2b9de91f..8681280a 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -48,7 +48,7 @@ def run(filename, passes, js_engine): f_end = js.find('\n}\n', f_end+1) chunk = js[f_start:(-1 if f_end == -1 else f_end+3)] + suffix temp_file = filename + '.p%d.js' % i - if DEBUG: print >> sys.stderr, ' chunk %d: %d bytes' % (i, (f_end if f_end >= 0 else len(js)) - f_start) + #if DEBUG: print >> sys.stderr, ' chunk %d: %d bytes' % (i, (f_end if f_end >= 0 else len(js)) - f_start) i += 1 f_start = f_end+3 done = f_end == -1 or f_start >= len(js) diff --git a/tools/shared.py b/tools/shared.py index c94c110e..ae6c5eb5 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -219,7 +219,8 @@ except: CANONICAL_TEMP_DIR = os.path.join(TEMP_DIR, 'emscripten_temp') EMSCRIPTEN_TEMP_DIR = None -if os.environ.get('EMCC_DEBUG'): +DEBUG = os.environ.get('EMCC_DEBUG') +if DEBUG: try: EMSCRIPTEN_TEMP_DIR = CANONICAL_TEMP_DIR if not os.path.exists(EMSCRIPTEN_TEMP_DIR): @@ -334,11 +335,14 @@ class TempFiles: def get(self, suffix): """Returns a named temp file with the given prefix.""" - named_file = tempfile.NamedTemporaryFile(dir=TEMP_DIR, suffix=suffix, delete=False) + named_file = tempfile.NamedTemporaryFile(dir=TEMP_DIR if not DEBUG else EMSCRIPTEN_TEMP_DIR, suffix=suffix, delete=False) self.note(named_file.name) return named_file def clean(self): + if DEBUG: + print >> sys.stderr, 'not cleaning up temp files since in debug mode, see them in %s' % EMSCRIPTEN_TEMP_DIR + return for filename in self.to_clean: try_delete(filename) self.to_clean = [] @@ -371,13 +375,10 @@ def timeout_run(proc, timeout, note='unnamed process'): raise Exception("Timed out: " + note) return proc.communicate()[0] -EM_DEBUG = os.environ.get('EM_DEBUG') - def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None): if engine is None: engine = JS_ENGINES[0] if type(engine) is not list: engine = [engine] command = engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args - if EM_DEBUG: print >> sys.stderr, 'run_js: ' + ' '.join(command) return timeout_run(Popen(command, stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution') def to_cc(cxx): @@ -555,7 +556,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e env['EMMAKEN_JUST_CONFIGURE'] = '1' if 'cmake' in args[0]: args = Building.handle_CMake_toolchain(args, env) - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + try: + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + except Exception, e: + print >> sys.stderr, 'Error: Exception thrown when invoking Popen in configure with args: "%s"!' % ' '.join(args) + raise del env['EMMAKEN_JUST_CONFIGURE'] @staticmethod @@ -563,7 +568,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e if env is None: env = Building.get_building_env() #args += ['VERBOSE=1'] - Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + try: + Popen(args, stdout=stdout, stderr=stderr, env=env).communicate() + except Exception, e: + print >> sys.stderr, 'Error: Exception thrown when invoking Popen in make with args: "%s"!' % ' '.join(args) + raise @staticmethod def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None): |