From 09b7788e66eddb3d04e99d4ca3cf3c3198df0cc5 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 5 Sep 2013 09:01:44 +0900 Subject: [PATCH] Bug 911634 - Create a .mozconfig.mk in the objdir when starting a build, and include it from config.mk. r=gps --- Makefile.in | 2 +- build/autoconf/mozconfig2client-mk | 16 +--------- client.mk | 48 +++++++++++++++++++++++++----- config/config.mk | 2 ++ js/src/config/config.mk | 2 ++ 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/Makefile.in b/Makefile.in index 923f7c263a25..ef1cf067cf78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,7 @@ DIST_GARBAGE = config.cache config.log config.status* config-defs.h \ config/autoconf.mk \ mozilla-config.h \ netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \ - $(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out + .mozconfig.mk ifndef MOZ_PROFILE_USE # One of the first things we do in the build is purge "unknown" files diff --git a/build/autoconf/mozconfig2client-mk b/build/autoconf/mozconfig2client-mk index a3bf18ba42c8..aaf8de185932 100755 --- a/build/autoconf/mozconfig2client-mk +++ b/build/autoconf/mozconfig2client-mk @@ -43,15 +43,6 @@ mk_add_options() { # and substitute '@@' with '$()'. _opt=`echo "$_opt" | sed -e 's/\([\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'` echo $_opt; - opts="${opts:+$opts^}$_opt"; - done -} - -mk_echo_options() { - echo "Adding client.mk options from $FOUND_MOZCONFIG:" >&2 - IFS=^ - for _opt in $opts; do - echo " $_opt" >&2 done } @@ -60,7 +51,6 @@ mk_echo_options() { scriptdir=`dirname $0` topsrcdir=$1 -opts="" # If the path changes, configure should be rerun echo "# PATH=$PATH" @@ -81,10 +71,6 @@ if [ -n $isfoundset ]; then then print_header . "$FOUND_MOZCONFIG" - fi - echo "export FOUND_MOZCONFIG := $FOUND_MOZCONFIG" - - if [ "$opts" ]; then - mk_echo_options + echo "FOUND_MOZCONFIG := $FOUND_MOZCONFIG" fi fi diff --git a/client.mk b/client.mk index 95a0e2513782..f9f7f10d1d2d 100644 --- a/client.mk +++ b/client.mk @@ -114,8 +114,20 @@ endef # As $(shell) doesn't preserve newlines, use sed to replace them with an # unlikely sequence (||), which is then replaced back to newlines by make -# before evaluation. -$(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/'))) +# before evaluation. $(shell) replacing newlines with spaces, || is always +# followed by a space (since sed doesn't remove newlines), except on the +# last line, so replace both '|| ' and '||'. +MOZCONFIG_CONTENT := $(subst ||,$(CR),$(subst || ,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) | sed 's/$$/||/'))) +$(eval $(MOZCONFIG_CONTENT)) + +# As '||' was used as a newline separator, it means it's not occurring in +# lines themselves. It can thus safely be used to replaces normal spaces, +# to then replace newlines with normal spaces. This allows to get a list +# of mozconfig output lines. +MOZCONFIG_OUT_LINES := $(subst $(CR), ,$(subst $(NULL) $(NULL),||,$(MOZCONFIG_CONTENT))) +# Filter-out comments from those lines. +START_COMMENT = \# +MOZCONFIG_OUT_FILTERED := $(filter-out $(START_COMMENT)%,$(MOZCONFIG_OUT_LINES)) ifdef AUTOCLOBBER export AUTOCLOBBER=1 @@ -175,13 +187,35 @@ build:: include $(TOPSRCDIR)/config/makefiles/makeutils.mk include $(TOPSRCDIR)/config/makefiles/autotargets.mk +# Create a makefile containing the mk_add_options values from mozconfig, +# but only do so when OBJDIR is defined (see further above). +ifdef MOZ_BUILD_PROJECTS +ifdef MOZ_CURRENT_PROJECT +WANT_MOZCONFIG_MK = 1 +else +WANT_MOZCONFIG_MK = +endif +else +WANT_MOZCONFIG_MK = 1 +endif + +ifdef WANT_MOZCONFIG_MK +# For now, only output "export" lines from mozconfig2client-mk output. +$(OBJDIR)/.mozconfig.mk: $(FOUND_MOZCONFIG) $(call mkdir_deps,$(OBJDIR)) + ( $(foreach line,$(filter export||%,$(MOZCONFIG_OUT_LINES)), echo "$(subst ||, ,$(line))";) ) > $@ + +# Include that makefile so that it is created. This should not actually change +# the environment since MOZCONFIG_CONTENT, which MOZCONFIG_OUT_LINES derives +# from, has already been eval'ed. +-include $(OBJDIR)/.mozconfig.mk +endif + # Print out any options loaded from mozconfig. all realbuild clean depend distclean export libs install realclean:: - @if test -f .mozconfig.out; then \ - cat .mozconfig.out; \ - rm -f .mozconfig.out; \ - else true; \ - fi +ifneq (,$(strip $(MOZCONFIG_OUT_FILTERED))) + $(info Adding client.mk options from $(FOUND_MOZCONFIG):) + $(foreach line,$(MOZCONFIG_OUT_FILTERED),$(info $(NULL) $(NULL) $(NULL) $(NULL) $(subst ||, ,$(line)))) +endif # Windows equivalents build_all: build diff --git a/config/config.mk b/config/config.mk index 19f9fec32a66..0eca489eef08 100644 --- a/config/config.mk +++ b/config/config.mk @@ -27,6 +27,8 @@ ifndef INCLUDED_AUTOCONF_MK include $(DEPTH)/config/autoconf.mk endif +-include $(DEPTH)/.mozconfig.mk + space = $(NULL) $(NULL) # Include defs.mk files that can be found in $(srcdir)/$(DEPTH), diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 19f9fec32a66..0eca489eef08 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -27,6 +27,8 @@ ifndef INCLUDED_AUTOCONF_MK include $(DEPTH)/config/autoconf.mk endif +-include $(DEPTH)/.mozconfig.mk + space = $(NULL) $(NULL) # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),