def _consume_jar_manifest(self, obj): # Ideally, this would all be handled somehow in the emitter, but # this would require all the magic surrounding l10n and addons in # the recursive make backend to die, which is not going to happen # any time soon enough. # Notably missing: # - DEFINES from config/config.mk # - L10n support # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in # moz.build, but it doesn't matter in dist/bin. pp = Preprocessor() if obj.defines: pp.context.update(obj.defines.defines) pp.context.update(self.environment.defines) pp.context.update( AB_CD='en-US', BUILD_FASTER=1, ) pp.out = JarManifestParser() try: pp.do_include(obj.path.full_path) except DeprecatedJarManifest as e: raise DeprecatedJarManifest( 'Parsing error while processing %s: %s' % (obj.path.full_path, e.message)) self.backend_input_files |= pp.includes for jarinfo in pp.out: jar_context = Context(allowed_variables=VARIABLES, config=obj._context.config) jar_context.push_source(obj._context.main_path) jar_context.push_source(obj.path.full_path) install_target = obj.install_target if jarinfo.base: install_target = mozpath.normpath( mozpath.join(install_target, jarinfo.base)) jar_context['FINAL_TARGET'] = install_target if obj.defines: jar_context['DEFINES'] = obj.defines.defines files = jar_context['FINAL_TARGET_FILES'] files_pp = jar_context['FINAL_TARGET_PP_FILES'] for e in jarinfo.entries: if e.is_locale: if jarinfo.relativesrcdir: src = '/%s' % jarinfo.relativesrcdir else: src = '' src = mozpath.join(src, 'en-US', e.source) else: src = e.source src = Path(jar_context, src) if '*' not in e.source and not os.path.exists(src.full_path): if e.is_locale: raise Exception('%s: Cannot find %s' % (obj.path, e.source)) if e.source.startswith('/'): src = Path(jar_context, '!' + e.source) else: # This actually gets awkward if the jar.mn is not # in the same directory as the moz.build declaring # it, but it's how it works in the recursive make, # not that anything relies on that, but it's simpler. src = Path(obj._context, '!' + e.source) output_basename = mozpath.basename(e.output) if output_basename != src.target_basename: src = RenamedSourcePath(jar_context, (src, output_basename)) path = mozpath.dirname(mozpath.join(jarinfo.name, e.output)) if e.preprocess: if '*' in e.source: raise Exception('%s: Wildcards are not supported with ' 'preprocessing' % obj.path) files_pp[path] += [src] else: files[path] += [src] if files: self.consume_object(FinalTargetFiles(jar_context, files)) if files_pp: self.consume_object( FinalTargetPreprocessedFiles(jar_context, files_pp)) for m in jarinfo.chrome_manifests: entry = parse_manifest_line( mozpath.dirname(jarinfo.name), m.replace('%', mozpath.basename(jarinfo.name) + '/')) self.consume_object( ChromeManifestEntry(jar_context, '%s.manifest' % jarinfo.name, entry))
def _consume_jar_manifest(self, obj, defines): # Ideally, this would all be handled somehow in the emitter, but # this would require all the magic surrounding l10n and addons in # the recursive make backend to die, which is not going to happen # any time soon enough. # Notably missing: # - DEFINES from config/config.mk # - L10n support # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in # moz.build, but it doesn't matter in dist/bin. pp = Preprocessor() pp.context.update(defines) pp.context.update(self.environment.defines) pp.context.update( AB_CD='en-US', BUILD_FASTER=1, ) pp.out = JarManifestParser() pp.do_include(obj.path) for jarinfo in pp.out: install_target = obj.install_target # Bug 1150417 added some gross hacks, which we don't try to # support generically. Fortunately, the hacks don't define more # than chrome manifest entries, so just assume we don't get # any installation entries. if jarinfo.name.startswith('../'): assert not jarinfo.entries base = mozpath.join('chrome', jarinfo.name) for e in jarinfo.entries: if e.is_locale: src = mozpath.join( jarinfo.relativesrcdir or mozpath.dirname(obj.path), 'en-US', e.source) elif e.source.startswith('/'): src = mozpath.join(self.environment.topsrcdir, e.source[1:]) else: src = mozpath.join(mozpath.dirname(obj.path), e.source) if '*' in e.source: if e.preprocess: raise Exception('%s: Wildcards are not supported with ' 'preprocessing' % obj.path) def _prefix(s): for p in s.split('/'): if '*' not in p: yield p + '/' prefix = ''.join(_prefix(src)) self._install_manifests[obj.install_target] \ .add_pattern_symlink( prefix, src[len(prefix):], mozpath.join(base, e.output)) continue if not os.path.exists(src): if e.is_locale: raise Exception( '%s: Cannot find %s' % (obj.path, e.source)) if e.source.startswith('/'): src = mozpath.join(self.environment.topobjdir, e.source[1:]) else: # This actually gets awkward if the jar.mn is not # in the same directory as the moz.build declaring # it, but it's how it works in the recursive make, # not that anything relies on that, but it's simpler. src = mozpath.join(obj.objdir, e.source) self._dependencies['install-%s' % obj.install_target] \ .append(mozpath.relpath( src, self.environment.topobjdir)) if e.preprocess: kwargs = {} if src.endswith('.css'): kwargs['marker'] = '%' self._add_preprocess( obj, src, mozpath.join(base, mozpath.dirname(e.output)), mozpath.basename(e.output), defines=defines, **kwargs) else: self._install_manifests[obj.install_target].add_symlink( src, mozpath.join(base, e.output)) manifest = mozpath.normpath(mozpath.join(obj.install_target, base)) manifest += '.manifest' for m in jarinfo.chrome_manifests: self._manifest_entries[manifest].append( m.replace('%', jarinfo.name + '/')) # ../ special cased for bug 1150417 again. if not jarinfo.name.startswith('../'): manifest = mozpath.normpath(mozpath.join(obj.install_target, 'chrome.manifest')) entry = 'manifest %s.manifest' % base if entry not in self._manifest_entries[manifest]: self._manifest_entries[manifest].append(entry)