diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-18 09:00:27 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-21 20:47:01 +0100 |
commit | 58e00ebddf017079a6b7d60c066210676661177d (patch) | |
tree | e52489aee9afbaabfd100fa7b91347032dec62a1 | |
parent | f199880bb1474e8b2e3a3e4a3e5bf215c8a2b694 (diff) |
basic logic and stubs for caching pre phase
-rwxr-xr-x | emscripten.py | 15 | ||||
-rw-r--r-- | tools/shared.py | 16 |
2 files changed, 28 insertions, 3 deletions
diff --git a/emscripten.py b/emscripten.py index d33c16e7..5eb62ba2 100755 --- a/emscripten.py +++ b/emscripten.py @@ -123,15 +123,24 @@ def emscript(infile, settings, outfile, libraries=[]): # Save settings to a file to work around v8 issue 1579 settings_file = temp_files.get('.txt').name + settings_text = json.dumps(settings) s = open(settings_file, 'w') - s.write(json.dumps(settings)) + s.write(settings_text) s.close() # Phase 1 - pre if DEBUG: t = time.time() pre_file = temp_files.get('.pre.ll').name - open(pre_file, 'w').write(''.join(pre) + '\n' + meta) - out = shared.run_js(compiler, shared.COMPILER_ENGINE, [settings_file, pre_file, 'pre'] + libraries, stdout=subprocess.PIPE, cwd=path_from_root('src')) + pre_input = ''.join(pre) + '\n' + meta + out = None + if jcache: + pre_cache_key = JCache.get_key([pre_input, settings_text, ','.join(libraries)]) + out = JCache.get(pre_cache_key) + if not out: + open(pre_file, 'w').write(pre_input) + out = shared.run_js(compiler, shared.COMPILER_ENGINE, [settings_file, pre_file, 'pre'] + libraries, stdout=subprocess.PIPE, cwd=path_from_root('src')) + if jcache: + JCache.set(pre_cache_key, out) pre, forwarded_data = out.split('//FORWARDED_DATA:') forwarded_file = temp_files.get('.json').name open(forwarded_file, 'w').write(forwarded_data) diff --git a/tools/shared.py b/tools/shared.py index 1f3b5f20..06cbba68 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1153,6 +1153,22 @@ class Cache: shutil.copyfile(creator(), cachename) return cachename +class JCache: + # Generates a single key from multiple values + @staticmethod + def get_key(keys): + return '' + + # Returns a cached value for a key (from get_key), if it exists + @staticmethod + def get(key): + return None + + # Sets the cached value for a key (from get_key) + @staticmethod + def set(key, value): + pass + # Compression of code and data for smaller downloads class Compression: on = False |