Bug 900569 - Support writing install manifests from recursivemake backend; r=glandium

This commit is contained in:
Gregory Szorc 2013-08-01 17:42:47 -07:00
Родитель 506982a7d0
Коммит 97d35e6062
2 изменённых файлов: 37 добавлений и 16 удалений

Просмотреть файл

@ -11,7 +11,10 @@ import types
import mozpack.path
from mozpack.copier import FilePurger
from mozpack.manifests import PurgeManifest
from mozpack.manifests import (
InstallManifest,
PurgeManifest,
)
from .base import BuildBackend
from ..frontend.data import (
@ -133,6 +136,8 @@ class RecursiveMakeBackend(BuildBackend):
self.backend_input_files.add(os.path.join(self.environment.topobjdir,
'config', 'autoconf.mk'))
self._install_manifests = dict()
self._purge_manifests = dict(
dist_bin=PurgeManifest(relpath='dist/bin'),
dist_include=PurgeManifest(relpath='dist/include'),
@ -292,7 +297,8 @@ class RecursiveMakeBackend(BuildBackend):
self._update_from_avoid_write(mastermanifest.close())
self.summary.managed_count += 1
self._write_purge_manifests()
self._write_manifests('install', self._install_manifests)
self._write_manifests('purge', self._purge_manifests)
def _process_directory_traversal(self, obj, backend_file):
"""Process a data.DirectoryTraversal instance."""
@ -370,21 +376,15 @@ class RecursiveMakeBackend(BuildBackend):
manifest = '%s/%s' % (obj.relativedir, manifest)
self.xpcshell_manifests.append(manifest)
def _write_purge_manifests(self):
# We write out a "manifest" file for each directory that is to be
# purged.
#
# Ideally we have as few manifests as possible - ideally only 1. This
# will likely require all build metadata to be in emitted objects.
# We're not quite there yet, so we maintain multiple manifests.
def _write_manifests(self, dest, manifests):
man_dir = os.path.join(self.environment.topobjdir, '_build_manifests',
'purge')
dest)
# We have a purger for the manifests themselves to ensure we don't over
# purge if we delete a purge manifest.
# We have a purger for the manifests themselves to ensure legacy
# manifests are deleted.
purger = FilePurger()
for k, manifest in self._purge_manifests.items():
for k, manifest in manifests.items():
purger.add(k)
fh = FileAvoidWrite(os.path.join(man_dir, k))

Просмотреть файл

@ -5,12 +5,13 @@
from __future__ import unicode_literals
import os
import time
from mozpack.manifests import PurgeManifest
from mozpack.manifests import (
InstallManifest,
PurgeManifest,
)
from mozunit import main
from mozbuild.backend.configenvironment import ConfigEnvironment
from mozbuild.backend.recursivemake import RecursiveMakeBackend
from mozbuild.frontend.emitter import TreeMetadataEmitter
from mozbuild.frontend.reader import BuildReader
@ -320,6 +321,26 @@ class TestRecursiveMakeBackend(BackendTester):
self._consume('stub0', RecursiveMakeBackend, env)
self.assertFalse(os.path.exists(manifest_path))
def test_install_manifests_written(self):
env, objs = self._emit('stub0')
backend = RecursiveMakeBackend(env)
m = InstallManifest()
backend._install_manifests['testing'] = m
m.add_symlink(__file__, 'self')
backend.consume(objs)
man_dir = os.path.join(env.topobjdir, '_build_manifests', 'install')
self.assertTrue(os.path.isdir(man_dir))
expected = ['testing']
for e in expected:
full = os.path.join(man_dir, e)
self.assertTrue(os.path.exists(full))
m2 = InstallManifest(path=full)
self.assertEqual(m, m2)
def test_ipdl_sources(self):
"""Test that IPDL_SOURCES are written to ipdlsrcs.mk correctly."""
env = self._consume('ipdl_sources', RecursiveMakeBackend)