Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
69 lines (61 loc) · 2.18 KB

File metadata and controls

69 lines (61 loc) · 2.18 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os.path, sys, shutil, time, logging
import tempfiles
# Permanent cache for dlmalloc and stdlibc++
class Cache:
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):
shared.safe_ensure_dirs(self.dirname)
def erase(self):
tempfiles.try_delete(self.dirname)
try:
open(self.dirname + '__last_clear', 'w').write('last clear: ' + time.asctime() + '\n')
except Exception, e:
print >> sys.stderr, 'failed to save last clear time: ', e
def get_path(self, shortname):
return os.path.join(self.dirname, shortname)
# Request a cached file. If it isn't in the cache, it will be created with
# the given creator function
def get(self, shortname, creator, extension='.bc', what=None):
if not shortname.endswith(extension): shortname += extension
cachename = os.path.join(self.dirname, shortname)
if os.path.exists(cachename):
return cachename
if what is None:
if shortname.endswith(('.bc', '.so', '.a')): what = 'system library'
else: what = 'system asset'
message = 'generating ' + what + ': ' + shortname + '...'
logging.warn(message)
self.ensure()
temp = creator()
if temp != cachename:
shutil.copyfile(temp, cachename)
logging.warn(' '*len(message) + 'ok')
return cachename
# Given a set of functions of form (ident, text), and a preferred chunk size,
# generates a set of chunks for parallel processing and caching.
def chunkify(funcs, chunk_size, DEBUG=False):
chunks = []
# initialize reasonably, the rest of the funcs we need to split out
curr = []
total_size = 0
for i in range(len(funcs)):
func = funcs[i]
curr_size = len(func[1])
if total_size + curr_size < chunk_size:
curr.append(func)
total_size += curr_size
else:
chunks.append(curr)
curr = [func]
total_size = curr_size
if curr:
chunks.append(curr)
curr = None
return [''.join([func[1] for func in chunk]) for chunk in chunks] # remove function names
import shared
Morty Proxy This is a proxified and sanitized view of the page, visit original site.