aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py23
1 files changed, 16 insertions, 7 deletions
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):