aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-01-31 17:48:49 -0800
committerChad Austin <chad@imvu.com>2013-03-04 19:31:47 -0800
commit730294d0d106a4cf2d40bad94bba33f53d944ebc (patch)
treea23fdcf4f1942d736fdc07e8eeffbf4bfd6150d0
parent14833940f45cfea351e571f486d68c685cb9239f (diff)
Move TEMP_DIR into the Configuration object.
-rwxr-xr-xemscripten.py8
-rw-r--r--tools/shared.py22
2 files changed, 15 insertions, 15 deletions
diff --git a/emscripten.py b/emscripten.py
index 26a018ae..1a87c788 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -585,10 +585,10 @@ def main(args, compiler_engine, cache, jcache, relooper):
def _main(environ):
parser = optparse.OptionParser(
- usage='usage: %prog [-h] [-H HEADERS] [-o OUTFILE] [-c COMPILER_ENGINE] [-s FOO=BAR]* infile',
- description=('You should normally never use this! Use emcc instead. '
- 'This is a wrapper around the JS compiler, converting .ll to .js.'),
- epilog='')
+ usage='usage: %prog [-h] [-H HEADERS] [-o OUTFILE] [-c COMPILER_ENGINE] [-s FOO=BAR]* infile',
+ description=('You should normally never use this! Use emcc instead. '
+ 'This is a wrapper around the JS compiler, converting .ll to .js.'),
+ epilog='')
parser.add_option('-H', '--headers',
default=[],
action='append',
diff --git a/tools/shared.py b/tools/shared.py
index f1d133d7..9b2b4561 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -293,14 +293,6 @@ FILE_PACKAGER = path_from_root('tools', 'file_packager.py')
# Temp dir. Create a random one, unless EMCC_DEBUG is set, in which case use TEMP_DIR/emscripten_temp
-try:
- TEMP_DIR
-except:
- print >> sys.stderr, 'TEMP_DIR not defined in ~/.emscripten, using /tmp'
- TEMP_DIR = '/tmp'
-
-CANONICAL_TEMP_DIR = os.path.join(TEMP_DIR, 'emscripten_temp')
-
class Configuration:
def __init__(self, environ):
self.DEBUG = environ.get('EMCC_DEBUG')
@@ -309,6 +301,14 @@ class Configuration:
self.DEBUG_CACHE = self.DEBUG and "cache" in self.DEBUG
self.EMSCRIPTEN_TEMP_DIR = None
+ try:
+ self.TEMP_DIR = TEMP_DIR
+ except NameError:
+ print >> sys.stderr, 'TEMP_DIR not defined in ~/.emscripten, using /tmp'
+ self.TEMP_DIR = '/tmp'
+
+ CANONICAL_TEMP_DIR = os.path.join(self.TEMP_DIR, 'emscripten_temp')
+
if self.DEBUG:
try:
self.EMSCRIPTEN_TEMP_DIR = CANONICAL_TEMP_DIR
@@ -327,7 +327,7 @@ EMSCRIPTEN_TEMP_DIR = configuration.EMSCRIPTEN_TEMP_DIR
DEBUG_CACHE = configuration.DEBUG_CACHE
if not EMSCRIPTEN_TEMP_DIR:
- EMSCRIPTEN_TEMP_DIR = tempfile.mkdtemp(prefix='emscripten_temp_', dir=TEMP_DIR)
+ EMSCRIPTEN_TEMP_DIR = tempfile.mkdtemp(prefix='emscripten_temp_', dir=configuration.TEMP_DIR)
def clean_temp():
try_delete(EMSCRIPTEN_TEMP_DIR)
atexit.register(clean_temp)
@@ -467,7 +467,7 @@ class TempFiles:
def make_temp_files(configuration=configuration):
return TempFiles(
- tmp=TEMP_DIR if not configuration.DEBUG else configuration.EMSCRIPTEN_TEMP_DIR,
+ tmp=configuration.TEMP_DIR if not configuration.DEBUG else configuration.EMSCRIPTEN_TEMP_DIR,
save_debug_files=os.environ.get('EMCC_DEBUG_SAVE'))
# Utilities
@@ -660,7 +660,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
.replace('$EMSCRIPTEN_ROOT', path_from_root('').replace('\\', '/')) \
.replace('$CFLAGS', env['CFLAGS']) \
.replace('$CXXFLAGS', env['CFLAGS'])
- toolchainFile = mkstemp(suffix='.cmaketoolchain.txt', dir=TEMP_DIR)[1]
+ toolchainFile = mkstemp(suffix='.cmaketoolchain.txt', dir=configuration.TEMP_DIR)[1]
open(toolchainFile, 'w').write(CMakeToolchain)
args.append('-DCMAKE_TOOLCHAIN_FILE=%s' % os.path.abspath(toolchainFile))
return args