Bug 911375 - Part 2: Convert uses of PurgeManifest to InstallManifest; r=glandium

This commit is contained in:
Gregory Szorc 2013-09-16 17:49:44 -07:00
parent 08a79183b5
commit 6c15858170
3 changed files with 71 additions and 83 deletions

View File

@ -31,32 +31,9 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
.mozconfig.mk
ifndef MOZ_PROFILE_USE
# One of the first things we do in the build is purge "unknown" files
# from the object directory. This serves two purposes:
#
# 1) Remove files from a previous build no longer accounted for in
# this build configuration.
#
# 2) Work around poor build system dependencies by forcing some
# rebuilds.
#
# Ideally #2 does not exist. Our reliance on this aspect should diminish
# over time.
#
# moz.build backend generation simply installs a set of "manifests" into
# a common directory. Each manifest is responsible for defining files in
# a specific subdirectory of the object directory. The invoked Python
# script simply iterates over all the manifests, purging files as
# necessary. To manage new directories or add files to the manifests,
# modify the backend generator.
#
# We need to explicitly put backend.RecursiveMakeBackend.built here
# otherwise the rule in rules.mk doesn't run early enough.
libs export tools:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built
$(call SUBMAKE,backend.RecursiveMakeBackend.built,js/src,1)
export::
$(call py_action,purge_manifests,-d _build_manifests/purge .)
libs export tools:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built js-config-status
endif
CLOBBER: $(topsrcdir)/CLOBBER
@ -79,17 +56,53 @@ config.status: $(topsrcdir)/configure
@echo "but your build might not succeed."
@exit 1
export::
$(RM) -r $(DIST)/sdk
.PHONY: js-config-status
js-config-status:
$(call SUBMAKE,backend.RecursiveMakeBackend.built,js/src,1)
install_manifests := bin idl include public private sdk
install_manifest_depends = \
CLOBBER \
$(topsrcdir)/configure \
config.status \
backend.RecursiveMakeBackend.built \
js-config-status \
$(NULL)
.PHONY: install-manifests
install-manifests: $(addprefix install-dist-,$(install_manifests))
.PHONY: $(addprefix install-dist-,$(install_manifests))
$(addprefix install-dist-,$(install_manifests)): install-dist-%: $(install_manifest_depends)
$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$* js/src/_build_manifests/install/dist_$*)
.PHONY: install-tests
install-manifests: install-tests
install-tests: $(install_manifest_depends)
$(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/tests js/src/_build_manifests/install/tests)
# Windows PGO builds don't perform a clean before the 2nd pass. So, we want
# to preserve content for the 2nd pass on Windows. Everywhere else, we always
# process the install manifests as part of export.
ifdef MOZ_PROFILE_USE
ifndef NO_PROFILE_GUIDED_OPTIMIZE
ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
export:: install-manifests
endif
endif
else # !MOZ_PROFILE_USE (normal build)
export:: install-manifests
endif
# For historical reasons that are unknown, $(DIST)/sdk is always blown away
# with no regard for PGO passes. This decision could probably be revisited.
export:: install-dist-sdk
ifdef ENABLE_TESTS
# Additional makefile targets to call automated test suites
include $(topsrcdir)/testing/testsuite-targets.mk
endif
export::
$(call py_action,process_install_manifest,$(DIST)/include _build_manifests/install/dist_include js/src/_build_manifests/install/dist_include)
default all::
$(call BUILDSTATUS,TIERS export compile libs tools)

View File

@ -12,7 +12,6 @@ import types
from mozpack.copier import FilePurger
from mozpack.manifests import (
InstallManifest,
PurgeManifest,
)
import mozpack.path as mozpath
@ -148,19 +147,17 @@ class RecursiveMakeBackend(CommonBackend):
self.backend_input_files.add(os.path.join(self.environment.topobjdir,
'config', 'autoconf.mk'))
self._purge_manifests = dict(
dist_bin=PurgeManifest(relpath='dist/bin'),
dist_private=PurgeManifest(relpath='dist/private'),
dist_public=PurgeManifest(relpath='dist/public'),
dist_sdk=PurgeManifest(relpath='dist/sdk'),
tests=PurgeManifest(relpath='_tests'),
xpidl=PurgeManifest(relpath='config/makefiles/xpidl'),
)
self._install_manifests = dict(
dist_idl=InstallManifest(),
dist_include=InstallManifest(),
)
self._install_manifests = {
k: InstallManifest() for k in [
'dist_bin',
'dist_idl',
'dist_include',
'dist_public',
'dist_private',
'dist_sdk',
'tests',
'xpidl',
]}
def _update_from_avoid_write(self, result):
existed, updated = result
@ -363,7 +360,6 @@ class RecursiveMakeBackend(CommonBackend):
self.summary.managed_count += 1
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."""
@ -432,11 +428,11 @@ class RecursiveMakeBackend(CommonBackend):
namespace=namespace + subdir)
def _handle_idl_manager(self, manager):
build_files = self._purge_manifests['xpidl']
build_files = self._install_manifests['xpidl']
for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done',
'xpt/.mkdir.done'):
build_files.add(p)
build_files.add_optional_exists(p)
for idl in manager.idls.values():
self._install_manifests['dist_idl'].add_symlink(idl['source'],
@ -445,8 +441,10 @@ class RecursiveMakeBackend(CommonBackend):
% idl['root'])
for module in manager.modules:
build_files.add(mozpath.join('xpt', '%s.xpt' % module))
build_files.add(mozpath.join('.deps', '%s.pp' % module))
build_files.add_optional_exists(mozpath.join('xpt',
'%s.xpt' % module))
build_files.add_optional_exists(mozpath.join('.deps',
'%s.pp' % module))
modules = manager.modules
xpt_modules = sorted(modules.keys())
@ -475,7 +473,7 @@ class RecursiveMakeBackend(CommonBackend):
# Create dependency for output header so we force regeneration if the
# header was deleted. This ideally should not be necessary. However,
# some processes (such as PGO at the time this was implemented) wipe
# out dist/include without regard to our install/purge manifests.
# out dist/include without regard to our install manifests.
out_path = os.path.join(self.environment.topobjdir, 'config',
'makefiles', 'xpidl', 'Makefile')

View File

@ -8,7 +8,6 @@ import os
from mozpack.manifests import (
InstallManifest,
PurgeManifest,
)
from mozunit import main
@ -267,22 +266,21 @@ class TestRecursiveMakeBackend(BackendTester):
"""Ensure xpidl files and directories are written out."""
env = self._consume('xpidl', RecursiveMakeBackend)
# Purge manifests should contain entries.
purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge')
# Install manifests should contain entries.
install_dir = os.path.join(env.topobjdir, '_build_manifests',
'install')
self.assertTrue(os.path.isfile(os.path.join(purge_dir, 'xpidl')))
self.assertTrue(os.path.isfile(os.path.join(install_dir, 'dist_idl')))
m = PurgeManifest(path=os.path.join(purge_dir, 'xpidl'))
self.assertIn('.deps/my_module.pp', m.entries)
self.assertIn('xpt/my_module.xpt', m.entries)
self.assertTrue(os.path.isfile(os.path.join(install_dir, 'xpidl')))
m = InstallManifest(path=os.path.join(install_dir, 'dist_idl'))
self.assertEqual(len(m), 2)
self.assertIn('bar.idl', m)
self.assertIn('foo.idl', m)
m = InstallManifest(path=os.path.join(install_dir, 'xpidl'))
self.assertIn('.deps/my_module.pp', m)
self.assertIn('xpt/my_module.xpt', m)
m = InstallManifest(path=os.path.join(install_dir, 'dist_include'))
self.assertIn('foo.h', m)
@ -303,35 +301,14 @@ class TestRecursiveMakeBackend(BackendTester):
'; THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT MODIFY BY HAND.',
''] + ['[include:%s/xpcshell.ini]' % x for x in expected])
def test_purge_manifests_written(self):
env = self._consume('stub0', RecursiveMakeBackend)
purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge')
self.assertTrue(os.path.exists(purge_dir))
expected = [
'dist_bin',
'dist_private',
'dist_public',
'dist_sdk',
'tests',
]
for e in expected:
full = os.path.join(purge_dir, e)
self.assertTrue(os.path.exists(full))
m = PurgeManifest(path=os.path.join(purge_dir, 'dist_bin'))
self.assertEqual(m.relpath, 'dist/bin')
def test_old_purge_manifest_deleted(self):
# Simulate a purge manifest from a previous backend version. Ensure it
# is deleted.
def test_old_install_manifest_deleted(self):
# Simulate an install manifest from a previous backend version. Ensure
# it is deleted.
env = self._get_environment('stub0')
purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'purge')
purge_dir = os.path.join(env.topobjdir, '_build_manifests', 'install')
manifest_path = os.path.join(purge_dir, 'old_manifest')
os.makedirs(purge_dir)
m = PurgeManifest()
m = InstallManifest()
m.write(path=manifest_path)
self.assertTrue(os.path.exists(manifest_path))