Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 600676 | Differences between
and this patch

Collapse All | Expand All

(-)a/python/mozbuild/mozpack/packager/formats.py (-6 / +1 lines)
Lines 23-33 from mozpack.copier import ( Link Here
23
    Jarrer,
23
    Jarrer,
24
)
24
)
25
25
26
STARTUP_CACHE_PATHS = [
27
    'jsloader',
28
    'jssubloader',
29
]
30
31
'''
26
'''
32
Formatters are classes receiving packaging instructions and creating the
27
Formatters are classes receiving packaging instructions and creating the
33
appropriate package layout.
28
appropriate package layout.
Lines 321-324 class OmniJarSubFormatter(PiecemealFormatter): Link Here
321
            'greprefs.js',
316
            'greprefs.js',
322
            'hyphenation',
317
            'hyphenation',
323
            'update.locale',
318
            'update.locale',
324
        ] or path[0] in STARTUP_CACHE_PATHS
319
        ]
(-)a/python/mozbuild/mozpack/packager/unpack.py (-6 / +2 lines)
Lines 23-32 from mozpack.copier import ( Link Here
23
    FileCopier,
23
    FileCopier,
24
)
24
)
25
from mozpack.packager import SimplePackager
25
from mozpack.packager import SimplePackager
26
from mozpack.packager.formats import (
26
from mozpack.packager.formats import FlatFormatter
27
    FlatFormatter,
28
    STARTUP_CACHE_PATHS,
29
)
30
from urlparse import urlparse
27
from urlparse import urlparse
31
28
32
29
Lines 188-195 def unpack_to_registry(source, registry): Link Here
188
    finder = UnpackFinder(source)
185
    finder = UnpackFinder(source)
189
    packager = SimplePackager(FlatFormatter(registry))
186
    packager = SimplePackager(FlatFormatter(registry))
190
    for p, f in finder.find('*'):
187
    for p, f in finder.find('*'):
191
        if mozpath.split(p)[0] not in STARTUP_CACHE_PATHS:
188
        packager.add(p, f)
192
            packager.add(p, f)
193
    packager.close()
189
    packager.close()
194
190
195
191
(-)a/python/mozbuild/mozpack/test/test_packager_formats.py (-2 lines)
Lines 408-415 class TestFormatters(unittest.TestCase): Link Here
408
            self.assertTrue(is_resource(base, 'greprefs.js'))
408
            self.assertTrue(is_resource(base, 'greprefs.js'))
409
            self.assertTrue(is_resource(base, 'hyphenation/foo'))
409
            self.assertTrue(is_resource(base, 'hyphenation/foo'))
410
            self.assertTrue(is_resource(base, 'update.locale'))
410
            self.assertTrue(is_resource(base, 'update.locale'))
411
            self.assertTrue(
412
                is_resource(base, 'jsloader/resource/gre/modules/foo.jsm'))
413
            self.assertFalse(is_resource(base, 'foo'))
411
            self.assertFalse(is_resource(base, 'foo'))
414
            self.assertFalse(is_resource(base, 'foo/bar/greprefs.js'))
412
            self.assertFalse(is_resource(base, 'foo/bar/greprefs.js'))
415
            self.assertTrue(is_resource(base, 'defaults/messenger/foo.dat'))
413
            self.assertTrue(is_resource(base, 'defaults/messenger/foo.dat'))
(-)a/toolkit/mozapps/installer/packager.py (-74 lines)
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

Return to bug 600676