Bug 1256568 - Move perl detection to moz.configure. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 15 Mar 2016 11:23:29 +0900
changeset 288751 4a2a46087a28a0b061f1f68be74d0182910b0c83
parent 288750 c71929474f668a7d47191287d820639ba833926f
child 288752 7fd99a35ac93c34fd9f2a03330942f9763f42c8a
push id30089
push userkwierso@gmail.com
push dateWed, 16 Mar 2016 00:26:08 +0000
treeherdermozilla-central@7773387a9a2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1256568
milestone48.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 1256568 - Move perl detection to moz.configure. r=gps
build/moz.configure/checks.configure
build/moz.configure/init.configure
js/src/old-configure.in
moz.configure
old-configure.in
--- a/build/moz.configure/checks.configure
+++ b/build/moz.configure/checks.configure
@@ -25,17 +25,22 @@
 def checking(what):
     def decorator(func):
         @advanced
         def wrapped(*args, **kwargs):
             import sys
             print('checking', what, end='... ')
             sys.stdout.flush()
             ret = func(*args, **kwargs)
-            print(ret)
+            if ret is True:
+                print('yes')
+            elif ret is False:
+                print('no')
+            else:
+                print(ret)
             sys.stdout.flush()
             return ret
         return wrapped
     return decorator
 
 
 # Template to check for programs in $PATH.
 #   check('PROG', ('a', 'b'))
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -250,16 +250,17 @@ def wanted_mozconfig_variables(help):
          'AUTOCONF',
          'AWK',
          'DISABLE_EXPORT_JS',
          'DISABLE_SHARED_JS',
          'EXTERNAL_SOURCE_DIR',
          'MOZILLABUILD',
          'MOZ_ARTIFACT_BUILDS',
          'MOZ_BUILD_APP',
+         'PERL',
      ])
 
 
 @depends(mozconfig, wanted_mozconfig_variables)
 def mozconfig_options(mozconfig, wanted_mozconfig_variables):
     if mozconfig['path']:
         helper = command_line_helper()
         warn('Adding configure options from %s' % mozconfig['path'])
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -49,17 +49,16 @@ dnl ====================================
 
 dnl Set the version number of the libs included with mozilla
 dnl ========================================================
 NSPR_VERSION=4
 NSPR_MINVER=4.9.2
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
-PERL_VERSION=5.006
 WINDRES_VERSION=2.14.90
 W32API_VERSION=3.14
 
 MSMANIFEST_TOOL=
 
 dnl Set various checks
 dnl ========================================================
 MISSING_X=
@@ -74,22 +73,16 @@ dnl Do not allow objdir == srcdir builds
 dnl ==============================================================
 _topsrcdir=`cd $srcdir; pwd -W 2>/dev/null || pwd -P`
 _objdir=`pwd -P`
 
 MOZ_BUILD_ROOT=`pwd -W 2>/dev/null || pwd -P`
 
 MOZ_DEFAULT_COMPILER
 
-dnl Check for Perl first -- needed for win32 SDK checks
-MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
-if test -z "$PERL" -o "$PERL" = ":"; then
-    AC_MSG_ERROR([perl not found in \$PATH])
-fi
-
 if test "$JS_STANDALONE" = no; then
   autoconfmk=autoconf-js.mk
   JS_STANDALONE=
   #DIST is exported from top-level configure
 else
   JS_STANDALONE=1
   AC_DEFINE(JS_STANDALONE)
   DIST="$MOZ_BUILD_ROOT/dist"
@@ -467,35 +460,16 @@ AC_PROG_LN_S
 AC_MSG_CHECKING([for tar archiver])
 AC_CHECK_PROGS(TAR, gnutar gtar tar, "")
 if test -z "$TAR"; then
     AC_MSG_WARN([no tar archiver found in \$PATH])
 fi
 AC_MSG_RESULT([$TAR])
 AC_SUBST(TAR)
 
-AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
-_perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
-_perl_res=$?
-AC_MSG_RESULT([$_perl_version])
-
-if test "$_perl_res" != 0; then
-    AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
-fi
-
-AC_MSG_CHECKING([for full perl installation])
-_perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
-_perl_res=$?
-if test "$_perl_res" != 0; then
-    AC_MSG_RESULT([no])
-    AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
-else
-    AC_MSG_RESULT([yes])
-fi
-
 if test -z "$COMPILE_ENVIRONMENT"; then
     NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
 fi
 AC_SUBST(NSINSTALL_BIN)
 
 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
 MOZ_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" -o "$XARGS" = ":"; then
--- a/moz.configure
+++ b/moz.configure
@@ -62,10 +62,54 @@ def build_backend(backends, artifact_bui
 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
 
 # Until the AWK variable is not necessary in old-configure
 @depends(awk)
 def awk_for_old_configure(value):
     add_old_configure_assignment('AWK', value)
 
 
+# Perl detection
+# ==============================================================
+perl = check_prog('PERL', ('perl5', 'perl'))
+
+# Until the PERL variable is not necessary in old-configure
+@depends(perl)
+def perl_for_old_configure(value):
+    add_old_configure_assignment('PERL', value)
+
+@template
+def perl_version_check(min_version):
+    @depends(perl)
+    @checking('for minimum required perl version >= %s' % min_version)
+    @advanced
+    def get_perl_version(perl):
+        import subprocess
+        try:
+            return subprocess.check_output([perl, '-e', 'print $]'])
+        except subprocess.CalledProcessError as e:
+            error('Failed to get perl version: %s' % e.message)
+
+    @depends(get_perl_version)
+    def check_perl_version(version):
+        if version < min_version:
+            error('Perl %s or higher is required.' % min_version)
+
+    @depends(perl)
+    @checking('for full perl installation')
+    @advanced
+    def has_full_perl_installation(perl):
+        import subprocess
+        ret = subprocess.call(
+            [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
+        return ret == 0
+
+    @depends(has_full_perl_installation)
+    def require_full_perl_installation(has_full_perl_installation):
+        if not has_full_perl_installation:
+            error('Cannot find Config.pm or $Config{archlib}. '
+                  'A full perl installation is required.')
+
+perl_version_check('5.006')
+
+
 # Fallthrough to autoconf-based configure
 include('build/moz.configure/old.configure')
--- a/old-configure.in
+++ b/old-configure.in
@@ -58,17 +58,16 @@ NSS_VERSION=3
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
 GLIB_VERSION=2.22
 # 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
 # The macro won't be used when compiling with earlier versions anyway.
 GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
 GIO_VERSION=2.22
-PERL_VERSION=5.006
 CAIRO_VERSION=1.10
 PANGO_VERSION=1.22.0
 GTK2_VERSION=2.18.0
 GTK3_VERSION=3.4.0
 GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4
 WINDRES_VERSION=2.14.90
 W32API_VERSION=3.14
 GNOMEUI_VERSION=2.2.0
@@ -109,22 +108,16 @@ if test -n "$L10NBASEDIR"; then
     elif test -d "$L10NBASEDIR"; then
         L10NBASEDIR=`cd "$L10NBASEDIR" && pwd -P`
     else
         AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
     fi
 fi
 AC_SUBST(L10NBASEDIR)
 
-dnl Check for Perl first -- needed for win32 SDK checks
-MOZ_PATH_PROGS(PERL, $PERL perl5 perl )
-if test -z "$PERL" -o "$PERL" = ":"; then
-    AC_MSG_ERROR([perl not found in \$PATH])
-fi
-
 if test -n "$MOZTTDIR" -a ! -d "$MOZTTDIR" ; then
     AC_MSG_ERROR([MOZTTDIR '$MOZTTDIR' isn't a valid directory])
 fi
 
 AC_SUBST(MOZTTDIR)
 if test -n "$MOZTTDIR" ; then
     AC_DEFINE(PACKAGE_MOZTT)
 fi
@@ -696,35 +689,16 @@ AC_SUBST(WRAP_STL_INCLUDES)
 AC_SUBST(MOZ_MSVC_STL_WRAP_RAISE)
 
 dnl ========================================================
 dnl Checks for programs.
 dnl ========================================================
 AC_PROG_INSTALL
 AC_PROG_LN_S
 
-AC_MSG_CHECKING([for minimum required perl version >= $PERL_VERSION])
-_perl_version=`PERL_VERSION=$PERL_VERSION $PERL -e 'print "$]"; if ($] >= $ENV{PERL_VERSION}) { exit(0); } else { exit(1); }' 2>&5`
-_perl_res=$?
-AC_MSG_RESULT([$_perl_version])
-
-if test "$_perl_res" != 0; then
-    AC_MSG_ERROR([Perl $PERL_VERSION or higher is required.])
-fi
-
-AC_MSG_CHECKING([for full perl installation])
-_perl_archlib=`$PERL -e 'use Config; if ( -d $Config{archlib} ) { exit(0); } else { exit(1); }' 2>&5`
-_perl_res=$?
-if test "$_perl_res" != 0; then
-    AC_MSG_RESULT([no])
-    AC_MSG_ERROR([Cannot find Config.pm or \$Config{archlib}.  A full perl installation is required.])
-else
-    AC_MSG_RESULT([yes])
-fi
-
 if test -z "$COMPILE_ENVIRONMENT"; then
     NSINSTALL_BIN='$(PYTHON) $(MOZILLA_DIR)/config/nsinstall.py'
 fi
 AC_SUBST(NSINSTALL_BIN)
 
 MOZ_PATH_PROG(DOXYGEN, doxygen, :)
 MOZ_PATH_PROGS(UNZIP, unzip)
 if test -z "$UNZIP" -o "$UNZIP" = ":"; then