Bug 1354581 - Move enable-release / MOZILLA_OFFICIAL / MOZ_INCLUDE_SOURCE_INFO support into the python configure r?glandium draft
authorSylvestre Ledru <sledru@mozilla.com>
Fri, 07 Apr 2017 18:12:45 +0200
changeset 576910 5cffd6f7e753d21b27a321b65587e5553a4a9ba4
parent 576909 1944785ec6254237f1425dc35f873951c7716d39
child 628347 3d5db1a8096efb4bbba7a80833d4bb0279eee31f
push id58521
push userbmo:sledru@mozilla.com
push dateFri, 12 May 2017 13:23:58 +0000
reviewersglandium
bugs1354581
milestone55.0a1
Bug 1354581 - Move enable-release / MOZILLA_OFFICIAL / MOZ_INCLUDE_SOURCE_INFO support into the python configure r?glandium MozReview-Commit-ID: GP0smX8AWcu
build/autoconf/compiler-opts.m4
build/moz.configure/old.configure
build/moz.configure/toolchain.configure
moz.configure
old-configure.in
python/mozbuild/mozbuild/test/configure/test_moz_configure.py
--- a/build/autoconf/compiler-opts.m4
+++ b/build/autoconf/compiler-opts.m4
@@ -1,25 +1,16 @@
 dnl This Source Code Form is subject to the terms of the Mozilla Public
 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 Add compiler specific options
 
 AC_DEFUN([MOZ_DEFAULT_COMPILER],
 [
-dnl set DEVELOPER_OPTIONS early; MOZ_DEFAULT_COMPILER is usually the first non-setup directive
-  if test -z "$MOZILLA_OFFICIAL"; then
-    DEVELOPER_OPTIONS=1
-  fi
-  MOZ_ARG_ENABLE_BOOL(release,
-  [  --enable-release        Build with more conservative, release engineering-oriented options.
-                          This may slow down builds.],
-      DEVELOPER_OPTIONS=,
-      DEVELOPER_OPTIONS=1)
 
 dnl Default to MSVC for win32 and gcc-4.2 for darwin
 dnl ==============================================================
 if test -z "$CROSS_COMPILE"; then
 case "$target" in
 *-mingw*)
     if test -z "$CPP"; then CPP="$CC -E -nologo"; fi
     if test -z "$CXXCPP"; then CXXCPP="$CXX -TP -E -nologo"; ac_cv_prog_CXXCPP="$CXXCPP"; fi
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -206,17 +206,16 @@ def old_configure_options(*options):
     '--enable-pie',
     '--enable-png-arm-neon-support',
     '--enable-posix-nspr-emulation',
     '--enable-pref-extensions',
     '--enable-pulseaudio',
     '--enable-raw',
     '--enable-readline',
     '--enable-reflow-perf',
-    '--enable-release',
     '--enable-safe-browsing',
     '--enable-sandbox',
     '--enable-signmar',
     '--enable-simulator',
     '--enable-small-chunk-size',
     '--enable-startup-notification',
     '--enable-startupcache',
     '--enable-stdcxx-compat',
--- a/build/moz.configure/toolchain.configure
+++ b/build/moz.configure/toolchain.configure
@@ -989,24 +989,57 @@ def wrap_system_includes(target, visibil
 
 set_define('HAVE_VISIBILITY_HIDDEN_ATTRIBUTE',
            depends(visibility_flags)(lambda v: bool(v) or None))
 set_define('HAVE_VISIBILITY_ATTRIBUTE',
            depends(visibility_flags)(lambda v: bool(v) or None))
 set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes)
 set_config('VISIBILITY_FLAGS', visibility_flags)
 
+
 # We only want to include windows.configure when we are compiling on
 # Windows, for Windows.
 @depends(target, host)
 def is_windows(target, host):
     return host.kernel == 'WINNT' and target.kernel == 'WINNT'
 
 include('windows.configure', when=is_windows)
 
+js_option('--enable-release', env='DEVELOPER_OPTIONS', default=False,
+          help='Build with more conservative, release engineering-oriented options. This may slow down builds.')
+
+@depends("--enable-release", 'MOZILLA_OFFICIAL')
+def enable_release(target, mozilla_official_flag, moz_include_source_info_flag):
+    # We have either --enable-release or MOZILLA_OFFICIAL
+    # means that we are in release mode (and not dev mode)
+    return bool(target) or bool(mozilla_official_flag)
+
+@depends('MOZILLA_OFFICIAL')
+def enable_official(mozilla_official_flag):
+    # if we have the variable MOZILLA_OFFICIAL, MOZ_INCLUDE_SOURCE_INFO_FLAG
+    # should be 1 too
+    return bool(mozilla_official_flag)
+
+@depends(enable_release, target)
+def dev_options(enable_release, target):
+    # If official release, disable the developer mode
+    return not bool(enable_release)
+
+set_config('DEVELOPER_OPTIONS', dev_options)
+# Until we move all the DEVELOPER_OPTIONS consumers out of old-configure.
+add_old_configure_assignment('DEVELOPER_OPTIONS',
+                             dev_options)
+
+set_config('MOZ_INCLUDE_SOURCE_INFO', enable_official)
+# Until we move all the MOZ_INCLUDE_SOURCE_INFO out of old-configure.
+add_old_configure_assignment('MOZ_INCLUDE_SOURCE_INFO',
+                             enable_official)
+
+
+
 # Security Hardening
 # ==============================================================
 
 option('--enable-hardening', env='MOZ_SECURITY_HARDENING',
        help='Enables security hardening compiler options')
 
 @depends('--enable-hardening', c_compiler)
 def security_hardening_cflags(value, c_compiler):
--- a/moz.configure
+++ b/moz.configure
@@ -66,16 +66,19 @@ add_old_configure_assignment('COMPILE_EN
 js_option('--disable-tests',
           help='Do not build test libraries & programs')
 
 @depends('--disable-tests')
 def enable_tests(value):
     if value:
         return True
 
+js_option(env='MOZILLA_OFFICIAL',
+          help='Build an official release (will disable the DEVELOPER_OPTIONS).')
+
 set_config('ENABLE_TESTS', enable_tests)
 set_define('ENABLE_TESTS', enable_tests)
 
 @depends(enable_tests)
 def gtest_has_rtti(value):
     if value:
         return '0'
 
--- a/old-configure.in
+++ b/old-configure.in
@@ -5174,28 +5174,20 @@ AC_SUBST(FIREFOX_VERSION)
 AC_SUBST(MOZ_UA_OS_AGNOSTIC)
 if test -n "$MOZ_UA_OS_AGNOSTIC"; then
   AC_DEFINE(MOZ_UA_OS_AGNOSTIC)
 fi
 
 AC_SUBST(MOZ_PKG_SPECIAL)
 AC_SUBST(MOZ_SIMPLE_PACKAGE_NAME)
 
-AC_SUBST(MOZILLA_OFFICIAL)
-if test "$MOZILLA_OFFICIAL"; then
-    AC_DEFINE(MOZILLA_OFFICIAL)
-    # Build revisions should always be present in official builds
-    MOZ_INCLUDE_SOURCE_INFO=1
-fi
-
 # External builds (specifically Ubuntu) may drop the hg repo information, so we allow to
 # explicitly set the repository and changeset information in.
 AC_SUBST(MOZ_SOURCE_REPO)
 AC_SUBST(MOZ_SOURCE_CHANGESET)
-AC_SUBST(MOZ_INCLUDE_SOURCE_INFO)
 
 if test "$MOZ_TELEMETRY_REPORTING"; then
     AC_DEFINE(MOZ_TELEMETRY_REPORTING)
 
     # Enable Telemetry by default for nightly and aurora channels
     if test -z "$RELEASE_OR_BETA"; then
       AC_DEFINE(MOZ_TELEMETRY_ON_BY_DEFAULT)
     fi
--- a/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_moz_configure.py
@@ -56,16 +56,31 @@ class TestMozConfigure(BaseConfigureTest
         self.assertEquals('--enable-application=browser --with-foo',
                           get_value_for(['--enable-application=browser',
                                          '--with-foo']))
 
         self.assertEquals("--enable-application=browser '--with-foo=foo bar'",
                           get_value_for(['--enable-application=browser',
                                          '--with-foo=foo bar']))
 
+        value = get_value_for(['--enable-release'],
+                              environ={'MOZILLA_OFFICIAL': '',
+                                       'MOZ_INCLUDE_SOURCE_INFO': '',
+                                       'DEVELOPER_OPTIONS': ''})
+
+        self.assertEquals('--enable-release',
+                          value)
+
+        value = get_value_for(
+            environ={'MOZILLA_OFFICIAL': '1', 'MOZ_INCLUDE_SOURCE_INFO': '1',
+                     'DEVELOPER_OPTIONS': ''})
+
+        self.assertEquals('MOZILLA_OFFICIAL=1',
+                          value)
+
     def test_nsis_version(self):
         this = self
 
         class FakeNSIS(object):
             def __init__(self, version):
                 self.version = version
 
             def __call__(self, stdin, args):