Bug 1210642 - Use install manifests for preprocessed files in the FasterMake build backend. r=gps

This commit is contained in:
Mike Hommey 2015-10-01 17:10:08 +09:00
parent 070700d726
commit c5e63a76f9
2 changed files with 39 additions and 79 deletions

View File

@ -31,8 +31,6 @@
# symbolic links
# - JAR_MN_TARGETS, which defines the targets to use for jar manifest
# processing, see further below
# - PP_TARGETS, which defines the file paths of preprocessed files, 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
@ -47,7 +45,6 @@ default: $(addprefix install-,$(INSTALL_MANIFESTS))
default: $(addprefix jar-,$(JAR_MN_TARGETS))
# Explicit files to be built for a default build
default: $(addprefix $(TOPOBJDIR)/,$(PP_TARGETS))
default: $(addprefix $(TOPOBJDIR)/,$(MANIFEST_TARGETS))
default: $(TOPOBJDIR)/dist/bin/greprefs.js
default: $(TOPOBJDIR)/dist/bin/platform.ini
@ -83,42 +80,20 @@ $(TOPOBJDIR)/dist/%:
# corresponding install manifests are named correspondingly, with forward
# slashes replaced with underscores, and prefixed with `install_`. That is,
# the install manifest for `dist/bin` would be `install_dist_bin`.
$(addprefix install-,$(INSTALL_MANIFESTS)): install-%:
$(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(TOPOBJDIR)/config/buildid
@# For now, force preprocessed files to be reprocessed every time.
@# The overhead is not that big, and this avoids waiting for proper
@# support for defines tracking in process_install_manifest.
@touch install_$(subst /,_,$*)
$(PYTHON) -m mozbuild.action.process_install_manifest \
--no-remove \
--no-remove-empty-directories \
$(TOPOBJDIR)/$* \
install_$(subst /,_,$*)
# Preprocessed files. Ideally they would be using install manifests but
# right now, it's not possible because of things like MOZ_APP_BUILDID or
# nsURLFormatter.js.
#
# The list of preprocessed files is defined in PP_TARGETS. The list is
# relative to TOPOBJDIR.
# The source file for each of those preprocessed files is defined as a Make
# dependency for the $(TOPOBJDIR)/path target. For example:
# PP_TARGETS = foo/bar
# $(TOPOBJDIR)/foo/bar: /path/to/source/for/foo/bar.in
# The file name for the source doesn't need to be different.
# Additionally, extra defines can be specified for a given preprocessing
# by setting the `defines` variable specifically for the given target.
# For example:
# $(TOPOBJDIR)/foo/bar: defines = -Dqux=foobar
$(addprefix $(TOPOBJDIR)/,$(PP_TARGETS)): Makefile
$(addprefix $(TOPOBJDIR)/,$(PP_TARGETS)): $(TOPOBJDIR)/%:
$(PYTHON) -m mozbuild.action.preprocessor \
--depend $(TOPOBJDIR)/faster/.deps/$(subst /,_,$*) \
-DAB_CD=en-US \
$(defines) \
-DMOZ_APP_BUILDID=$(shell cat $(TOPOBJDIR)/config/buildid) \
$(ACDEFINES) \
$(MOZ_DEBUG_DEFINES) \
$< \
-o $@
# Include the dependency files from the above preprocessed files rule.
$(foreach pp_target,$(PP_TARGETS), \
$(eval -include $(TOPOBJDIR)/faster/.deps/$(subst /,_,$(pp_target))))
install_$(subst /,_,$*)
# Install files from jar manifests. Ideally, they would be using install
# manifests, but the code to read jar manifests and emit appropriate
@ -191,11 +166,6 @@ jar-browser-themes-%-jar.mn: \
$(TOPOBJDIR)/browser/themes/%/tab-selected-end.svg \
$(TOPOBJDIR)/browser/themes/%/tab-selected-start.svg
# Extra dependencies and/or definitions for preprocessed files.
$(TOPOBJDIR)/dist/bin/application.ini: $(TOPOBJDIR)/config/buildid
$(TOPOBJDIR)/dist/bin/application.ini: defines += \
-DMOZ_APP_BUILDID=$(shell cat $(TOPOBJDIR)/config/buildid)
# 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

View File

@ -32,17 +32,29 @@ class FasterMakeBackend(CommonBackend):
self._defines = dict()
self._jar_manifests = OrderedDict()
self._preprocess_files = OrderedDict()
self._manifest_entries = OrderedDefaultDict(list)
self._install_manifests = OrderedDefaultDict(InstallManifest)
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]
depfile = mozpath.join(
self.environment.topobjdir, 'faster', '.deps',
mozpath.join(obj.install_target, dest, target).replace('/', '_'))
self._install_manifests[obj.install_target].add_preprocess(
mozpath.join(obj.srcdir, path),
mozpath.join(dest, target),
depfile,
**kwargs)
def consume_object(self, obj):
if not isinstance(obj, Defines) and isinstance(obj, ContextDerived):
defines = self._defines.get(obj.objdir, [])
defines = self._defines.get(obj.objdir, {})
if defines:
defines = list(defines.get_defines())
defines = defines.defines
if isinstance(obj, Defines):
self._defines[obj.objdir] = obj
@ -54,6 +66,9 @@ 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)
@ -74,9 +89,8 @@ class FasterMakeBackend(CommonBackend):
'manifest components/%s' % mozpath.basename(f))
for f in obj.variables.get('EXTRA_PP_COMPONENTS', {}):
path = mozpath.join(obj.install_target, 'components',
mozpath.basename(f))
self._preprocess_files[path] = (obj.srcdir, f, defines)
self._add_preprocess(obj, f, 'components', defines=defines)
if f.endswith('.manifest'):
manifest = mozpath.join(obj.install_target,
'chrome.manifest')
@ -86,16 +100,15 @@ class FasterMakeBackend(CommonBackend):
elif isinstance(obj, JavaScriptModules) and \
obj.install_target.startswith('dist/bin'):
for path, strings in obj.modules.walk():
base = mozpath.join(obj.install_target, 'modules', path)
base = mozpath.join('modules', path)
for f in strings:
if obj.flavor == 'extra':
self._install_manifests[obj.install_target].add_symlink(
mozpath.join(obj.srcdir, f),
mozpath.join('modules', path, mozpath.basename(f))
mozpath.join(base, mozpath.basename(f))
)
elif obj.flavor == 'extra_pp':
dest = mozpath.join(base, mozpath.basename(f))
self._preprocess_files[dest] = (obj.srcdir, f, defines)
self._add_preprocess(obj, f, base, defines=defines)
elif isinstance(obj, JsPreferenceFile) and \
obj.install_target.startswith('dist/bin'):
@ -119,25 +132,22 @@ class FasterMakeBackend(CommonBackend):
mozpath.basename(obj.path))
# We preprocess these, but they don't necessarily have preprocessor
# directives, so tell the preprocessor to not complain about that.
defines.append('--silence-missing-directive-warnings')
self._preprocess_files[dest] = (obj.srcdir, obj.path, defines)
self._add_preprocess(obj, obj.path, pref_dir, defines=defines,
silence_missing_directive_warnings=True)
elif isinstance(obj, Resources) and \
obj.install_target.startswith('dist/bin'):
for path, strings in obj.resources.walk():
base = mozpath.join(obj.install_target, 'res', path)
base = mozpath.join('res', path)
for f in strings:
flags = strings.flags_for(f)
if flags and flags.preprocess:
dest = mozpath.join(base, mozpath.basename(f))
defines = Defines(obj._context, obj.defines)
defines = list(defines.get_defines())
defines.extend(['--marker', '%'])
self._preprocess_files[dest] = (obj.srcdir, f, defines)
self._add_preprocess(obj, f, base, marker='%',
defines=obj.defines)
else:
self._install_manifests[obj.install_target].add_symlink(
mozpath.join(obj.srcdir, f),
mozpath.join('res', path, mozpath.basename(f))
mozpath.join(base, mozpath.basename(f))
)
elif isinstance(obj, FinalTargetFiles) and \
@ -154,10 +164,9 @@ class FasterMakeBackend(CommonBackend):
obj.install_target.startswith('dist/bin'):
# We preprocess these, but they don't necessarily have preprocessor
# directives, so tell the preprocessor to not complain about that.
defines.append('--silence-missing-directive-warnings')
for f in obj.files:
dest = mozpath.join(obj.install_target, mozpath.basename(f))
self._preprocess_files[dest] = (obj.srcdir, f, defines)
self._add_preprocess(obj, f, '', defines=defines,
silence_missing_directive_warnings=True)
else:
# We currently ignore a lot of object types, so just acknowledge
@ -217,25 +226,6 @@ class FasterMakeBackend(CommonBackend):
mk.add_statement('MANIFEST_TARGETS = %s' % ' '.join(manifest_targets))
# Add information for preprocessed files.
preprocess_targets = []
for target, (srcdir, f, defines) in self._preprocess_files.iteritems():
# This matches what PP_TARGETS do in config/rules.
if target.endswith('.in'):
target = target[:-3]
# PP_TARGETS assumes this is true, but doesn't enforce it.
assert target not in self._preprocess_files
preprocess_targets.append(target)
target = '$(TOPOBJDIR)/%s' % target
mk.create_rule([target]).add_dependencies(
[mozpath.join(srcdir, f)])
if defines:
mk.create_rule([target]).add_dependencies(
['defines = %s' % ' '.join(defines)])
mk.add_statement('PP_TARGETS = %s' % ' '.join(preprocess_targets))
# Add information for install manifests.
mk.add_statement('INSTALL_MANIFESTS = %s'
% ' '.join(self._install_manifests.keys()))