From 6098e02a36aacca7e31dacb26fe42090f372b253 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 22 Jan 2016 11:13:26 +0900 Subject: [PATCH] Bug 1239217 - Add the FasterMake+RecursiveMake hybrid backend. r=gps --- Makefile.in | 24 +++++++++++++++++- config/faster/rules.mk | 7 +++++- python/mozbuild/mozbuild/backend/__init__.py | 6 +++++ .../mozbuild/mozbuild/backend/fastermake.py | 4 ++- .../mozbuild/test/backend/test_build.py | 25 +++++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index b1baf4417a3d..e33f9c505b18 100644 --- a/Makefile.in +++ b/Makefile.in @@ -123,9 +123,16 @@ default:: $(BUILD_BACKEND_FILES) endif install_manifests := \ - $(addprefix dist/,bin branding idl include public private sdk xpi-stage) \ + $(addprefix dist/,branding idl include public private sdk xpi-stage) \ _tests \ $(NULL) +# Skip the dist/bin install manifest when using the hybrid +# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves +# xpidl handling to FasterMake in that case, mechanically making the dist/bin +# install manifest non-existent (non-existent manifests being skipped) +ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) +install_manifests += dist/bin +endif install_manifest_depends = \ CLOBBER \ $(configure_dir)/configure \ @@ -145,6 +152,15 @@ endif .PHONY: install-manifests install-manifests: $(addprefix install-,$(install_manifests)) +# If we're using the hybrid FasterMake/RecursiveMake backend, we want +# to recurse in the faster/ directory in parallel of install manifests. +ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) +install-manifests: faster +.PHONY: faster +faster: + $(MAKE) -C faster FASTER_RECURSIVE_MAKE=1 +endif + # process_install_manifest needs to be invoked with --no-remove when building # js as standalone because automated builds are building nspr separately and # that would remove the resulting files. @@ -156,6 +172,12 @@ endif .PHONY: $(addprefix install-,$(subst /,_,$(install_manifests))) $(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends) +ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) + @# If we're using the hybrid FasterMake/RecursiveMake backend, we want + @# to ensure the FasterMake end doesn't have install manifests for the + @# same directory, because that would blow up + $(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*))) +endif $(addprefix $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$*) ,$(wildcard _build_manifests/install/$(subst /,_,$*))) # Dummy wrapper rule to allow the faster backend to piggy back diff --git a/config/faster/rules.mk b/config/faster/rules.mk index e61434154ccf..446ce1832beb 100644 --- a/config/faster/rules.mk +++ b/config/faster/rules.mk @@ -47,14 +47,19 @@ ifndef NO_XPIDL default: $(TOPOBJDIR)/config/makefiles/xpidl/xpidl endif -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) # Mac builds require to copy things in dist/bin/*.app # TODO: remove the MOZ_WIDGET_TOOLKIT and MOZ_BUILD_APP variables from # faster/Makefile and python/mozbuild/mozbuild/test/backend/test_build.py # when this is not required anymore. +# We however don't need to do this when using the hybrid +# FasterMake/RecursiveMake backend (FASTER_RECURSIVE_MAKE is set when +# recursing from the RecursiveMake backend) +ifndef FASTER_RECURSIVE_MAKE +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) default: $(MAKE) -C $(TOPOBJDIR)/$(MOZ_BUILD_APP)/app repackage endif +endif .PHONY: FORCE diff --git a/python/mozbuild/mozbuild/backend/__init__.py b/python/mozbuild/mozbuild/backend/__init__.py index 7e3bc61e1e8c..331bc9fca86e 100644 --- a/python/mozbuild/mozbuild/backend/__init__.py +++ b/python/mozbuild/mozbuild/backend/__init__.py @@ -8,12 +8,18 @@ backends = { 'CompileDB': 'mozbuild.compilation.database', 'CppEclipse': 'mozbuild.backend.cpp_eclipse', 'FasterMake': 'mozbuild.backend.fastermake', + 'FasterMake+RecursiveMake': None, 'RecursiveMake': 'mozbuild.backend.recursivemake', 'VisualStudio': 'mozbuild.backend.visualstudio', } def get_backend_class(name): + if '+' in name: + from mozbuild.backend.base import HybridBackend + return HybridBackend(*(get_backend_class(name) + for name in name.split('+'))) + class_name = '%sBackend' % name module = __import__(backends[name], globals(), locals(), [class_name]) return getattr(module, class_name) diff --git a/python/mozbuild/mozbuild/backend/fastermake.py b/python/mozbuild/mozbuild/backend/fastermake.py index eef23b4bd9bf..d55928e8c7eb 100644 --- a/python/mozbuild/mozbuild/backend/fastermake.py +++ b/python/mozbuild/mozbuild/backend/fastermake.py @@ -126,7 +126,9 @@ class FasterMakeBackend(CommonBackend, PartialBackend): 'MOZ_BUILD_APP', 'MOZ_WIDGET_TOOLKIT', ): - mk.add_statement('%s = %s' % (var, self.environment.substs[var])) + value = self.environment.substs.get(var) + if value is not None: + mk.add_statement('%s = %s' % (var, value)) install_manifests_bases = self._install_manifests.keys() diff --git a/python/mozbuild/mozbuild/test/backend/test_build.py b/python/mozbuild/mozbuild/test/backend/test_build.py index 2fa47bcc3845..d6111d85f73f 100644 --- a/python/mozbuild/mozbuild/test/backend/test_build.py +++ b/python/mozbuild/mozbuild/test/backend/test_build.py @@ -12,6 +12,7 @@ import unittest import mozpack.path as mozpath from contextlib import contextmanager from mozunit import main +from mozbuild.backend import get_backend_class from mozbuild.backend.configenvironment import ConfigEnvironment from mozbuild.backend.recursivemake import RecursiveMakeBackend from mozbuild.backend.fastermake import FasterMakeBackend @@ -92,6 +93,30 @@ class TestBuild(unittest.TestCase): self.validate(config) + def test_faster_recursive_make(self): + substs = list(BASE_SUBSTS) + [ + ('BUILD_BACKENDS', 'FasterMake+RecursiveMake'), + ] + with self.do_test_backend(get_backend_class( + 'FasterMake+RecursiveMake'), substs=substs) as config: + buildid = mozpath.join(config.topobjdir, 'config', 'buildid') + ensureParentDir(buildid) + with open(buildid, 'w') as fh: + fh.write('20100101012345\n') + + build = MozbuildObject(config.topsrcdir, None, None, + config.topobjdir) + overrides = [ + 'install_manifest_depends=', + 'MOZ_CHROME_FILE_FORMAT=flat', + 'TEST_MOZBUILD=1', + ] + with self.line_handler() as handle_make_line: + build._run_make(directory=config.topobjdir, target=overrides, + silent=False, line_handler=handle_make_line) + + self.validate(config) + def test_faster_make(self): substs = list(BASE_SUBSTS) + [ ('MOZ_BUILD_APP', 'dummy_app'),