aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-05 10:19:10 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-05 10:23:33 -0800
commit09868ed9110b5ff6575f9f4af0976e3e2313d05e (patch)
treea6af20beace5e5265500394e27008be28cf7035b
parent46158be251798bf66417b1ce891ccf2e29e2ec85 (diff)
restore jcache debugging, busted by pull #826
-rw-r--r--tools/cache.py19
-rw-r--r--tools/shared.py2
2 files changed, 11 insertions, 10 deletions
diff --git a/tools/cache.py b/tools/cache.py
index a63d7bb3..eacf5a75 100644
--- a/tools/cache.py
+++ b/tools/cache.py
@@ -1,15 +1,16 @@
-import os.path, shutil, hashlib, cPickle, zlib
+import os.path, sys, shutil, hashlib, cPickle, zlib
import tempfiles
# Permanent cache for dlmalloc and stdlibc++
class Cache:
- def __init__(self, dirname=None):
+ def __init__(self, dirname=None, debug=False):
if dirname is None:
dirname = os.environ.get('EM_CACHE')
if not dirname:
dirname = os.path.expanduser(os.path.join('~', '.emscripten_cache'))
self.dirname = dirname
+ self.debug = debug
def ensure(self):
if not os.path.exists(self.dirname):
@@ -43,6 +44,7 @@ class JCache:
def __init__(self, cache):
self.cache = cache
self.dirname = os.path.join(cache.dirname, 'jcache')
+ self.debug = cache.debug
def ensure(self):
self.cache.ensure()
@@ -63,27 +65,27 @@ class JCache:
# Returns a cached value, if it exists. Make sure the full key matches
def get(self, shortkey, keys):
- #if DEBUG: print >> sys.stderr, 'jcache get?', shortkey
+ if self.debug: print >> sys.stderr, 'jcache get?', shortkey
cachename = self.get_cachename(shortkey)
if not os.path.exists(cachename):
- #if DEBUG: print >> sys.stderr, 'jcache none at all'
+ if self.debug: print >> sys.stderr, 'jcache none at all'
return
try:
data = cPickle.loads(zlib.decompress(open(cachename).read()))
except Exception, e:
if DEBUG_CACHE: print >> sys.stderr, 'jcache decompress/unpickle error:', e
if len(data) != 2:
- #if DEBUG: print >> sys.stderr, 'jcache error in get'
+ if self.debug: print >> sys.stderr, 'jcache error in get'
return
oldkeys = data[0]
if len(oldkeys) != len(keys):
- #if DEBUG: print >> sys.stderr, 'jcache collision (a)'
+ if self.debug: print >> sys.stderr, 'jcache collision (a)'
return
for i in range(len(oldkeys)):
if oldkeys[i] != keys[i]:
- #if DEBUG: print >> sys.stderr, 'jcache collision (b)'
+ if self.debug: print >> sys.stderr, 'jcache collision (b)'
return
- #if DEBUG: print >> sys.stderr, 'jcache win'
+ if self.debug: print >> sys.stderr, 'jcache win'
return data[1]
# Sets the cached value for a key (from get_key)
@@ -96,7 +98,6 @@ class JCache:
except Exception, e:
if DEBUG_CACHE: print >> sys.stderr, 'jcache compress/pickle error:', e
return
- #if DEBUG:
# for i in range(len(keys)):
# open(cachename + '.key' + str(i), 'w').write(keys[i])
# open(cachename + '.value', 'w').write(value)
diff --git a/tools/shared.py b/tools/shared.py
index 74e4d8f3..9ad227b6 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1200,7 +1200,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
return outfile
# compatibility with existing emcc, etc. scripts
-Cache = cache.Cache()
+Cache = cache.Cache(debug=DEBUG_CACHE)
JCache = cache.JCache(Cache)
chunkify = cache.chunkify