Bug 1422859 - move MOZILLA_*VERSION setting into moz.configure; r=chmanchester
authorNathan Froyd <froydnj@mozilla.com>
Mon, 04 Dec 2017 11:19:25 -0500
changeset 450440 dbe0c741aa32a9847ac6ad4cf5ebe1bfc93f32dc
parent 450439 bb8056c405856f8ec9459956cd01428891a5b407
child 450441 c237e10a08aa185f17cbed0d7eeedd9173a2cfe3
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1422859
milestone59.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 1422859 - move MOZILLA_*VERSION setting into moz.configure; r=chmanchester This has the virtue of not executing python three times during configure just to read the same value of milestone.txt and munge it. We can also remove milestone.py as a happy side effect, so all the milestone computations can be done in init.configure.
build/moz.configure/init.configure
config/milestone.txt
js/src/old-configure.in
old-configure.in
python/mozbuild/mozbuild/milestone.py
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -989,43 +989,63 @@ add_old_configure_assignment('MOZ_BUILD_
 
 # set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
 # The logic works like this:
 # - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
 # - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
 # - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
 @depends(check_build_environment, '--help')
 @imports(_from='__builtin__', _import='open')
+@imports('re')
 def milestone(build_env, _):
     milestone_path = os.path.join(build_env.topsrcdir,
                                   'config',
                                   'milestone.txt')
     with open(milestone_path, 'r') as fh:
         milestone = fh.read().splitlines()[-1]
 
     is_nightly = is_release_or_beta = None
 
     if 'a1' in milestone:
         is_nightly = True
     elif 'a' not in milestone:
         is_release_or_beta = True
 
+    major_version = milestone.split('.')[0]
+    m = re.search(r"([ab]\d+)", milestone)
+    ab_patch = m.group(1) if m else ''
+
+    # Only expose the major version milestone in the UA string and hide the
+    # patch leve (bugs 572659 and 870868).
+    #
+    # Only expose major milestone and alpha version in the symbolversion
+    # string; as the name suggests, we use it for symbol versioning on Linux.
     return namespace(version=milestone,
+                     uaversion='%s.0' % major_version,
+                     symbolversion='%s%s' % (major_version, ab_patch),
                      is_nightly=is_nightly,
                      is_release_or_beta=is_release_or_beta)
 
 
 set_config('GRE_MILESTONE', milestone.version)
 set_config('NIGHTLY_BUILD', milestone.is_nightly)
 set_define('NIGHTLY_BUILD', milestone.is_nightly)
 add_old_configure_assignment('NIGHTLY_BUILD', milestone.is_nightly)
 set_config('RELEASE_OR_BETA', milestone.is_release_or_beta)
 set_define('RELEASE_OR_BETA', milestone.is_release_or_beta)
 add_old_configure_assignment('RELEASE_OR_BETA',
                              milestone.is_release_or_beta)
+set_define('MOZILLA_VERSION', depends(milestone)(lambda m: '"%s"' % m.version))
+set_config('MOZILLA_VERSION', milestone.version)
+set_define('MOZILLA_VERSION_U', milestone.version)
+set_define('MOZILLA_UAVERSION', depends(milestone)(lambda m: '"%s"' % m.uaversion))
+set_config('MOZILLA_SYMBOLVERSION', milestone.symbolversion)
+# JS configure still wants to look at these.
+add_old_configure_assignment('MOZILLA_VERSION', milestone.version)
+add_old_configure_assignment('MOZILLA_SYMBOLVERSION', milestone.symbolversion)
 
 # The app update channel is 'default' when not supplied. The value is used in
 # the application's confvars.sh (and is made available to a project specific
 # moz.configure).
 option('--enable-update-channel',
        nargs=1,
        help='Select application update channel',
        default='default')
--- a/config/milestone.txt
+++ b/config/milestone.txt
@@ -1,13 +1,13 @@
 # Holds the current milestone.
 # Should be in the format of
 #
 #    x.x.x
 #    x.x.x.x
 #    x.x.x+
 #
-# Referenced by milestone.py.
+# Referenced by build/moz.configure/init.configure.
 # Hopefully I'll be able to automate replacement of *all*
 # hardcoded milestones in the tree from these two files.
 #--------------------------------------------------------
 
 59.0a1
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -351,31 +351,16 @@ tools are selected during the Xcode/Deve
 fi
 
 AC_PATH_XTRA
 
 XCFLAGS="$X_CFLAGS"
 
 fi # COMPILE_ENVIRONMENT
 
-dnl ==============================================================
-dnl Get mozilla version from central milestone file
-dnl ==============================================================
-MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
-MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
-MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
-if test -z "$MOZILLA_VERSION"; then
-  AC_MSG_ERROR([failed to read version info from milestone file])
-fi
-
-AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
-AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
-AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
-AC_SUBST(MOZILLA_SYMBOLVERSION)
-
 # Separate version into components for use in shared object naming etc
 changequote(,)
 MOZJS_MAJOR_VERSION=`echo $MOZILLA_VERSION | sed "s|\(^[0-9]*\)\.[0-9]*.*|\1|"`
 MOZJS_MINOR_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.\([0-9]*\).*|\1|"`
 MOZJS_PATCH_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9]*[^0-9]*||"`
 IS_ALPHA=`echo $MOZILLA_VERSION | grep '[ab]'`
 
 dnl XXX in a temporary bid to avoid developer anger at renaming files
@@ -1921,18 +1906,16 @@ fi
 dnl ========================================================
 dnl JavaScript shell
 dnl ========================================================
 
 MOZ_CHECK_ALLOCATOR
 
 AC_CHECK_FUNCS(setlocale localeconv)
 
-AC_SUBST(MOZILLA_VERSION)
-
 AC_SUBST(ac_configure_args)
 
 if test -n "$JS_STANDALONE"; then
 MOZ_APP_NAME="mozjs"
 MOZ_APP_VERSION="$MOZILLA_SYMBOLVERSION"
 JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION"
 else
 JS_LIBRARY_NAME="mozjs"
--- a/old-configure.in
+++ b/old-configure.in
@@ -743,43 +743,28 @@ case "$host" in
     ;;
 
 *)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
     HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
     ;;
 esac
 
-dnl ==============================================================
-dnl Get mozilla version from central milestone file
-dnl ==============================================================
-MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir`
-MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion`
-MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion`
-if test -z "$MOZILLA_VERSION"; then
-  AC_MSG_ERROR([failed to read version info from milestone file])
-fi
-
 dnl Get version of various core apps from the version files.
 FIREFOX_VERSION=`cat $_topsrcdir/browser/config/version.txt`
 FIREFOX_VERSION_DISPLAY=`cat $_topsrcdir/browser/config/version_display.txt`
 
 if test -z "$FIREFOX_VERSION"; then
     AC_MSG_ERROR([FIREFOX_VERSION is unexpectedly blank.])
 fi
 
 if test -z "$FIREFOX_VERSION_DISPLAY"; then
     AC_MSG_ERROR([FIREFOX_VERSION_DISPLAY is unexpectedly blank.])
 fi
 
-AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION")
-AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION)
-AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION")
-AC_SUBST(MOZILLA_SYMBOLVERSION)
-
 MOZ_DOING_LTO(lto_is_enabled)
 
 dnl ========================================================
 dnl System overrides of the defaults for target
 dnl ========================================================
 
 case "$target" in
 *-darwin*)
@@ -4838,18 +4823,16 @@ aurora|beta|release|esr)
     A11Y_LOG=1
     ;;
 esac
 AC_SUBST(A11Y_LOG)
 if test -n "$A11Y_LOG"; then
     AC_DEFINE(A11Y_LOG)
 fi
 
-AC_SUBST(MOZILLA_VERSION)
-
 dnl Spit out some output
 dnl ========================================================
 
 dnl The following defines are used by xpcom
 _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES
 CPP_THROW_NEW
 HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
 HAVE_GETPAGESIZE
deleted file mode 100644
--- a/python/mozbuild/mozbuild/milestone.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from __future__ import absolute_import, print_function, unicode_literals
-
-import argparse
-import os
-import re
-import sys
-
-
-def get_milestone_ab_with_num(milestone):
-    """
-    Returns the alpha and beta tag with its number (a1, a2, b3, ...).
-    """
-
-    match = re.search(r"([ab]\d+)", milestone)
-    if match:
-        return match.group(1)
-
-    return ""
-
-
-def get_official_milestone(path):
-    """
-    Returns the contents of the first line in `path` that starts with a digit.
-    """
-
-    with open(path) as fp:
-        for line in fp:
-            line = line.strip()
-            if line[:1].isdigit():
-                return line
-
-    raise Exception("Didn't find a line that starts with a digit.")
-
-
-def get_milestone_major(milestone):
-    """
-    Returns the major (first) part of the milestone.
-    """
-
-    return milestone.split('.')[0]
-
-
-def main(args):
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--uaversion', default=False, action='store_true')
-    parser.add_argument('--symbolversion', default=False, action='store_true')
-    parser.add_argument('--topsrcdir', metavar='TOPSRCDIR', required=True)
-    options = parser.parse_args(args)
-
-    milestone_file = os.path.join(options.topsrcdir, 'config', 'milestone.txt')
-
-    milestone = get_official_milestone(milestone_file)
-
-    if options.uaversion:
-        # Only expose the major milestone in the UA string, hide the patch
-        # level (bugs 572659 and 870868).
-        uaversion = "%s.0" % (get_milestone_major(milestone),)
-        print(uaversion)
-
-    elif options.symbolversion:
-        # Only expose major milestone and alpha version. Used for symbol
-        # versioning on Linux.
-        symbolversion = "%s%s" % (get_milestone_major(milestone),
-                                  get_milestone_ab_with_num(milestone))
-        print(symbolversion)
-    else:
-        print(milestone)
-
-
-if __name__ == '__main__':
-    main(sys.argv[1:])