Bug 762358 - Don't create a .mozconfig.mk file, and re-run configure when .mozconfig changed. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Jun 2012 09:12:43 +0200
changeset 97000 aa9532ebf77de38cb7a5348d41bb8356f3d1d134
parent 96999 a367517095e3c118f67f01d35ad6be07c4fa51d8
child 97001 86cf33eb20091690db75b83a676c61c95c04579a
push id10817
push usermh@glandium.org
push dateTue, 19 Jun 2012 07:16:59 +0000
treeherdermozilla-inbound@31e9fbf97eb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs762358
milestone16.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 762358 - Don't create a .mozconfig.mk file, and re-run configure when .mozconfig changed. r=ted
build/autoconf/mozconfig2client-mk
client.mk
--- a/build/autoconf/mozconfig2client-mk
+++ b/build/autoconf/mozconfig2client-mk
@@ -6,87 +6,77 @@
 
 # mozconfig2client-mk - Translates .mozconfig into options for client.mk.
 #    Prints defines to stdout.
 #
 # See mozconfig2configure for more details
 
 print_header() {
   _mozconfig=${MOZCONFIG:-$HOME/.mozconfig}
-  cat >> $tmp_file <<EOF
+  cat <<EOF
 # gmake
 # This file is automatically generated for client.mk.
 # Do not edit. Edit $_mozconfig instead.
 
 EOF
 }
 
 ac_add_options() {
-  echo "# $* is used by configure (not client.mk)" >> $tmp_file
+  echo "# $* is used by configure (not client.mk)"
 }
 
 ac_add_app_options() {
-  echo "# $* is used by configure (not client.mk)" >> $tmp_file
+  echo "# $* is used by configure (not client.mk)"
 }
 
 mk_add_options() {
   for _opt
   do
     # Escape shell characters, space, tab, dollar, quote, backslash,
     # and substitute '@<word>@' with '$(<word>)'.
     _opt=`echo "$_opt" | sed -e 's/\([\"\\]\)/\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'`
     echo $_opt;
     opts="${opts:+$opts^}$_opt";
-  done >> $tmp_file
+  done
 }
 
 mk_echo_options() {
-  echo "Adding client.mk options from $FOUND_MOZCONFIG:"
+  echo "Adding client.mk options from $FOUND_MOZCONFIG:" >&2
   IFS=^
   for _opt in $opts; do
-    echo "    $_opt"
+    echo "    $_opt" >&2
   done
 }
 
 # Main
 #--------------------------------------------------
 
 scriptdir=`dirname $0`
 topsrcdir=$1
-out_file=$2
-tmp_file="$out_file-tmp$$"
 opts=""
 
-trap "rm -f $tmp_file; exit 1" 1 2 15
-
-print_header > $tmp_file
+print_header
 
 # If the path changes, configure should be rerun
-echo "# PATH=$PATH" >> $tmp_file
+echo "# PATH=$PATH"
 
 # If FOUND_MOZCONFIG isn't set, look for it and make sure the script doesn't error out
 isfoundset=${FOUND_MOZCONFIG+yes}
 if [ -z $isfoundset ]; then
   FOUND_MOZCONFIG=`$scriptdir/mozconfig-find $topsrcdir`
   if [ $? -ne 0 ]; then
-    echo '$(error Fix above errors before continuing.)' >> $tmp_file
+    echo '$(error Fix above errors before continuing.)'
   else
     isfoundset=yes
   fi
 fi
 
 if [ -n $isfoundset ]; then
   if [ "$FOUND_MOZCONFIG" ]
   then
     . "$FOUND_MOZCONFIG"
   fi
-  echo "export FOUND_MOZCONFIG := $FOUND_MOZCONFIG" >> $tmp_file
+  echo "export FOUND_MOZCONFIG := $FOUND_MOZCONFIG"
 
   if [ "$opts" ]; then
     mk_echo_options
   fi
 fi
-
-if test -f $out_file && cmp -s $tmp_file $out_file; then
-  rm $tmp_file
-else
-  mv -f $tmp_file $out_file
-fi
--- a/client.mk
+++ b/client.mk
@@ -90,20 +90,25 @@ endif
 # Load mozconfig Options
 
 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
 
 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
 MOZCONFIG_FINDER := build/autoconf/mozconfig-find 
 MOZCONFIG_MODULES := build/unix/uniq.pl
 
-run_for_side_effects := \
-  $(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
+define CR
+
+
+endef
 
-include $(TOPSRCDIR)/.mozconfig.mk
+# 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 $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
 
 ifndef MOZ_OBJDIR
   MOZ_OBJDIR = obj-$(CONFIG_GUESS)
 else
 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
   ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
   ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
   $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
@@ -288,17 +293,17 @@ configure-files: $(CONFIGURES)
 
 configure-preqs = \
   configure-files \
   $(call mkdir_deps,$(OBJDIR)) \
   $(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
   save-mozconfig \
   $(NULL)
 
-save-mozconfig:
+save-mozconfig: $(FOUND_MOZCONFIG)
 	-cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
 
 configure:: $(configure-preqs)
 	@echo cd $(OBJDIR);
 	@echo $(CONFIGURE) $(CONFIGURE_ARGS)
 	@cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
 	  || ( echo "*** Fix above errors and then restart with\
                \"$(MAKE) -f client.mk build\"" && exit 1 )