Bug 681659 - Execute mozconfig-find just once and make sure mozconfig detection errors are handled properly. r=ted
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Fri, 09 Sep 2011 02:00:31 +0530
changeset 78045 57d1c50198050d7afdbb28f25a5af803a73c0677
parent 78044 65c007c580a8d103a551c14431ce0ceebc6b5dc4
child 78046 53f66dd0ebdd4b30e0e4255fa8e5738292fec86e
push idunknown
push userunknown
push dateunknown
reviewersted
bugs681659
milestone9.0a1
Bug 681659 - Execute mozconfig-find just once and make sure mozconfig detection errors are handled properly. r=ted
build/autoconf/mozconfig-find
build/autoconf/mozconfig2client-mk
build/autoconf/mozconfig2configure
--- a/build/autoconf/mozconfig-find
+++ b/build/autoconf/mozconfig-find
@@ -64,27 +64,27 @@ abspath() {
     fi
   done
 
   # If we're at this point, we have a relative path
   echo `pwd`/$1
 }
 
 if [ -n "$MOZCONFIG" ] && ! [ -f "$MOZCONFIG" ]; then
-  echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!"
+  echo "Specified MOZCONFIG \"$MOZCONFIG\" does not exist!" 1>&2
   exit 1
 fi
 
 if [ -n "$MOZ_MYCONFIG" ]; then
-  echo "Your environment currently has the MOZ_MYCONFIG variable set to \"$MOZ_MYCONFIG\". MOZ_MYCONFIG is no longer supported. Please use MOZCONFIG instead."
+  echo "Your environment currently has the MOZ_MYCONFIG variable set to \"$MOZ_MYCONFIG\". MOZ_MYCONFIG is no longer supported. Please use MOZCONFIG instead." 1>&2
   exit 1
 fi
 
 if [ -z "$MOZCONFIG" ] && [ -f "$topsrcdir/.mozconfig" ] && [ -f "$topsrcdir/mozconfig" ]; then
-  echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other."
+  echo "Both \$topsrcdir/.mozconfig and \$topsrcdir/mozconfig are supported, but you must choose only one. Please remove the other." 1>&2
   exit 1
 fi
 
 for _config in "$MOZCONFIG" \
                "$topsrcdir/.mozconfig" \
                "$topsrcdir/mozconfig"
 do
   if test -f "$_config"; then
@@ -98,12 +98,12 @@ done
 # find any.
 for _config in "$topsrcdir/mozconfig.sh" \
                "$topsrcdir/myconfig.sh" \
                "$HOME/.mozconfig" \
                "$HOME/.mozconfig.sh" \
                "$HOME/.mozmyconfig.sh"
 do
   if test -f "$_config"; then
-    echo "You currently have a mozconfig at \"$_config\". This implicit location is no longer supported. Please move it to $topsrcdir/.mozconfig or specify it explicitly via \$MOZCONFIG.";
+    echo "You currently have a mozconfig at \"$_config\". This implicit location is no longer supported. Please move it to $topsrcdir/.mozconfig or specify it explicitly via \$MOZCONFIG." 1>&2
     exit 1
   fi
 done
--- a/build/autoconf/mozconfig2client-mk
+++ b/build/autoconf/mozconfig2client-mk
@@ -17,16 +17,17 @@
 #
 # The Initial Developer of the Original Code is
 # Netscape Communications Corporation.
 # Portions created by the Initial Developer are Copyright (C) 1999
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Stephen Lamm <slamm@netscape.com>
+#   Siddharth Agarwal <sagarwal@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either of the GNU General Public License Version 2 or later (the "GPL"),
 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -87,29 +88,41 @@ mk_echo_options() {
 scriptdir=`dirname $0`
 topsrcdir=$1
 out_file=$2
 tmp_file="$out_file-tmp$$"
 opts=""
 
 trap "rm -f $tmp_file; exit 1" 1 2 15
 
-MOZCONFIG=`$scriptdir/mozconfig-find $topsrcdir`
-
 print_header > $tmp_file
 
 # If the path changes, configure should be rerun
 echo "# PATH=$PATH" >> $tmp_file
 
-if [ "$MOZCONFIG" ]
-then
-  . "$MOZCONFIG"
+# 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
+  else
+    isfoundset=yes
+  fi
 fi
 
-if [ "$opts" ]; then
-  mk_echo_options
+if [ -n $isfoundset ]; then
+  if [ "$FOUND_MOZCONFIG" ]
+  then
+    . "$FOUND_MOZCONFIG"
+  fi
+  echo "export FOUND_MOZCONFIG := $FOUND_MOZCONFIG" >> $tmp_file
+
+  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/build/autoconf/mozconfig2configure
+++ b/build/autoconf/mozconfig2configure
@@ -17,16 +17,17 @@
 #
 # The Initial Developer of the Original Code is
 # Netscape Communications Corporation.
 # Portions created by the Initial Developer are Copyright (C) 1999
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Stephen Lamm <slamm@netscape.com>
+#   Siddharth Agarwal <sagarwal@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either of the GNU General Public License Version 2 or later (the "GPL"),
 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -108,19 +109,29 @@ mozconfig_ac_options=
 # Save the real command-line options
 for _opt
 do
   # Escape shell characters, space, tab, dollar, quote, backslash.
   _opt=`echo $_opt | sed -e 's/\([\ \	\$\"\\]\)/\\\\\1/g;'`
   ac_options="$ac_options \"$_opt\""
 done
 
-MOZCONFIG=`$_AUTOCONF_TOOLS_DIR/mozconfig-find $topsrcdir`
-if [ "$MOZCONFIG" ]; then
-  . "$MOZCONFIG"
+
+# 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=`$_AUTOCONF_TOOLS_DIR/mozconfig-find $topsrcdir`
+  if [ $? -ne 0 ]; then
+    echo "Fix above errors before continuing." 1>&2
+    exit 1
+  fi
 fi
 
+if [ "$FOUND_MOZCONFIG" ]; then
+  . "$FOUND_MOZCONFIG"
+fi
+export FOUND_MOZCONFIG
+
 if [ "$mozconfig_ac_options" ]; then
   ac_echo_options 1>&2
 fi
 
 eval "set -- $mozconfig_ac_options $ac_options"
-