mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1210687 - Use install manifests for jar.mn files in FasterMake backend. r=gps
This commit is contained in:
parent
563b4fd669
commit
8c874fbbbf
@ -27,10 +27,6 @@
|
||||
# - PYTHON, the path to the python executable
|
||||
# - ACDEFINES, which contains a set of -Dvar=name to be used during
|
||||
# preprocessing
|
||||
# - MOZ_CHROME_FILE_FORMAT, which defines whether to use file copies or
|
||||
# symbolic links
|
||||
# - JAR_MN_TARGETS, which defines the targets to use for jar manifest
|
||||
# processing, see further below
|
||||
# - INSTALL_MANIFESTS, which defines the list of base directories handled
|
||||
# by install manifests, see further below
|
||||
# - MANIFEST_TARGETS, which defines the file paths of chrome manifests, see
|
||||
@ -42,7 +38,6 @@
|
||||
|
||||
# Targets to be triggered for a default build
|
||||
default: $(addprefix install-,$(INSTALL_MANIFESTS))
|
||||
default: $(addprefix jar-,$(JAR_MN_TARGETS))
|
||||
|
||||
# Explicit files to be built for a default build
|
||||
default: $(addprefix $(TOPOBJDIR)/,$(MANIFEST_TARGETS))
|
||||
@ -101,52 +96,6 @@ $(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/config/build
|
||||
$(MOZ_DEBUG_DEFINES) \
|
||||
install_$(subst /,_,$*)
|
||||
|
||||
# Install files from jar manifests. Ideally, they would be using install
|
||||
# manifests, but the code to read jar manifests and emit appropriate
|
||||
# install manifests is not there yet.
|
||||
# Things missing:
|
||||
# - DEFINES from config/config.mk
|
||||
# - L10N
|
||||
# - -e when USE_EXTENSION_MANIFEST is set in moz.build
|
||||
#
|
||||
# The list given in JAR_MN_TARGETS corresponds to the list of `jar-%` targets
|
||||
# to be processed, with the `jar-` prefix stripped.
|
||||
# The Makefile is expected to specify the source jar manifest as a dependency
|
||||
# to each target. There is no expectation that the `jar-%` target name matches
|
||||
# the source file name in any way. For example:
|
||||
# JAR_MN_TARGETS = foo
|
||||
# jar-foo: /path/to/some/jar.mn
|
||||
# Additionally, extra defines can be specified for the processing of the jar
|
||||
# manifest by settig the `defines` variable specifically for the given target.
|
||||
# For example:
|
||||
# jar-foo: defines = -Dqux=foo
|
||||
# The default base path where files are going to be installed is `dist/bin`.
|
||||
# It is possible to use a different path by setting the `install_target`
|
||||
# variable. For example:
|
||||
# jar-foo: install_target = dist/bin/foo
|
||||
# When processing jar manifests, relative paths given inside a jar manifest
|
||||
# can be resolved from an object directory. The default path for that object
|
||||
# directory is the translation of the jar manifest directory path from the
|
||||
# source directory to the object directory. That is, for
|
||||
# $(TOPSRCDIR)/path/to/jar.mn, the default would be $(TOPOBJDIR)/path/to.
|
||||
# In case a different path must be used for the object directory, the `objdir`
|
||||
# variable can be set. For example:
|
||||
# jar-foo: objdir=/some/other/path
|
||||
jar-%: objdir ?= $(dir $(patsubst $(TOPSRCDIR)%,$(TOPOBJDIR)%,$<))
|
||||
jar-%: install_target ?= dist/bin
|
||||
jar-%:
|
||||
cd $(objdir) && \
|
||||
$(PYTHON) -m mozbuild.action.jar_maker \
|
||||
-j $(TOPOBJDIR)/$(install_target)/chrome \
|
||||
-t $(TOPSRCDIR) \
|
||||
-f $(MOZ_CHROME_FILE_FORMAT) \
|
||||
-c $(dir $<)/en-US \
|
||||
-DAB_CD=en-US \
|
||||
$(defines) \
|
||||
$(ACDEFINES) \
|
||||
$(MOZ_DEBUG_DEFINES) \
|
||||
$<
|
||||
|
||||
# Create some chrome manifests
|
||||
# This rule is forced to run every time because it may be updating files that
|
||||
# already exit.
|
||||
@ -165,13 +114,6 @@ $(addprefix $(TOPOBJDIR)/,$(MANIFEST_TARGETS)): FORCE
|
||||
# Below is a set of additional dependencies and variables used to build things
|
||||
# that are not supported by data in moz.build.
|
||||
|
||||
# GENERATED_FILES are not supported yet, and even if they were, the
|
||||
# dependencies are missing information.
|
||||
$(foreach p,linux osx windows,jar-browser-themes-$(p)-jar.mn): \
|
||||
jar-browser-themes-%-jar.mn: \
|
||||
$(TOPOBJDIR)/browser/themes/%/tab-selected-end.svg \
|
||||
$(TOPOBJDIR)/browser/themes/%/tab-selected-start.svg
|
||||
|
||||
# Files to build with the recursive backend and simply copy
|
||||
$(TOPOBJDIR)/dist/bin/greprefs.js: $(TOPOBJDIR)/modules/libpref/greprefs.js
|
||||
$(TOPOBJDIR)/dist/bin/platform.ini: $(TOPOBJDIR)/toolkit/xre/platform.ini
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
|
||||
from mozbuild.backend.common import CommonBackend
|
||||
from mozbuild.frontend.data import (
|
||||
@ -16,12 +16,29 @@ from mozbuild.frontend.data import (
|
||||
Resources,
|
||||
VariablePassthru,
|
||||
)
|
||||
from mozbuild.jar import JarManifestParser
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozbuild.preprocessor import Preprocessor
|
||||
from mozbuild.util import OrderedDefaultDict
|
||||
from mozpack.manifests import InstallManifest
|
||||
import mozpack.path as mozpath
|
||||
from collections import OrderedDict
|
||||
from itertools import chain
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class OverwriteInstallManifest(InstallManifest):
|
||||
def _add_entry(self, dest, entry):
|
||||
# Because of bug 1210703, we can't let the default behavior of
|
||||
# InstallManifest._add_entry, which is to error out.
|
||||
# To match the current behavior of the recursive make libs tier, we
|
||||
# keep the last one given, but still warn about it.
|
||||
if dest in self._dests:
|
||||
print('Warning: Item already in manifest: %s' % dest,
|
||||
file=sys.stderr)
|
||||
|
||||
self._dests[dest] = entry
|
||||
|
||||
|
||||
class FasterMakeBackend(CommonBackend):
|
||||
@ -30,17 +47,19 @@ class FasterMakeBackend(CommonBackend):
|
||||
|
||||
self._seen_directories = set()
|
||||
self._defines = dict()
|
||||
self._jar_manifests = OrderedDict()
|
||||
|
||||
self._manifest_entries = OrderedDefaultDict(list)
|
||||
|
||||
self._install_manifests = OrderedDefaultDict(InstallManifest)
|
||||
self._install_manifests = OrderedDefaultDict(OverwriteInstallManifest)
|
||||
|
||||
def _add_preprocess(self, obj, path, dest, **kwargs):
|
||||
target = mozpath.basename(path)
|
||||
# This matches what PP_TARGETS do in config/rules.
|
||||
if target.endswith('.in'):
|
||||
target = target[:-3]
|
||||
self._dependencies = OrderedDefaultDict(list)
|
||||
|
||||
def _add_preprocess(self, obj, path, dest, target=None, **kwargs):
|
||||
if target is None:
|
||||
target = mozpath.basename(path)
|
||||
# This matches what PP_TARGETS do in config/rules.
|
||||
if target.endswith('.in'):
|
||||
target = target[:-3]
|
||||
depfile = mozpath.join(
|
||||
self.environment.topobjdir, 'faster', '.deps',
|
||||
mozpath.join(obj.install_target, dest, target).replace('/', '_'))
|
||||
@ -66,12 +85,7 @@ class FasterMakeBackend(CommonBackend):
|
||||
|
||||
elif isinstance(obj, JARManifest) and \
|
||||
obj.install_target.startswith('dist/bin'):
|
||||
defines = self._defines.get(obj.objdir, [])
|
||||
if defines:
|
||||
defines = list(defines.get_defines())
|
||||
self._jar_manifests[obj.path] = (obj.objdir,
|
||||
obj.install_target,
|
||||
defines)
|
||||
self._consume_jar_manifest(obj, defines)
|
||||
|
||||
elif isinstance(obj, VariablePassthru) and \
|
||||
obj.install_target.startswith('dist/bin'):
|
||||
@ -176,6 +190,113 @@ class FasterMakeBackend(CommonBackend):
|
||||
self._seen_directories.add(obj.objdir)
|
||||
return True
|
||||
|
||||
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)
|
||||
|
||||
def consume_finished(self):
|
||||
mk = Makefile()
|
||||
# Add the default rule at the very beginning.
|
||||
@ -187,36 +308,11 @@ class FasterMakeBackend(CommonBackend):
|
||||
for var in (
|
||||
'PYTHON',
|
||||
'ACDEFINES',
|
||||
'MOZ_CHROME_FILE_FORMAT',
|
||||
'MOZ_BUILD_APP',
|
||||
'MOZ_WIDGET_TOOLKIT',
|
||||
):
|
||||
mk.add_statement('%s = %s' % (var, self.environment.substs[var]))
|
||||
|
||||
# Add all necessary information for jar manifest processing
|
||||
jar_mn_targets = []
|
||||
|
||||
for path, (objdir, install_target, defines) in \
|
||||
self._jar_manifests.iteritems():
|
||||
rel_manifest = mozpath.relpath(path, self.environment.topsrcdir)
|
||||
target = rel_manifest.replace('/', '-')
|
||||
assert target not in jar_mn_targets
|
||||
jar_mn_targets.append(target)
|
||||
target = 'jar-%s' % target
|
||||
mk.create_rule([target]).add_dependencies([path])
|
||||
if objdir != mozpath.join(self.environment.topobjdir,
|
||||
mozpath.dirname(rel_manifest)):
|
||||
mk.create_rule([target]).add_dependencies(
|
||||
['objdir = %s' % objdir])
|
||||
if install_target != 'dist/bin':
|
||||
mk.create_rule([target]).add_dependencies(
|
||||
['install_target = %s' % install_target])
|
||||
if defines:
|
||||
mk.create_rule([target]).add_dependencies(
|
||||
['defines = %s' % ' '.join(defines)])
|
||||
|
||||
mk.add_statement('JAR_MN_TARGETS = %s' % ' '.join(jar_mn_targets))
|
||||
|
||||
# Add information for chrome manifest generation
|
||||
manifest_targets = []
|
||||
|
||||
@ -232,6 +328,11 @@ class FasterMakeBackend(CommonBackend):
|
||||
mk.add_statement('INSTALL_MANIFESTS = %s'
|
||||
% ' '.join(self._install_manifests.keys()))
|
||||
|
||||
# Add dependencies we infered:
|
||||
for target, deps in self._dependencies.iteritems():
|
||||
mk.create_rule([target]).add_dependencies(
|
||||
'$(TOPOBJDIR)/%s' % d for d in deps)
|
||||
|
||||
mk.add_statement('include $(TOPSRCDIR)/config/faster/rules.mk')
|
||||
|
||||
for base, install_manifest in self._install_manifests.iteritems():
|
||||
|
Loading…
Reference in New Issue
Block a user