bug 750303: mkdir_deps - target specific enhancement
authorJoey Armstrong <joey@mozilla.com>
Mon, 04 Mar 2013 14:34:02 -0500
changeset 134940 7f12ca5e6d0acf10c4911d6f141bf94750ace687
parent 134939 7b1bb476bd8d5493d1a9e3418d48aad367387170
child 134941 13974e5104c95c52d04b7209edd48ddd7e777802
push id336
push userakeybl@mozilla.com
push dateMon, 17 Jun 2013 22:53:19 +0000
treeherdermozilla-release@574a39cdf657 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs750303
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 750303: mkdir_deps - target specific enhancement
browser/app/Makefile.in
browser/locales/Makefile.in
config/Makefile.in
config/makefiles/autotargets.mk
config/makefiles/test/check-autotargets.mk
config/makefiles/test/check-export-targets.mk
ipc/chromium/Makefile.in
js/src/config/makefiles/autotargets.mk
webapprt/Makefile.in
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -98,16 +98,21 @@ endif
 ifeq ($(OS_ARCH),OS2)
 RESFILE=splashos2.res
 RCFLAGS += -DMOZ_PHOENIX
 RCFLAGS += -DFIREFOX_ICO=\"$(DIST)/branding/firefox-os2.ico\" -DDOCUMENT_ICO=\"$(DIST)/branding/document-os2.ico\"
 endif
 
 PROGRAMS_DEST = $(DIST)/bin
 
+GENERATED_DIRS_libs = \
+  $(dist_dest)/Contents/MacOS \
+  $(dist_dest)/Contents/Resources/$(AB).lproj \
+  $(NULL)
+
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT) #{
 #
 # Control the default heap size.
 # This is the heap returned by GetProcessHeap().
 # As we use the CRT heap, the default size is too large and wastes VM.
 #
@@ -169,23 +174,19 @@ clean clobber repackage::
 ifdef LIBXUL_SDK
 APPFILES = Resources
 else
 APPFILES = MacOS
 endif
 
 MAC_BUNDLE_VERSION = $(shell $(PYTHON) $(srcdir)/macversion.py --version=$(MOZ_APP_VERSION) --buildid=$(DEPTH)/config/buildid)
 
-libs-preqs = \
-  $(call mkdir_deps,$(dist_dest)/Contents/MacOS) \
-  $(call mkdir_deps,$(dist_dest)/Contents/Resources/$(AB).lproj) \
-  $(NULL)
 
 .PHONY: repackage
-libs repackage:: $(PROGRAM) $(libs-preqs)
+libs repackage:: $(PROGRAM)
 	rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents $(dist_dest) --exclude English.lproj
 	rsync -a --exclude "*.in" $(srcdir)/macbuild/Contents/Resources/English.lproj/ $(dist_dest)/Contents/Resources/$(AB).lproj
 	sed -e "s/%APP_VERSION%/$(MOZ_APP_VERSION)/" -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" -e "s/%MOZ_MACBUNDLE_ID%/$(MOZ_MACBUNDLE_ID)/" -e "s/%MAC_BUNDLE_VERSION%/$(MAC_BUNDLE_VERSION)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(dist_dest)/Contents/Info.plist
 	sed -e "s/%MAC_APP_NAME%/$(MAC_APP_NAME)/" $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | iconv -f UTF-8 -t UTF-16 > $(dist_dest)/Contents/Resources/$(AB).lproj/InfoPlist.strings
 	rsync -a $(DIST)/bin/ $(dist_dest)/Contents/$(APPFILES)
 	$(RM) $(dist_dest)/Contents/MacOS/$(PROGRAM)
 	rsync -aL $(PROGRAM) $(dist_dest)/Contents/MacOS
 	cp -RL $(DIST)/branding/firefox.icns $(dist_dest)/Contents/Resources/firefox.icns
--- a/browser/locales/Makefile.in
+++ b/browser/locales/Makefile.in
@@ -85,16 +85,18 @@ PP_TARGETS += SEARCHPLUGINS
 # be included in langpack xpis.
 ifdef MOZ_METRO
 # metro build, include both app folders
 DIST_SUBDIRS = browser metro
 else
 DIST_SUBDIRS = $(DIST_SUBDIR)
 endif
 
+GENERATED_DIRS_libs = $(DIST)/bin
+
 include $(topsrcdir)/config/rules.mk
 
 include $(topsrcdir)/toolkit/locales/l10n.mk
 
 $(STAGEDIST): $(DIST)/branding
 
 $(DIST)/branding:
 	$(NSINSTALL) -D $@
@@ -203,17 +205,17 @@ langpack: langpack-$(AB_CD)
 # tinderbox scripts. Alter it with caution.
 
 installers-%: clobber-% langpack-% repackage-win32-installer-% repackage-zip-%
 	@echo "repackaging done"
 
 ifdef MOZ_UPDATER
 # Note that we want updater.ini to be in the top directory, not the browser/
 # subdirectory, because that's where the updater is installed and runs.
-libs:: $(call MERGE_FILE,updater/updater.ini) $(call mkdir_deps,$(DIST)/bin)
+libs:: $(call MERGE_FILE,updater/updater.ini)
 ifeq ($(OS_ARCH),WINNT)
 	cat $< $(srcdir)/../installer/windows/nsis/updater_append.ini | \
 	  sed -e "s/^InfoText=/Info=/" -e "s/^TitleText=/Title=/" | \
 	  sed -e "s/%MOZ_APP_DISPLAYNAME%/$(MOZ_APP_DISPLAYNAME)/" > \
 	  $(DIST)/bin/updater.ini
 else
 	cat $< | \
 	  sed -e "s/^InfoText=/Info=/" -e "s/^TitleText=/Title=/" | \
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -62,16 +62,20 @@ HEADERS_FILES = \
 	$(srcdir)/nsStaticComponents.h \
 	$(NULL)
 HEADERS_DEST := $(DIST)/include
 HEADERS_TARGET := export
 INSTALL_TARGETS += HEADERS
 
 PYTHON_UNIT_TESTS := $(wildcard $(srcdir)/tests/unit-*.py)
 
+ifdef WRAP_SYSTEM_INCLUDES
+  GENERATED_DIRS_export += system_wrappers
+endif
+
 include $(topsrcdir)/config/rules.mk
 
 HOST_CFLAGS += -DUNICODE -D_UNICODE
 
 ifeq ($(OS_CONFIG),SunOS4.1)
 NSPR_CFLAGS	+= -I$(srcdir)/../nsprpub/pr/include/md
 endif
 
@@ -83,21 +87,18 @@ export::
 export::
 ifdef MOZ_BUILD_DATE
 	printf "%s" $(MOZ_BUILD_DATE) > buildid
 else
 	$(PYTHON) $(topsrcdir)/toolkit/xre/make-platformini.py --print-buildid > buildid
 endif
 
 ifdef WRAP_SYSTEM_INCLUDES
-export-preqs = \
-  $(call mkdir_deps,system_wrappers) \
-  $(NULL)
 
-export:: $(export-preqs)
+export::
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
 		-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
 		-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
 		-DMOZ_NATIVE_HUNSPELL=$(MOZ_NATIVE_HUNSPELL) \
 		-DMOZ_NATIVE_BZ2=$(MOZ_NATIVE_BZ2) \
 		-DMOZ_NATIVE_ZLIB=$(MOZ_NATIVE_ZLIB) \
 		-DMOZ_NATIVE_PNG=$(MOZ_NATIVE_PNG) \
 		-DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \
--- a/config/makefiles/autotargets.mk
+++ b/config/makefiles/autotargets.mk
@@ -43,18 +43,27 @@ slash_strip = \
     $(subst <--[**]-->,$(space),\
 	$(call _slashSqueeze,\
     $(subst $(space),<--[**]-->,$(1))\
   )))
 
 # Extract directory path from a dependency file.
 mkdir_stem =$(foreach val,$(getargv),$(subst /.mkdir.done,$(NULL),$(val)))
 
+# Function can be called by other functions to expand un-expanded make vars.
+# := functionality in call(able) function form
+expand = $(eval func-expand-$(1) := $($(1)))$(func-expand-$(1))
+
 ## Generate timestamp file for threadsafe directory creation
-mkdir_deps =$(foreach dir,$(getargv),$(call slash_strip,$(dir)/.mkdir.done))
+mkdir_deps = \
+  $(strip \
+  $(foreach var,$(getargv),\
+  $(foreach dir,$(call expand,var),\
+  $(call slash_strip,$(call expand,dir)/.mkdir.done) \
+  )))
 
 #######################
 ##---]  TARGETS  [---##
 #######################
 
 %/.mkdir.done: # mkdir -p -p => mkdir -p
 	$(subst $(space)-p,$(null),$(MKDIR)) -p "$(dir $@)"
 # Make the timestamp old enough for not being a problem with symbolic links
@@ -68,27 +77,29 @@ mkdir_deps =$(foreach dir,$(getargv),$(c
 .mkdir.done:
 	@echo "WARNING: $(MKDIR) -dot- requested by $(MAKE) -C $(CURDIR) $(MAKECMDGOALS)"
 	@$(TOUCH) -t 198001030000 "$@"
 
 INCLUDED_AUTOTARGETS_MK = 1
 endif #}
 
 
-## Accumulate deps and cleanup
-ifneq (,$(GENERATED_DIRS))
-  GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
-  tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
-  GENERATED_DIRS_DEPS +=$(tmpauto)
-  GARBAGE_DIRS        +=$(GENERATED_DIRS)
-endif
+###########################################################################
+## GENERATED_DIR(_\S+)? directory deps
+## GENERATED_DIRS_{export,lib,tools} = foo   # target specific deps
+###########################################################################
+GENERATED_DIRS += $(foreach tgt,$(MAKECMDGOALS),$(value GENERATED_DIRS_$(tgt)))
+GENERATED_DIRS := $(call expand,GENERATED_DIRS)
+GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
+GARBAGE_DIRS   += $(GENERATED_DIRS)
+
+# directory deps are timestamp based to only create when needed
+AUTO_DEPS += $(if $(value GENERATED_DIRS),$(call mkdir_deps,GENERATED_DIRS))
 
 #################################################################
 # One ring/dep to rule them all:
 #   config/rules.mk::all target is available by default
 #   Add $(AUTO_DEPS) as an explicit target dependency when needed.
 #################################################################
-
-AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
 AUTO_DEPS := $(strip $(sort $(AUTO_DEPS)))
 
 # Complain loudly if deps have not loaded so getargv != $(NULL)
 $(call requiredfunction,getargv)
--- a/config/makefiles/test/check-autotargets.mk
+++ b/config/makefiles/test/check-autotargets.mk
@@ -4,38 +4,68 @@
 # 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/.
 
 ifdef VERBOSE
   $(warning loading test)
 endif
 
 space=$(null) $(null)
-GENERATED_DIRS = bogus # test data
+
+testD1 = test-dir-1
+testD2 = test-dir-2
+testD3 = test-dir-3
+testD4 = test-dir-4
+
+# Append goals to force var expansion
+MAKECMDGOALS := $(MAKECMDGOALS) libs tools
+
+#dir-var = test-dir-1
+GENERATED_DIRS = test-dir-1 # test data
+GENERATED_DIRS_libs = $(testD2)
+GENERATED_DIRS_tools = test-dir-3 $(testD4)
+
 
-undefine USE_AUTOTARGETS_MK
-undefine INCLUDED_AUTOTARGETS_MK
+###########################################################################
+# undefine directive not supported by older make versions but needed here
+# to force a re-include/re-eval for testing.  Unit test should be non-fatal
+# unless hacking on makefiles.
+###########################################################################
+
+undefine_supported=no
+$(eval undefine undefine_supported)
+undefine_supported ?= yes
+
+ifeq (yes,$(undefine_supported))
+  # Clear defs to re-include for testing
+  undefine USE_AUTOTARGETS_MK
+  undefine INCLUDED_AUTOTARGETS_MK
+else
+  $(info ===========================================================================)
+  $(warning $(MAKE)[$(MAKE_VERSION)]: makefile directive 'undefined' not supported, disabling test)
+  $(info ===========================================================================)
+endif
+
 include $(topsrcdir)/config/makefiles/autotargets.mk
 
 ifndef INCLUDED_AUTOTARGETS_MK
-  $(error autotargets.mk was not included
+  $(error autotargets.mk was not included)
 endif
 
 $(call requiredfunction,mkdir_deps)
 
 
 # Verify test data populated makefile vars correctly
-vars = AUTO_DEPS GARBAGE_DIRS GENERATED_DIRS_DEPS
+vars = AUTO_DEPS GARBAGE_DIRS GENERATED_DIRS_tools
 $(foreach var,$(vars),$(call errorIfEmpty,$(var)))
 
-# Data should also be valid
-ifneq (bogus,$(findstring bogus,$(AUTO_DEPS)))
-  $(error AUTO_DEPS=[$(AUTO_DEPS)] is not set correctly)
-endif
-
+# Verify target dirs were expanded into GENERATED_DIRS
+$(foreach path,$(testD1) $(testD2) $(testD3) $(testD4),\
+  $(if $(findstring $(path),$(AUTO_DEPS))\
+    ,,$(error AUTO_DEPS missing path $(path))))
 
 # relpath
 path  := foo/bar.c
 exp   := foo/.mkdir.done
 found := $(call mkdir_deps,$(dir $(path)))
 ifneq ($(exp),$(found))
   $(error mkdir_deps($(path))=$(exp) not set correctly [$(found)])
 endif
--- a/config/makefiles/test/check-export-targets.mk
+++ b/config/makefiles/test/check-export-targets.mk
@@ -8,23 +8,35 @@ ifdef VERBOSE
   $(warning loading test)
 endif
 
 MOZILLA_DIR ?= $(topsrcdir)
 checkup = \
   check-final-lib-link-list \
   $(NULL)
 
+undefine_supported=no
+$(eval undefine undefine_supported)
+undefine_supported ?= yes
+
+
 checkup: $(checkup)
 
 
 # <CHECK: final-lib-link-list>
 LIBRARY_NAME   = foo# real_data: xptcmd
 EXPORT_LIBRARY = foo# real_data: ../..
-undefine IS_COMPONENT
+
+ifeq (yes,$(undefine_supported))
+  undefine IS_COMPONENT
+else
+  $(info ===========================================================================)
+  $(warning $(MAKE)[$(MAKE_VERSION)]: makefile directive 'undefined' not supported, disabling test)
+  $(info ===========================================================================)
+endif
 
 test-data = $(CURDIR)/check-export-targets-test-data
 FINAL_LINK_LIBS     = $(test-data)
 STATIC_LIBRARY_NAME = /dev/null
 
 check-final-lib-link-list: export-gen-final-lib-link-list
 	@cat $(test-data)
 # </CHECK: final-lib-link-list>
--- a/ipc/chromium/Makefile.in
+++ b/ipc/chromium/Makefile.in
@@ -315,20 +315,18 @@ ifneq (mips,$(findstring mips,$(OS_TEST)
 # Use mutex-backed atomics
 CPPSRCS += atomicops_internals_mutex.cc
 endif # }
 endif # }
 endif # }
 
 OS_CXXFLAGS += $(TK_CFLAGS)
 
+GENERATED_DIRS_export := $(DIST)/third_party/libevent
+
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_NATIVE_LIBEVENT # {
 
-export-preqs = \
-  $(call mkdir_deps,$(DIST)/third_party/libevent) \
-  $(NULL)
-
-export:: $(export-preqs)
+export::
 	echo "#include <event.h>" > $(DIST)/third_party/libevent/event.h
 
 endif # }
--- a/js/src/config/makefiles/autotargets.mk
+++ b/js/src/config/makefiles/autotargets.mk
@@ -43,18 +43,27 @@ slash_strip = \
     $(subst <--[**]-->,$(space),\
 	$(call _slashSqueeze,\
     $(subst $(space),<--[**]-->,$(1))\
   )))
 
 # Extract directory path from a dependency file.
 mkdir_stem =$(foreach val,$(getargv),$(subst /.mkdir.done,$(NULL),$(val)))
 
+# Function can be called by other functions to expand un-expanded make vars.
+# := functionality in call(able) function form
+expand = $(eval func-expand-$(1) := $($(1)))$(func-expand-$(1))
+
 ## Generate timestamp file for threadsafe directory creation
-mkdir_deps =$(foreach dir,$(getargv),$(call slash_strip,$(dir)/.mkdir.done))
+mkdir_deps = \
+  $(strip \
+  $(foreach var,$(getargv),\
+  $(foreach dir,$(call expand,var),\
+  $(call slash_strip,$(call expand,dir)/.mkdir.done) \
+  )))
 
 #######################
 ##---]  TARGETS  [---##
 #######################
 
 %/.mkdir.done: # mkdir -p -p => mkdir -p
 	$(subst $(space)-p,$(null),$(MKDIR)) -p "$(dir $@)"
 # Make the timestamp old enough for not being a problem with symbolic links
@@ -68,27 +77,29 @@ mkdir_deps =$(foreach dir,$(getargv),$(c
 .mkdir.done:
 	@echo "WARNING: $(MKDIR) -dot- requested by $(MAKE) -C $(CURDIR) $(MAKECMDGOALS)"
 	@$(TOUCH) -t 198001030000 "$@"
 
 INCLUDED_AUTOTARGETS_MK = 1
 endif #}
 
 
-## Accumulate deps and cleanup
-ifneq (,$(GENERATED_DIRS))
-  GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
-  tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
-  GENERATED_DIRS_DEPS +=$(tmpauto)
-  GARBAGE_DIRS        +=$(GENERATED_DIRS)
-endif
+###########################################################################
+## GENERATED_DIR(_\S+)? directory deps
+## GENERATED_DIRS_{export,lib,tools} = foo   # target specific deps
+###########################################################################
+GENERATED_DIRS += $(foreach tgt,$(MAKECMDGOALS),$(value GENERATED_DIRS_$(tgt)))
+GENERATED_DIRS := $(call expand,GENERATED_DIRS)
+GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
+GARBAGE_DIRS   += $(GENERATED_DIRS)
+
+# directory deps are timestamp based to only create when needed
+AUTO_DEPS += $(if $(value GENERATED_DIRS),$(call mkdir_deps,GENERATED_DIRS))
 
 #################################################################
 # One ring/dep to rule them all:
 #   config/rules.mk::all target is available by default
 #   Add $(AUTO_DEPS) as an explicit target dependency when needed.
 #################################################################
-
-AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
 AUTO_DEPS := $(strip $(sort $(AUTO_DEPS)))
 
 # Complain loudly if deps have not loaded so getargv != $(NULL)
 $(call requiredfunction,getargv)
--- a/webapprt/Makefile.in
+++ b/webapprt/Makefile.in
@@ -27,27 +27,29 @@ EXTRA_JS_MODULES = \
   Startup.jsm \
   WebappRT.jsm \
   WebappsHandler.jsm \
   $(NULL)
 
 PREF_JS_EXPORTS = $(srcdir)/prefs.js \
                   $(NULL)
 
+GENERATED_DIRS_libs = $(FINAL_TARGET)
+
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_DEBUG
 DEFINES += -DMOZ_DEBUG=1
 endif
 
 ifdef MOZILLA_OFFICIAL
 DEFINES += -DMOZILLA_OFFICIAL
 endif
 
-libs:: $(call mkdir_deps,$(FINAL_TARGET))
+libs::
 	$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "resource webapprt ./"
 
 GRE_MILESTONE := $(shell tail -n 1 $(topsrcdir)/config/milestone.txt 2>/dev/null || tail -1 $(topsrcdir)/config/milestone.txt)
 GRE_BUILDID := $(shell cat $(DEPTH)/config/buildid)
 DEFINES += -DGRE_MILESTONE=$(GRE_MILESTONE) \
            -DGRE_BUILDID=$(GRE_BUILDID) \
            -DMOZ_APP_BASENAME=$(MOZ_APP_BASENAME) \
            $(NULL)