|
Lines 30-36
from argparse import ArgumentParser
Link Here
|
| 30 |
import os |
30 |
import os |
| 31 |
from StringIO import StringIO |
31 |
from StringIO import StringIO |
| 32 |
import subprocess |
32 |
import subprocess |
| 33 |
import platform |
|
|
| 34 |
import mozinfo |
33 |
import mozinfo |
| 35 |
|
34 |
|
| 36 |
# List of libraries to shlibsign. |
35 |
# List of libraries to shlibsign. |
|
Lines 125-184
class LibSignFile(File):
Link Here
|
| 125 |
errors.fatal('Error while signing %s' % self.path) |
124 |
errors.fatal('Error while signing %s' % self.path) |
| 126 |
|
125 |
|
| 127 |
|
126 |
|
| 128 |
def precompile_cache(registry, source_path, gre_path, app_path): |
|
|
| 129 |
''' |
| 130 |
Create startup cache for the given application directory, using the |
| 131 |
given GRE path. |
| 132 |
- registry is a FileRegistry-like instance where to add the startup cache. |
| 133 |
- source_path is the base path of the package. |
| 134 |
- gre_path is the GRE path, relative to source_path. |
| 135 |
- app_path is the application path, relative to source_path. |
| 136 |
Startup cache for all resources under resource://app/ are generated, |
| 137 |
except when gre_path == app_path, in which case it's under |
| 138 |
resource://gre/. |
| 139 |
''' |
| 140 |
from tempfile import mkstemp |
| 141 |
source_path = os.path.abspath(source_path) |
| 142 |
if app_path != gre_path: |
| 143 |
resource = 'app' |
| 144 |
else: |
| 145 |
resource = 'gre' |
| 146 |
app_path = os.path.join(source_path, app_path) |
| 147 |
gre_path = os.path.join(source_path, gre_path) |
| 148 |
|
| 149 |
fd, cache = mkstemp('.zip') |
| 150 |
os.close(fd) |
| 151 |
os.remove(cache) |
| 152 |
|
| 153 |
try: |
| 154 |
extra_env = {'MOZ_STARTUP_CACHE': cache} |
| 155 |
if buildconfig.substs.get('MOZ_TSAN'): |
| 156 |
extra_env['TSAN_OPTIONS'] = 'report_bugs=0' |
| 157 |
if buildconfig.substs.get('MOZ_ASAN'): |
| 158 |
extra_env['ASAN_OPTIONS'] = 'detect_leaks=0' |
| 159 |
if launcher.launch(['xpcshell', '-g', gre_path, '-a', app_path, |
| 160 |
'-f', os.path.join(os.path.dirname(__file__), |
| 161 |
'precompile_cache.js'), |
| 162 |
'-e', 'precompile_startupcache("resource://%s/");' |
| 163 |
% resource], |
| 164 |
extra_linker_path=gre_path, |
| 165 |
extra_env=extra_env): |
| 166 |
errors.fatal('Error while running startup cache precompilation') |
| 167 |
return |
| 168 |
from mozpack.mozjar import JarReader |
| 169 |
jar = JarReader(cache) |
| 170 |
resource = '/resource/%s/' % resource |
| 171 |
for f in jar: |
| 172 |
if resource in f.filename: |
| 173 |
path = f.filename[f.filename.index(resource) + len(resource):] |
| 174 |
if registry.contains(path): |
| 175 |
registry.add(f.filename, GeneratedFile(f.read())) |
| 176 |
jar.close() |
| 177 |
finally: |
| 178 |
if os.path.exists(cache): |
| 179 |
os.remove(cache) |
| 180 |
|
| 181 |
|
| 182 |
class RemovedFiles(GeneratedFile): |
127 |
class RemovedFiles(GeneratedFile): |
| 183 |
''' |
128 |
''' |
| 184 |
File class for removed-files. Is used as a preprocessor parser. |
129 |
File class for removed-files. Is used as a preprocessor parser. |
|
Lines 389-413
def main():
Link Here
|
| 389 |
if key in log: |
334 |
if key in log: |
| 390 |
f.preload(log[key]) |
335 |
f.preload(log[key]) |
| 391 |
|
336 |
|
| 392 |
# Fill startup cache |
|
|
| 393 |
if isinstance(formatter, OmniJarFormatter) and launcher.can_launch() \ |
| 394 |
and buildconfig.substs['MOZ_DISABLE_STARTUPCACHE'] != '1': |
| 395 |
gre_path = None |
| 396 |
def get_bases(): |
| 397 |
for b in sink.packager.get_bases(addons=False): |
| 398 |
for p in (mozpath.join('bin', b), b): |
| 399 |
if os.path.exists(os.path.join(args.source, p)): |
| 400 |
yield p |
| 401 |
break |
| 402 |
for base in sorted(get_bases()): |
| 403 |
if not gre_path: |
| 404 |
gre_path = base |
| 405 |
omnijar_path = mozpath.join(sink.normalize_path(base), |
| 406 |
buildconfig.substs['OMNIJAR_NAME']) |
| 407 |
if formatter.contains(omnijar_path): |
| 408 |
precompile_cache(formatter.copier[omnijar_path], |
| 409 |
args.source, gre_path, base) |
| 410 |
|
| 411 |
copier.copy(args.destination) |
337 |
copier.copy(args.destination) |
| 412 |
|
338 |
|
| 413 |
|
339 |
|