Bug 1259381 - Move --with-ccache and --with-compiler-wrapper to moz.configure. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 21:14:59 +0900
changeset 290987 352568360a612b1cca16f2083a981276d3c81502
parent 290986 bd956b7718c96998ed80143b0f77a7f0a1f87281
child 290988 178b2c7228b6527ce26c306c07dde4ed538215b6
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1259381
milestone48.0a1
Bug 1259381 - Move --with-ccache and --with-compiler-wrapper to moz.configure. r=chmanchester
build/autoconf/wrapper.m4
build/moz.configure/init.configure
build/moz.configure/old.configure
build/moz.configure/toolchain.configure
--- a/build/autoconf/wrapper.m4
+++ b/build/autoconf/wrapper.m4
@@ -2,74 +2,24 @@ dnl This Source Code Form is subject to 
 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 dnl =======================================================================
 dnl = Enable compiling with various compiler wrappers (distcc, ccache, etc)
 dnl =======================================================================
 AC_DEFUN([MOZ_CHECK_COMPILER_WRAPPER],
 [
-MOZ_ARG_WITH_STRING(compiler_wrapper,
-[  --with-compiler-wrapper[=path/to/wrapper]
-    Enable compiling with wrappers such as distcc and ccache],
-    COMPILER_WRAPPER=$withval, COMPILER_WRAPPER="no")
-
-MOZ_ARG_WITH_STRING(ccache,
-[  --with-ccache[=path/to/ccache]
-                          Enable compiling with ccache],
-    CCACHE=$withval, CCACHE="no")
-
-if test "$CCACHE" != "no"; then
-    if test -z "$CCACHE" -o "$CCACHE" = "yes"; then
-        CCACHE=
-    else
-        if test ! -e "$CCACHE"; then
-            AC_MSG_ERROR([$CCACHE not found])
-        fi
-    fi
-    MOZ_PATH_PROGS(CCACHE, $CCACHE ccache)
-    if test -z "$CCACHE" -o "$CCACHE" = ":"; then
-        AC_MSG_ERROR([ccache not found])
-    elif test -x "$CCACHE"; then
-        if test "$COMPILER_WRAPPER" != "no"; then
-            COMPILER_WRAPPER="$CCACHE $COMPILER_WRAPPER"
-        else
-            COMPILER_WRAPPER="$CCACHE"
-        fi
-        MOZ_USING_CCACHE=1
-    else
-        AC_MSG_ERROR([$CCACHE is not executable])
-    fi
-fi
-
-AC_SUBST(MOZ_USING_CCACHE)
-
-if test "$COMPILER_WRAPPER" != "no"; then
-    case "$target" in
-    *-mingw*)
-        dnl When giving a windows path with backslashes, js/src/configure
-        dnl fails because of double wrapping because the test further below
-        dnl doesn't work with backslashes. While fixing that test to work
-        dnl might seem better, a lot of the make build backend actually
-        dnl doesn't like backslashes, so normalize windows paths to use
-        dnl forward slashes.
-        COMPILER_WRAPPER=`echo "$COMPILER_WRAPPER" | tr '\\' '/'`
-        ;;
-    esac
-
+if test -n "$COMPILER_WRAPPER"; then
     case "$CC" in
     $COMPILER_WRAPPER\ *)
         :
         ;;
     *)
         CC="$COMPILER_WRAPPER $CC"
         CXX="$COMPILER_WRAPPER $CXX"
         _SUBDIR_CC="$CC"
         _SUBDIR_CXX="$CXX"
         ac_cv_prog_CC="$CC"
         ac_cv_prog_CXX="$CXX"
         ;;
     esac
-    MOZ_USING_COMPILER_WRAPPER=1
 fi
-
-AC_SUBST(MOZ_USING_COMPILER_WRAPPER)
 ])
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -141,16 +141,18 @@ def add_old_configure_assignment(var, va
         if value is None:
             return
         if value is True:
             assignments.append('%s=1' % var)
         elif value is False:
             assignments.append('%s=' % var)
         else:
             from mozbuild.shellutil import quote
+            if isinstance(value, (list, tuple)):
+                value = ' '.join(quote(v) for v in value)
             assignments.append('%s=%s' % (var, quote(value)))
 
 @template
 def add_old_configure_arg(arg):
     @depends(extra_old_configure_args)
     def add_arg(args):
         args.append(arg)
 
@@ -268,16 +270,18 @@ early_options = early_options()
 # moz.configure files are executed, so we keep a manual list here, that is
 # checked in old.configure (we'll assume it's the last moz.configure file
 # processed). This is tedious but necessary for now.
 @depends('--help')
 def wanted_mozconfig_variables(help):
      return set([
          'AUTOCONF',
          'AWK',
+         'CCACHE',
+         'COMPILER_WRAPPER',
          'DISABLE_EXPORT_JS',
          'DISABLE_SHARED_JS',
          'DOXYGEN',
          'DSYMUTIL',
          'EXTERNAL_SOURCE_DIR',
          'GENISOIMAGE',
          'GRADLE',
          'GRADLE_FLAGS',
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -309,18 +309,16 @@ def old_configure_options(*options):
     '--with-android-toolchain',
     '--with-android-version',
     '--with-app-basename',
     '--with-app-name',
     '--with-arch',
     '--with-arm-kuser',
     '--with-bing-api-keyfile',
     '--with-branding',
-    '--with-ccache',
-    '--with-compiler-wrapper',
     '--with-crashreporter-enable-percent',
     '--with-cross-lib',
     '--with-debug-label',
     '--with-default-mozilla-five-home',
     '--with-distribution-id',
     '--with-doc-include-dirs',
     '--with-doc-input-dirs',
     '--with-doc-output-dir',
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -53,8 +53,53 @@ set_config('YASM_ASFLAGS', yasm_asflags)
 @depends(yasm_asflags)
 def have_yasm(value):
     if value:
         return True
 
 set_config('HAVE_YASM', have_yasm)
 # Until the YASM variable is not necessary in old-configure.
 add_old_configure_assignment('YASM', have_yasm)
+
+
+# Compiler wrappers
+# ==============================================================
+js_option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,
+          help='Enable compiling with wrappers such as distcc and ccache')
+
+js_option('--with-ccache', env='CCACHE', nargs='?',
+          help='Enable compiling with ccache')
+
+@depends_if('--with-ccache')
+def ccache(value):
+    if len(value):
+        return value
+    # If --with-ccache was given without an explicit value, we default to
+    # 'ccache'.
+    return 'ccache'
+
+ccache = check_prog('CCACHE', progs=(), input=ccache)
+
+@depends_if(ccache)
+def using_ccache(ccache):
+    return True
+
+set_config('MOZ_USING_CCACHE', using_ccache)
+
+@depends('--with-compiler-wrapper', ccache)
+@advanced
+def compiler_wrapper(wrapper, ccache):
+    from mozbuild.shellutil import split as shell_split
+    if ccache:
+        if wrapper:
+            return tuple([ccache] + shell_split(wrapper[0]))
+        else:
+            return (ccache,)
+    elif wrapper:
+        return tuple(shell_split(wrapper[0]))
+
+add_old_configure_assignment('COMPILER_WRAPPER', compiler_wrapper)
+
+@depends_if(compiler_wrapper)
+def using_compiler_wrapper(compiler_wrapper):
+    return True
+
+set_config('MOZ_USING_COMPILER_WRAPPER', using_compiler_wrapper)