aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-02-01 14:54:00 -0800
committerChad Austin <chad@imvu.com>2013-03-04 19:34:28 -0800
commit74955d520119ed01509faf4976635a113bfe95bd (patch)
tree8788d1dbb662721f1b62f5b5f3742c6f1dbd7c82 /tools/shared.py
parentf507b18f6a21731618ac8042802b05eb23d79543 (diff)
make it possible to manually specify a temp directory when running emscripten.py
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py34
1 files changed, 2 insertions, 32 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 052be15b..ff9f9f9b 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1,7 +1,7 @@
import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess, hashlib, cPickle, zlib, re
from subprocess import Popen, PIPE, STDOUT
from tempfile import mkstemp
-from . import jsrun, cache
+from . import jsrun, cache, tempfiles
def listify(x):
if type(x) is not list: return [x]
@@ -318,7 +318,7 @@ class Configuration:
print >> sys.stderr, e, 'Could not create canonical temp dir. Check definition of TEMP_DIR in ~/.emscripten'
def get_temp_files(self):
- return TempFiles(
+ return tempfiles.TempFiles(
tmp=self.TEMP_DIR if not self.DEBUG else self.EMSCRIPTEN_TEMP_DIR,
save_debug_files=os.environ.get('EMCC_DEBUG_SAVE'))
@@ -326,36 +326,6 @@ class Configuration:
if self.DEBUG:
print >> sys.stderr, msg
-class TempFiles:
- def __init__(self, tmp, save_debug_files=False):
- self.tmp = tmp
- self.save_debug_files = save_debug_files
-
- self.to_clean = []
-
- def note(self, filename):
- self.to_clean.append(filename)
-
- def get(self, suffix):
- """Returns a named temp file with the given prefix."""
- named_file = tempfile.NamedTemporaryFile(dir=self.tmp, suffix=suffix, delete=False)
- self.note(named_file.name)
- return named_file
-
- def clean(self):
- if self.save_debug_files:
- print >> sys.stderr, 'not cleaning up temp files since in debug-save mode, see them in %s' % (self.tmp,)
- return
- for filename in self.to_clean:
- try_delete(filename)
- self.to_clean = []
-
- def run_and_clean(self, func):
- try:
- return func()
- finally:
- self.clean()
-
configuration = Configuration(environ=os.environ)
DEBUG = configuration.DEBUG
EMSCRIPTEN_TEMP_DIR = configuration.EMSCRIPTEN_TEMP_DIR