Bug 1290044 - Moved NSIS configure to Python. r?glandium draft
authorNathan Hakkakzadeh <nhakkakzadeh@mozilla.com>
Thu, 28 Jul 2016 17:39:24 -0700
changeset 394327 2d1f803bef4c1698bc6b2c7f5fb2e273a0f95218
parent 393861 9ec789c0ee5bd3a5e765513c21027fdad953b022
child 526799 3b22519da7b7a61943593f2ad8a3fa8f3474d8f8
push id24559
push userbmo:nhakkakzadeh@mozilla.com
push dateFri, 29 Jul 2016 17:45:45 +0000
reviewersglandium
bugs1290044
milestone50.0a1
Bug 1290044 - Moved NSIS configure to Python. r?glandium MozReview-Commit-ID: 6JFR5K1XDBr
moz.configure
old-configure.in
--- a/moz.configure
+++ b/moz.configure
@@ -223,11 +223,38 @@ option('--enable-system-hunspell',
 def check_for_hunspell(value, compile_env):
     return value and compile_env
 
 system_hunspell = pkg_check_modules('MOZ_HUNSPELL', 'hunspell',
                                     check_for_hunspell)
 
 set_config('MOZ_SYSTEM_HUNSPELL', system_hunspell)
 
+
+nsis = check_prog('MAKENSISU', ('makensis-3.0b3.exe', 'makensis-3.0b1.exe', 'makensis.exe', 'makensis'))
+
+# Make sure the version of makensis is up to date.
+@depends_win(nsis)
+@checking('for NSIS version >= %s' % '3.0b1')
+@imports('re')
+@imports('subprocess')
+def valid_nsis(nsis):
+    nsis_min_version = '3.0b1'
+    try:
+        out = subprocess.check_output([nsis, '-version'])
+        m = re.search(r'(?<=v)[0-9]+\.[0-9]+(a|b|rc)*[0-9]*', out)
+
+        out_of_date_msg = 'To build the installer you must have NSIS version %s or greater in your path' % nsis_min_version
+        if not m:
+            raise FatalCheckError('Unknown version of makensis')
+        ver = Version(m.string.lstrip('v'))
+
+        if ver < nsis_min_version:
+            raise FatalCheckError(out_of_date_msg)
+
+        return nsis
+    except subprocess.CalledProcessError:
+        pass
+
+
 # Fallthrough to autoconf-based configure
 include('build/moz.configure/old.configure')
 # Please do not add anything after the include of old.configure.
--- a/old-configure.in
+++ b/old-configure.in
@@ -4269,72 +4269,16 @@ if test -n "$MOZ_TREE_FREETYPE"; then
    CAIRO_FT_CFLAGS="-I$_topsrcdir/modules/freetype2/include"
    CAIRO_FT_OSLIBS=''
    AC_DEFINE(HAVE_FT_BITMAP_SIZE_Y_PPEM)
    AC_DEFINE(HAVE_FT_GLYPHSLOT_EMBOLDEN)
    AC_DEFINE(HAVE_FT_LOAD_SFNT_TABLE)
    AC_SUBST_LIST(CAIRO_FT_CFLAGS)
 fi
 
-dnl ========================================================
-dnl Installer
-dnl ========================================================
-dnl Abort Windows build if the required major version and
-dnl minimum minor version of Unicode NSIS isn't in the path
-dnl (unless in case of cross compiling, for which Unicode
-dnl is not yet sufficient).
-if test "$OS_ARCH" = "WINNT"; then
-    MIN_NSIS_MAJOR_VER=3
-    MIN_NSIS_MINOR_VER=0
-    MIN_NSIS_PRERELEASE_TYPE=b
-    MIN_NSIS_PRERELEASE_VER=1
-    MOZ_PATH_PROGS(MAKENSISU, $MAKENSISU makensis-3.0b3.exe makensis-3.0b1.exe makensis)
-    if test -n "$MAKENSISU" -a "$MAKENSISU" != ":"; then
-      AC_MSG_RESULT([yes])
-      MAKENSISU_VER=`"$MAKENSISU" -version 2>/dev/null`
-      changequote(,)
-      MAKENSISU_PARSED_VER=`echo "$MAKENSISU_VER" | sed -e 's/^v\([0-9]\+\.[0-9]\+\).*$/\1/g'`
-      changequote([,])
-      MAKENSISU_MAJOR_VER=0
-      MAKENSISU_MINOR_VER=0
-      MAKENSISU_PRERELEASE_TYPE=$MIN_NSIS_PRERELEASE_TYPE
-      MAKENSISU_PRERELEASE_VER=$MIN_NSIS_PRERELEASE_VER
-      if test ! "$MAKENSISU_PARSED_VER" = ""; then
-          MAKENSISU_MAJOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $1 }'`
-          MAKENSISU_MINOR_VER=`echo $MAKENSISU_PARSED_VER | $AWK -F\. '{ print $2 }'`
-          changequote(,)
-          MAKENSISU_PARSED_PRERELEASE=`echo "$MAKENSISU_VER" | sed -e 's/^v[0-9]\+\.[0-9]\+\([^0-9]\+\)\([0-9]\+\).*$/\1.\2/g'`
-          changequote([,])
-          if test ! "$MAKENSISU_PARSED_PRERELEASE" = "$MAKENSISU_VER"; then
-              MAKENSISU_PRERELEASE_TYPE=`echo $MAKENSISU_PARSED_PRERELEASE | $AWK -F\. '{ print $1 }'`
-              MAKENSISU_PRERELEASE_VER=`echo $MAKENSISU_PARSED_PRERELEASE | $AWK -F\. '{ print $2 }'`
-          fi
-      fi
-      AC_MSG_CHECKING([for NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER$MIN_NSIS_PRERELEASE_TYPE$MIN_NSIS_PRERELEASE_VER or greater])
-      if test "$MAKENSISU_MAJOR_VER" -eq $MIN_NSIS_MAJOR_VER -a \
-              "$MAKENSISU_MINOR_VER" -ge $MIN_NSIS_MINOR_VER -a \
-              "$MAKENSISU_PRERELEASE_TYPE" = "$MIN_NSIS_PRERELEASE_TYPE" -a \
-              "$MAKENSISU_PRERELEASE_VER" -ge $MIN_NSIS_PRERELEASE_VER; then
-          AC_MSG_RESULT([yes])
-          AC_MSG_RESULT([Found NSIS Version: $MAKENSISU_VER])
-      else
-          AC_MSG_RESULT([no])
-          if test -z "$CROSS_COMPILE"; then
-            AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER$MIN_NSIS_PRERELEASE_TYPE$MIN_NSIS_PRERELEASE_VER or greater in your path.])
-          else
-            MAKENSISU=
-          fi
-      fi
-    elif test -z "$CROSS_COMPILE"; then
-      AC_MSG_ERROR([To build the installer you must have the latest MozillaBuild or NSIS version $MIN_NSIS_MAJOR_VER.$MIN_NSIS_MINOR_VER$MIN_NSIS_PRERELEASE_TYPE$MIN_NSIS_PRERELEASE_VER or greater in your path.])
-    else
-      MAKENSISU=
-    fi
-fi
-
 AC_CHECK_PROGS(WGET, wget, "")
 AC_SUBST(WGET)
 
 dnl ========================================================
 dnl Maintenance Service
 dnl ========================================================
 
 MOZ_ARG_ENABLE_BOOL(maintenance-service,