Bug 912832 - Inverse tiers and subtiers for build traversal. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 06 Sep 2013 09:17:59 +0900
changeset 158709 9993d1e6185e2f6f61ae296142119930992e62f7
parent 158708 9c78c5ac85a8218b3442c0c9cce52879b5fee84e
child 158710 0c3e37bb0973e094f0c8b364642f6eb43e987171
push idunknown
push userunknown
push dateunknown
reviewersgps
bugs912832
milestone26.0a1
Bug 912832 - Inverse tiers and subtiers for build traversal. r=gps
Makefile.in
config/makefiles/precompile/Makefile.in
config/makefiles/tiers.mk
config/recurse.mk
config/rules.mk
js/src/config/makefiles/tiers.mk
js/src/config/recurse.mk
js/src/config/rules.mk
--- a/Makefile.in
+++ b/Makefile.in
@@ -47,20 +47,20 @@ ifndef MOZ_PROFILE_USE
 # 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.
-default all export libs tools:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built
+libs export tools:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built
 	$(call SUBMAKE,backend.RecursiveMakeBackend.built,js/src,1)
 
-default all export::
+export::
 	$(call py_action,purge_manifests,-d _build_manifests/purge .)
 endif
 
 CLOBBER: $(topsrcdir)/CLOBBER
 	@echo "STOP!  The CLOBBER file has changed."
 	@echo "Please run the build through a sanctioned build wrapper, such as"
 	@echo "'mach build' or client.mk."
 	@exit 1
@@ -74,39 +74,32 @@ CLOBBER: $(topsrcdir)/CLOBBER
 
 config.status: $(topsrcdir)/configure
 	@echo "STOP!  configure has changed and needs to be run in this build directory."
 	@echo "Please rerun configure."
 	@echo "To ignore this message, touch 'config.status' in the build directory,"
 	@echo "but your build might not succeed."
 	@exit 1
 
-default all export::
+export::
 	$(RM) -r $(DIST)/sdk
 
 ifdef ENABLE_TESTS
 # Additional makefile targets to call automated test suites
 include $(topsrcdir)/testing/testsuite-targets.mk
 endif
 
-# Hacky way for precompile tier to bypass default tier traversal mechanism.
-TIER_precompile_CUSTOM := 1
+export::
+	$(call py_action,process_install_manifest,$(DIST)/include _build_manifests/install/dist_include js/src/_build_manifests/install/dist_include)
 
-default all 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 libs tools)
 
 include $(topsrcdir)/config/rules.mk
 
-default all::
-	$(call BUILDSTATUS,TIERS $(TIERS))
-	$(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
-
-include $(topsrcdir)/config/makefiles/tiers.mk
-$(foreach tier,$(TIERS),$(eval $(call CREATE_TIER_RULE,$(tier))))
-
 distclean::
 	$(RM) $(DIST_GARBAGE)
 
 ifeq ($(OS_ARCH),WINNT)
 # we want to copy PDB files on Windows
 MAKE_SYM_STORE_ARGS := -c --vcs-info
 ifdef PDBSTR_PATH
 MAKE_SYM_STORE_ARGS += -i
--- a/config/makefiles/precompile/Makefile.in
+++ b/config/makefiles/precompile/Makefile.in
@@ -2,38 +2,23 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # This make file defines the precompile tier. This tier effectively fans out
 # to other make files and specialized targets.
 
 SUPPRESS_DEFAULT_RULES := 1
 
-include $(topsrcdir)/config/rules.mk
-
-# We don't print the build status messages unless we're in a top level build
-# otherwise the output is unexpected and it confuses downstream parsers.
-define make_subtier_dir
-$(call BUILDSTATUS,SUBTIER_START precompile $(1))
-+$(MAKE) -C $(2) $(3)
-$(call BUILDSTATUS,SUBTIER_FINISH precompile $(1))
-
-endef
-
 default::
-	$(call BUILDSTATUS,TIER_START  precompile IPDL WebIDL XPIDL)
 	+$(MAKE) export
-	$(call BUILDSTATUS,TIER_FINISH precompile)
 
 export:: ipdl webidl xpidl
 
 ipdl:
-	$(call make_subtier_dir,IPDL,$(DEPTH)/ipc/ipdl,ipdl)
+	$(call SUBMAKE,ipdl,$(DEPTH)/ipc/ipdl)
 
 webidl:
-	$(call make_subtier_dir,WebIDL,$(DEPTH)/dom/bindings,webidl)
+	$(call SUBMAKE,webidl,$(DEPTH)/dom/bindings)
 
 xpidl:
-	$(call BUILDSTATUS,SUBTIER_START  precompile XPIDL)
-	+$(MAKE) -C $(DEPTH)/xpcom/idl-parser xpidl-parser
+	$(call SUBMAKE,xpidl-parser,$(DEPTH)/xpcom/idl-parser)
 	$(call py_action,process_install_manifest,$(DIST)/idl $(DEPTH)/_build_manifests/install/dist_idl)
-	+$(MAKE) -C $(DEPTH)/config/makefiles/xpidl xpidl
-	$(call BUILDSTATUS,SUBTIER_FINISH precompile XPIDL)
+	$(call SUBMAKE,xpidl,$(DEPTH)/config/makefiles/xpidl)
deleted file mode 100644
--- a/config/makefiles/tiers.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This file contains logic for tier traversal.
-
-define CREATE_SUBTIER_RULE
-$(2)_tier_$(1):
-	$$(call BUILDSTATUS,SUBTIER_START  $(1) $(2) $$(tier_$(1)_dirs))
-	$$(foreach dir,$$(tier_$(1)_dirs),$$(call TIER_DIR_SUBMAKE,$(1),$(2),$$(dir),$(2)))
-	$$(call BUILDSTATUS,SUBTIER_FINISH $(1) $(2))
-
-endef
-
-# This function is called and evaluated to produce the rule to build the
-# specified tier.
-#
-# Tiers are traditionally composed of directories that are invoked either
-# once (so-called "static" directories) or 3 times with the export, libs, and
-# tools sub-tiers.
-#
-# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
-# tier rules are ignored and each directory in the tier is executed via a
-# sub-make invocation (make -C).
-define CREATE_TIER_RULE
-tier_$(1)::
-ifdef TIER_$(1)_CUSTOM
-	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
-else
-	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
-ifneq (,$(tier_$(1)_staticdirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
-	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
-endif
-ifneq (,$(tier_$(1)_dirs))
-	$$(MAKE) export_$$@
-	$$(MAKE) libs_$$@
-	$$(MAKE) tools_$$@
-endif
-	$(call BUILDSTATUS,TIER_FINISH $(1))
-endif
-
-$(foreach subtier,export libs tools,$(call CREATE_SUBTIER_RULE,$(1),$(subtier)))
-
-endef
--- a/config/recurse.mk
+++ b/config/recurse.mk
@@ -5,16 +5,29 @@
 ifndef INCLUDED_RULES_MK
 include $(topsrcdir)/config/rules.mk
 endif
 
 #########################
 # Tier traversal handling
 #########################
 
+ifdef TIERS
+
+libs export tools::
+	$(call BUILDSTATUS,TIER_START $@ $(filter-out $(if $(filter export,$@),,precompile),$(TIERS)))
+	$(foreach tier,$(TIERS), $(if $(filter-out libs_precompile tools_precompile,$@_$(tier)), \
+		$(call BUILDSTATUS,SUBTIER_START $@ $(tier) $(if $(filter libs,$@),$(tier_$(tier)_staticdirs)) $(tier_$(tier)_dirs)) \
+		$(if $(filter libs,$@),$(foreach dir, $(tier_$(tier)_staticdirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),,1))) \
+		$(foreach dir, $(tier_$(tier)_dirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),$@)) \
+		$(call BUILDSTATUS,SUBTIER_FINISH $@ $(tier))))
+	$(call BUILDSTATUS,TIER_FINISH $@)
+
+else
+
 define CREATE_SUBTIER_TRAVERSAL_RULE
 PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS))
 
 .PHONY: $(1) $$(PARALLEL_DIRS_$(1))
 
 ifdef PARALLEL_DIRS
 $$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile
 	+@$$(call SUBMAKE,$(1),$$*)
@@ -30,8 +43,10 @@ endef
 
 $(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
 
 export:: $(SUBMAKEFILES)
 	$(LOOP_OVER_TOOL_DIRS)
 
 tools:: $(SUBMAKEFILES)
 	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
+
+endif
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -430,17 +430,20 @@ ifdef MOZ_UPDATE_XTERM
 # Its good not to have a newline at the end of the titlebar string because it
 # makes the make -s output easier to read.  Echo -n does not work on all
 # platforms, but we can trick printf into doing it.
 UPDATE_TITLE = printf "\033]0;%s in %s\007" $(1) $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2) ;
 endif
 
 ifdef MACH
 ifndef NO_BUILDSTATUS_MESSAGES
-BUILDSTATUS=@echo "BUILDSTATUS $1"
+define BUILDSTATUS
+@echo "BUILDSTATUS $1"
+
+endef
 endif
 endif
 
 # Static directories are largely independent of our build system. But, they
 # could share the same build mechanism (like moz.build files). We need to
 # prevent leaking of our backend state to these independent build systems. This
 # is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static
 # directories.
@@ -452,17 +455,16 @@ endef # The extra line is important here
 
 define TIER_DIR_SUBMAKE
 $(call BUILDSTATUS,TIERDIR_START  $(1) $(2) $(3))
 $(call SUBMAKE,$(4),$(3),$(5))
 $(call BUILDSTATUS,TIERDIR_FINISH $(1) $(2) $(3))
 
 endef # Ths empty line is important.
 
-
 ifneq (,$(strip $(DIRS)))
 LOOP_OVER_DIRS = \
   $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
 endif
 
 # we only use this for the makefiles target and other stuff that doesn't matter
 ifneq (,$(strip $(PARALLEL_DIRS)))
 LOOP_OVER_PARALLEL_DIRS = \
@@ -682,22 +684,20 @@ endif
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
-ifndef TIERS
 default all::
 	$(MAKE) export
 	$(MAKE) libs
 	$(MAKE) tools
-endif # TIERS
 endif # SUPPRESS_DEFAULT_RULES
 
 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
 ECHO := echo
 QUIET :=
 else
 ECHO := true
 QUIET := -q
deleted file mode 100644
--- a/js/src/config/makefiles/tiers.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This file contains logic for tier traversal.
-
-define CREATE_SUBTIER_RULE
-$(2)_tier_$(1):
-	$$(call BUILDSTATUS,SUBTIER_START  $(1) $(2) $$(tier_$(1)_dirs))
-	$$(foreach dir,$$(tier_$(1)_dirs),$$(call TIER_DIR_SUBMAKE,$(1),$(2),$$(dir),$(2)))
-	$$(call BUILDSTATUS,SUBTIER_FINISH $(1) $(2))
-
-endef
-
-# This function is called and evaluated to produce the rule to build the
-# specified tier.
-#
-# Tiers are traditionally composed of directories that are invoked either
-# once (so-called "static" directories) or 3 times with the export, libs, and
-# tools sub-tiers.
-#
-# If the TIER_$(tier)_CUSTOM variable is defined, then these traditional
-# tier rules are ignored and each directory in the tier is executed via a
-# sub-make invocation (make -C).
-define CREATE_TIER_RULE
-tier_$(1)::
-ifdef TIER_$(1)_CUSTOM
-	$$(foreach dir,$$($$@_dirs),$$(call SUBMAKE,,$$(dir)))
-else
-	$(call BUILDSTATUS,TIER_START $(1) $(if $(tier_$(1)_staticdirs),static )$(if $(tier_$(1)_dirs),export libs tools))
-ifneq (,$(tier_$(1)_staticdirs))
-	$(call BUILDSTATUS,SUBTIER_START  $(1) static $$($$@_staticdirs))
-	$$(foreach dir,$$($$@_staticdirs),$$(call TIER_DIR_SUBMAKE,$(1),static,$$(dir),,1))
-	$(call BUILDSTATUS,SUBTIER_FINISH $(1) static)
-endif
-ifneq (,$(tier_$(1)_dirs))
-	$$(MAKE) export_$$@
-	$$(MAKE) libs_$$@
-	$$(MAKE) tools_$$@
-endif
-	$(call BUILDSTATUS,TIER_FINISH $(1))
-endif
-
-$(foreach subtier,export libs tools,$(call CREATE_SUBTIER_RULE,$(1),$(subtier)))
-
-endef
--- a/js/src/config/recurse.mk
+++ b/js/src/config/recurse.mk
@@ -5,16 +5,29 @@
 ifndef INCLUDED_RULES_MK
 include $(topsrcdir)/config/rules.mk
 endif
 
 #########################
 # Tier traversal handling
 #########################
 
+ifdef TIERS
+
+libs export tools::
+	$(call BUILDSTATUS,TIER_START $@ $(filter-out $(if $(filter export,$@),,precompile),$(TIERS)))
+	$(foreach tier,$(TIERS), $(if $(filter-out libs_precompile tools_precompile,$@_$(tier)), \
+		$(call BUILDSTATUS,SUBTIER_START $@ $(tier) $(if $(filter libs,$@),$(tier_$(tier)_staticdirs)) $(tier_$(tier)_dirs)) \
+		$(if $(filter libs,$@),$(foreach dir, $(tier_$(tier)_staticdirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),,1))) \
+		$(foreach dir, $(tier_$(tier)_dirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),$@)) \
+		$(call BUILDSTATUS,SUBTIER_FINISH $@ $(tier))))
+	$(call BUILDSTATUS,TIER_FINISH $@)
+
+else
+
 define CREATE_SUBTIER_TRAVERSAL_RULE
 PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS))
 
 .PHONY: $(1) $$(PARALLEL_DIRS_$(1))
 
 ifdef PARALLEL_DIRS
 $$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile
 	+@$$(call SUBMAKE,$(1),$$*)
@@ -30,8 +43,10 @@ endef
 
 $(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
 
 export:: $(SUBMAKEFILES)
 	$(LOOP_OVER_TOOL_DIRS)
 
 tools:: $(SUBMAKEFILES)
 	$(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
+
+endif
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -430,17 +430,20 @@ ifdef MOZ_UPDATE_XTERM
 # Its good not to have a newline at the end of the titlebar string because it
 # makes the make -s output easier to read.  Echo -n does not work on all
 # platforms, but we can trick printf into doing it.
 UPDATE_TITLE = printf "\033]0;%s in %s\007" $(1) $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2) ;
 endif
 
 ifdef MACH
 ifndef NO_BUILDSTATUS_MESSAGES
-BUILDSTATUS=@echo "BUILDSTATUS $1"
+define BUILDSTATUS
+@echo "BUILDSTATUS $1"
+
+endef
 endif
 endif
 
 # Static directories are largely independent of our build system. But, they
 # could share the same build mechanism (like moz.build files). We need to
 # prevent leaking of our backend state to these independent build systems. This
 # is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static
 # directories.
@@ -452,17 +455,16 @@ endef # The extra line is important here
 
 define TIER_DIR_SUBMAKE
 $(call BUILDSTATUS,TIERDIR_START  $(1) $(2) $(3))
 $(call SUBMAKE,$(4),$(3),$(5))
 $(call BUILDSTATUS,TIERDIR_FINISH $(1) $(2) $(3))
 
 endef # Ths empty line is important.
 
-
 ifneq (,$(strip $(DIRS)))
 LOOP_OVER_DIRS = \
   $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
 endif
 
 # we only use this for the makefiles target and other stuff that doesn't matter
 ifneq (,$(strip $(PARALLEL_DIRS)))
 LOOP_OVER_PARALLEL_DIRS = \
@@ -682,22 +684,20 @@ endif
 #   This is used to update or create the Makefiles before invoking them.
 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
 
 # The root makefile doesn't want to do a plain export/libs, because
 # of the tiers and because of libxul. Suppress the default rules in favor
 # of something else. Makefiles which use this var *must* provide a sensible
 # default rule before including rules.mk
 ifndef SUPPRESS_DEFAULT_RULES
-ifndef TIERS
 default all::
 	$(MAKE) export
 	$(MAKE) libs
 	$(MAKE) tools
-endif # TIERS
 endif # SUPPRESS_DEFAULT_RULES
 
 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
 ECHO := echo
 QUIET :=
 else
 ECHO := true
 QUIET := -q