Bug 1094560 - Eliminate the clone of config/recurse.mk in comm-central, r=glandium, a=jcranmer
authorJoshua Cranmer <Pidgeot18@gmail.com>
Wed, 05 Nov 2014 21:40:09 -0600
changeset 21224 a162396c787698de3b28f1fc62d465ef2380fed6
parent 21223 e4dbeb8f01a8f049ead91bc28fa147ac4dc560cf
child 21225 5f038bb278274f59d2308b3c511334448d43c009
push id1274
push usermbanner@mozilla.com
push dateMon, 12 Jan 2015 19:54:49 +0000
treeherdercomm-beta@baea280adc1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, jcranmer
bugs1094560, 1094033
Bug 1094560 - Eliminate the clone of config/recurse.mk in comm-central, r=glandium, a=jcranmer Ideally, this file would just die altogether. However, MOZILLA_DIR presently gets defined in m-c only as late as rules.mk (included via this file), so it requires bigger disruption to the m-c build system to do it. So instead, the copy in comm-central is just plain emasculated. Included are some ports of older build config bugs that are needed to make the current m-c copy actually usable from c-c. Another change directly ports bug 1094033.
config/config.mk
config/recurse.mk
config/rules.mk
--- a/config/config.mk
+++ b/config/config.mk
@@ -24,82 +24,21 @@ topsrcdir	= $(DEPTH)
 endif
 
 ifndef INCLUDED_AUTOCONF_MK
 include $(DEPTH)/config/autoconf.mk
 endif
 
 -include $(DEPTH)/.mozconfig.mk
 
-# Integrate with mozbuild-generated make files. We first verify that no
-# variables provided by the automatically generated .mk files are
-# present. If they are, this is a violation of the separation of
-# responsibility between Makefile.in and mozbuild files.
-_MOZBUILD_EXTERNAL_VARIABLES := \
-  ANDROID_GENERATED_RESFILES \
-  ANDROID_RESFILES \
-  CMMSRCS \
-  CPP_UNIT_TESTS \
-  DIRS \
-  DIST_SUBDIR \
-  EXTRA_DSO_LDOPTS \
-  EXTRA_JS_MODULES \
-  EXTRA_PP_COMPONENTS \
-  EXTRA_PP_JS_MODULES \
-  FINAL_LIBRARY \
-  FINAL_TARGET \
-  GTEST_CMMSRCS \
-  GTEST_CPPSRCS \
-  GTEST_CSRCS \
-  HOST_CSRCS \
-  HOST_LIBRARY_NAME \
-  IS_COMPONENT \
-  JAR_MANIFEST \
-  LIBRARY_NAME \
-  LIBS \
-  LIBXUL_LIBRARY \
-  MAKE_FRAMEWORK \
-  MODULE \
-  MSVC_ENABLE_PGO \
-  NO_DIST_INSTALL \
-  PARALLEL_DIRS \
-  SDK_HEADERS \
-  SDK_LIBRARY \
-  SHARED_LIBRARY_LIBS \
-  SHARED_LIBRARY_NAME \
-  SIMPLE_PROGRAMS \
-  STATIC_LIBRARY_NAME \
-  TEST_DIRS \
-  TESTING_JS_MODULES \
-  TESTING_JS_MODULE_DIR \
-  TIERS \
-  TOOL_DIRS \
-  XPCSHELL_TESTS \
-  XPIDL_MODULE \
-  XPI_NAME \
-  $(NULL)
-
-_DEPRECATED_VARIABLES := \
-  MOCHITEST_FILES_PARTS \
-  MOCHITEST_BROWSER_FILES_PARTS \
-  $(NULL)
-
 ifndef EXTERNALLY_MANAGED_MAKE_FILE
 # Using $(firstword) may not be perfect. But it should be good enough for most
 # scenarios.
 _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST))
 
-$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\
-    $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\
-    ))
-
-$(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\
-    $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\
-    ))
-
 # Import the automatically generated backend file. If this file doesn't exist,
 # the backend hasn't been properly configured. We want this to be a fatal
 # error, hence not using "-include".
 ifndef STANDALONE_MAKEFILE
 GLOBAL_DEPS += backend.mk
 include backend.mk
 endif
 
--- a/config/recurse.mk
+++ b/config/recurse.mk
@@ -1,158 +1,9 @@
 # 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/.
 
 ifndef INCLUDED_RULES_MK
 include $(topsrcdir)/config/rules.mk
 endif
 
-# The traditional model of directory traversal with make is as follows:
-#   make -C foo
-#     Entering foo
-#     make -C bar
-#       Entering foo/bar
-#     make -C baz
-#       Entering foo/baz
-#   make -C qux
-#     Entering qux
-#
-# Pseudo derecurse transforms the above into:
-#   make -C foo
-#   make -C foo/bar
-#   make -C foo/baz
-#   make -C qux
-
-ifeq (.,$(DEPTH))
-
-include root.mk
-
-# Disable build status for mach in top directories without TIERS.
-# In practice this disables it when recursing under js/src, which confuses mach.
-ifndef TIERS
-BUILDSTATUS =
-endif
-
-# Main rules (export, compile, libs and tools) call recurse_* rules.
-# This wrapping is only really useful for build status.
-compile libs export tools::
-	$(call BUILDSTATUS,TIER_START $@)
-	+$(MAKE) recurse_$@
-	$(call BUILDSTATUS,TIER_FINISH $@)
-
-# Special rule that does install-manifests (cf. Makefile.in) + compile
-binaries::
-	+$(MAKE) recurse_compile
-
-# Carefully avoid $(eval) type of rule generation, which makes pymake slower
-# than necessary.
-# Get current tier and corresponding subtiers from the data in root.mk.
-CURRENT_TIER := $(filter $(foreach tier,compile libs export tools,recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
-ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER))))
-$(error $(CURRENT_TIER) not supported on the same make command line)
-endif
-CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=))
-
-# The rules here are doing directory traversal, so we don't want further
-# recursion to happen when running make -C subdir $tier. But some make files
-# further call make -C something else, and sometimes expect recursion to
-# happen in that case (see browser/metro/locales/Makefile.in for example).
-# Conveniently, every invocation of make increases MAKELEVEL, so only stop
-# recursion from happening at current MAKELEVEL + 1.
-ifdef CURRENT_TIER
-ifeq (0,$(MAKELEVEL))
-export NO_RECURSE_MAKELEVEL=1
-else
-export NO_RECURSE_MAKELEVEL=$(word $(MAKELEVEL),2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
-endif
-endif
-
-# Get all directories traversed for all subtiers in the current tier, or use
-# directly the $(*_dirs) variables available in root.mk when there is no
-# TIERS (like for js/src).
-CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
-
-# The compile tier has different rules from other tiers.
-ifeq ($(CURRENT_TIER),compile)
-
-# Need a list of compile targets because we can't use pattern rules:
-# https://savannah.gnu.org/bugs/index.php?42833
-.PHONY: $(compile_targets)
-$(compile_targets):
-	$(call SUBMAKE,$(if $(filter $(@D),$(staticdirs)),,$(@F)),$(@D))
-
-else
-
-# Recursion rule for all directories traversed for all subtiers in the
-# current tier.
-$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER):
-	$(call SUBMAKE,$(CURRENT_TIER),$*)
-
-.PHONY: $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS))
-
-# Dummy rules for possibly inexisting dependencies for the above tier targets
-$(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)):
-
-ifeq ($(CURRENT_TIER),export)
-# At least build/export requires config/export for buildid, but who knows what
-# else, so keep this global dependency to make config/export first for now.
-$(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CURRENT_TIER)
-
-# The export tier requires nsinstall, which is built from config. So every
-# subdirectory traversal needs to happen after building nsinstall in config,
-# which is done with the config/host target. Note the config/host target only
-# exists if nsinstall is actually built, which it is not on Windows, because we
-# use nsinstall.py there.
-ifneq (,$(filter config/host, $(compile_targets)))
-$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): config/host
-
-# Ensure rules for config/host and its possible dependencies.
-.PHONY: $(filter %/host, $(compile_targets))
-$(filter %/host, $(compile_targets)):
-	$(call SUBMAKE,host,$(@D))
-endif
-endif
-
-endif # ifeq ($(CURRENT_TIER),compile)
-
-else
-
-# Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
-ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
-
-compile libs export tools::
-
-else
-#########################
-# Tier traversal handling
-#########################
-
-ifdef TIERS
-
-libs export tools::
-	$(call BUILDSTATUS,TIER_START $@)
-	$(foreach tier,$(TIERS), $(if $(filter-out libs_precompile tools_precompile,$@_$(tier)), \
-		$(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,TIER_FINISH $@)
-
-else
-
-define CREATE_SUBTIER_TRAVERSAL_RULE
-.PHONY: $(1)
-
-$(1):: $$(SUBMAKEFILES)
-	$$(LOOP_OVER_DIRS)
-
-endef
-
-$(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
-
-endif # ifdef TIERS
-
-endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
-
-endif # ifeq (.,$(DEPTH))
-
-recurse:
-	@$(RECURSED_COMMAND)
-	$(LOOP_OVER_DIRS)
+include $(MOZILLA_DIR)/config/recurse.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -483,30 +483,18 @@ endif
 
 ifeq (,$(CROSS_COMPILE))
 HOST_OUTOPTION = $(OUTOPTION)
 else
 HOST_OUTOPTION = -o # eol
 endif
 ################################################################################
 
-# 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
 default all::
-	$(MAKE) export
-ifdef COMPILE_ENVIRONMENT
-	$(MAKE) compile
-endif
-	$(MAKE) libs
-	$(MAKE) tools
-
-endif # SUPPRESS_DEFAULT_RULES
+	$(foreach tier,$(TIERS),$(call SUBMAKE,$(tier)))
 
 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
 ECHO := echo
 QUIET :=
 else
 ECHO := true
 QUIET := -q
 endif
@@ -1684,8 +1672,14 @@ include $(topsrcdir)/config/makefiles/au
 ifneq ($(NULL),$(AUTO_DEPS))
   default all libs tools export:: $(AUTO_DEPS)
 endif
 
 export:: $(GENERATED_FILES)
 
 GARBAGE += $(GENERATED_FILES)
 
+# We may have modified "frozen" variables in rules.mk (we do that), but we don't
+# want Makefile.in doing that, so collect the possibly modified variables here,
+# and check them again in recurse.mk, which is always included after Makefile.in
+# contents.
+$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
+$(foreach var,$(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))