aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-01-28 18:44:46 -0800
committerChad Austin <chad@imvu.com>2013-03-04 19:04:08 -0800
commiteff17663bc9460f1f760eaeb9be04450347eba1e (patch)
tree09623cbca6176fa146a42991f00d3b9a3890a141
parentb32d0644551903091ad873b52fe9de920ea07020 (diff)
Pass configuration into emscript
-rwxr-xr-xemscripten.py13
-rw-r--r--tools/shared.py9
2 files changed, 13 insertions, 9 deletions
diff --git a/emscripten.py b/emscripten.py
index a817ade3..a0b34751 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -13,11 +13,6 @@ import os, sys, json, optparse, subprocess, re, time, multiprocessing
from tools import shared
-DEBUG = os.environ.get('EMCC_DEBUG')
-if DEBUG == "0":
- DEBUG = None
-DEBUG_CACHE = DEBUG and "cache" in DEBUG
-
__rootpath__ = os.path.abspath(os.path.dirname(__file__))
def path_from_root(*pathelems):
"""Returns the absolute path for which the given path elements are
@@ -53,7 +48,7 @@ def process_funcs(args):
shared.try_delete(funcs_file)
return out
-def emscript(infile, settings, outfile, libraries=[]):
+def emscript(configuration, infile, settings, outfile, libraries=[]):
"""Runs the emscripten LLVM-to-JS compiler. We parallelize as much as possible
Args:
@@ -63,6 +58,8 @@ def emscript(infile, settings, outfile, libraries=[]):
outfile: The file where the output is written.
"""
+ DEBUG = configuration.DEBUG
+ DEBUG_CACHE = configuration.DEBUG_CACHE
compiler = path_from_root('src', 'compiler.js')
# Parallelization: We run 3 phases:
@@ -70,7 +67,7 @@ def emscript(infile, settings, outfile, libraries=[]):
# 2 aka 'funcs': Process functions. We can parallelize this, working on each function independently.
# 3 aka 'post' : Process globals, generate postamble and finishing touches.
- if DEBUG: print >> sys.stderr, 'emscript: ll=>js'
+ configuration.debug_log('emscript: ll=>js')
if jcache: shared.JCache.ensure()
@@ -566,7 +563,7 @@ def main(args):
# Compile the assembly to Javascript.
if settings.get('RELOOP'): shared.Building.ensure_relooper()
- emscript(args.infile, settings, args.outfile, libraries)
+ emscript(configuration, args.infile, settings, args.outfile, libraries)
def _main(environ):
parser = optparse.OptionParser(
diff --git a/tools/shared.py b/tools/shared.py
index 1005a48d..585b2af2 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -304,6 +304,9 @@ CANONICAL_TEMP_DIR = os.path.join(TEMP_DIR, 'emscripten_temp')
class Configuration:
def __init__(self, environ):
self.DEBUG = environ.get('EMCC_DEBUG')
+ if self.DEBUG == "0":
+ self.DEBUG = None
+ self.DEBUG_CACHE = self.DEBUG and "cache" in self.DEBUG
self.EMSCRIPTEN_TEMP_DIR = None
if self.DEBUG:
@@ -314,11 +317,15 @@ class Configuration:
except Exception, e:
print >> sys.stderr, e, 'Could not create canonical temp dir. Check definition of TEMP_DIR in ~/.emscripten'
+ def debug_log(self, msg):
+ if self.DEBUG:
+ print >> sys.stderr, msg
+
configuration = Configuration(
environ=os.environ)
DEBUG = configuration.DEBUG
EMSCRIPTEN_TEMP_DIR = configuration.EMSCRIPTEN_TEMP_DIR
-DEBUG_CACHE = DEBUG and "cache" in DEBUG
+DEBUG_CACHE = configuration.DEBUG_CACHE
if not EMSCRIPTEN_TEMP_DIR:
EMSCRIPTEN_TEMP_DIR = tempfile.mkdtemp(prefix='emscripten_temp_', dir=TEMP_DIR)