Bug 1384241 - Review comment: Make faster make backend write one manifest. r=gps
This is how I interpreted your comment, "This feels like a layering
violation." To avoid this, I made the faster make backend participate
directly. Does this address your concern?
There's a natural follow-on that I haven't time to explore right now:
I want the faster make backend to also write a "unified chrome
manifest" that maps outputs
(browser/chrome/browser/content/browser/ext-utils.js) to chrome:// or
resource:// URLs (chrome://content/browser/ext-utils.js or similar).
MozReview-Commit-ID: LDQmm8KD57I
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -148,18 +148,29 @@ class FasterMakeBackend(CommonBackend, P
# 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')
+ unified_manifest = InstallManifest()
for base, install_manifest in self._install_manifests.iteritems():
+ if base.startswith('dist/bin'):
+ unified_manifest.add_entries_from(install_manifest,
+ base=mozpath.relpath(base, 'dist/bin'))
+
with self._write_file(
mozpath.join(self.environment.topobjdir, 'faster',
'install_%s' % base.replace('/', '_'))) as fh:
install_manifest.write(fileobj=fh)
+ # Write a single unified manifest for consumption by |mach watch|.
+ with self._write_file(
+ mozpath.join(self.environment.topobjdir, 'faster',
+ 'unified_install_dist_bin')) as fh:
+ unified_manifest.write(fileobj=fh)
+
with self._write_file(
mozpath.join(self.environment.topobjdir, 'faster',
'Makefile')) as fh:
mk.dump(fh, removal_guard=False)
--- a/python/mozbuild/mozbuild/faster_daemon.py
+++ b/python/mozbuild/mozbuild/faster_daemon.py
@@ -85,27 +85,21 @@ class Daemon(object):
'browser', 'locales', 'en-US', 'profile'),
})
return defines
@mozbuild.util.memoized_property
def file_copier(self):
file_copier = FileCopier()
- finder = FileFinder(mozpath.join(self.config_environment.topobjdir, 'faster'))
- for path, f in finder.find('*.track'):
- manifest = InstallManifest(fileobj=f.open())
+ unified_manifest = InstallManifest(
+ mozpath.join(self.config_environment.topobjdir,
+ 'faster', 'unified_install_dist_bin'))
- # Turn 'install_dist_bin_browser.track' into ['browser'].
- parts = os.path.basename(os.path.splitext(path)[0]).split('_')
- parts = parts[3:]
-
- subtree = mozpath.join(*parts) if parts else None
- manifest.populate_registry(FileRegistrySubtree(subtree, file_copier),
- defines_override=self.defines)
+ unified_manifest.populate_registry(file_copier, defines_override=self.defines)
return file_copier
def subscribe_to_topsrcdir(self, dir_to_watch):
query = {
'empty_on_fresh_instance': True,
'expression': [
'allof',
--- a/python/mozbuild/mozpack/manifests.py
+++ b/python/mozbuild/mozpack/manifests.py
@@ -324,16 +324,29 @@ class InstallManifest(object):
))
def _add_entry(self, dest, entry):
if dest in self._dests:
raise ValueError('Item already in manifest: %s' % dest)
self._dests[dest] = entry
+ def add_entries_from(self, other, base=''):
+ """
+ Copy data from another mozpack.copier.InstallManifest
+ instance, adding an optional base prefix to the destination.
+
+ This allows to merge two manifests into a single manifest, or
+ two take the tagged union of two manifests.
+ """
+ for dest, entry in other._dests.iteritems():
+ if base:
+ dest = mozpath.join(base, dest)
+ self._add_entry(dest, entry)
+
def populate_registry(self, registry, defines_override={}):
"""Populate a mozpack.copier.FileRegistry instance with data from us.
The caller supplied a FileRegistry instance (or at least something that
conforms to its interface) and that instance is populated with data
from this manifest.
Defines can be given to override the ones in the manifest for