Bug 1257326 - Replace the env_flag configure template with a template that does not permit setting values directly from the environment or a mozconfig. draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 09 May 2016 15:20:16 -0700
changeset 365027 e7f76f5e1f4ae2fe5b7c28ea32ac4c7b306a985c
parent 365026 0606a59c04200f8aa27b0b89726a887dbc07bb12
child 365028 f1ab1ae4ca4dd92fcc0e82dfb14b2e60a2637a23
child 365053 032370508d6dcf7d442f7d86e0a0f791db0e7577
child 365068 193a188ca47ff6344ec36dda7021c8d931a4fbc4
push id17617
push usercmanchester@mozilla.com
push dateMon, 09 May 2016 22:22:03 +0000
bugs1257326
milestone49.0a1
Bug 1257326 - Replace the env_flag configure template with a template that does not permit setting values directly from the environment or a mozconfig. For most cases, this replaces a value that was set in a way that would ignore an environment variable, so this restores behavior for values that were set in confvars.sh. MozReview-Commit-ID: E31hm8uKq4D
build/moz.configure/init.configure
mobile/android/moz.configure
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -679,31 +679,32 @@ set_config('NIGHTLY_BUILD', delayed_geta
 set_define('NIGHTLY_BUILD', delayed_getattr(milestone, 'is_nightly'))
 add_old_configure_assignment('NIGHTLY_BUILD',
                              delayed_getattr(milestone, 'is_nightly'))
 set_config('RELEASE_BUILD', delayed_getattr(milestone, 'is_release'))
 set_define('RELEASE_BUILD', delayed_getattr(milestone, 'is_release'))
 add_old_configure_assignment('RELEASE_BUILD',
                              delayed_getattr(milestone, 'is_release'))
 
-# A template providing a shorthand for tying an environment-set option to
-# the corresponding variable in set_config, where the value of that variable
-# passed to set_config only depends on the provided value and default.
+# A template providing a shorthand for setting a variable. The created
+# option will only be settable with imply_option.
+# It is expected that a project-specific moz.configure will call imply_option
+# to set a value other than the default.
 # If required, the set_as_define and set_for_old_configure arguments
 # will additionally cause the variable to be set using set_define and
 # add_old_configure_assignment. util.configure would be an appropriate place for
 # this, but it uses add_old_configure_assignment, which is defined in this file.
 @template
-def env_flag(env=None, set_for_old_configure=False, set_as_define=False,
-             **kwargs):
+def project_flag(env=None, set_for_old_configure=False,
+                 set_as_define=False, **kwargs):
 
     if not env:
-        configure_error("An env_flag must be passed a variable name to set.")
+        configure_error("A project_flag must be passed a variable name to set.")
 
-    opt = option(env=env, **kwargs)
+    opt = option(env=env, possible_origins=('implied',), **kwargs)
 
     @depends(opt.option)
     def option_implementation(value):
         if value:
             if len(value):
                 return value
             return bool(value)
 
--- a/mobile/android/moz.configure
+++ b/mobile/android/moz.configure
@@ -1,53 +1,53 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
-env_flag('MOZ_ANDROID_EXCLUDE_FONTS',
-         help='Whether to exclude font files from the build',
-         default=True)
+project_flag('MOZ_ANDROID_EXCLUDE_FONTS',
+             help='Whether to exclude font files from the build',
+             default=True)
 
-env_flag('MOZ_LOCALE_SWITCHER',
-         help='Enable runtime locale switching',
-         default=True)
+project_flag('MOZ_LOCALE_SWITCHER',
+             help='Enable runtime locale switching',
+             default=True)
 
-env_flag('MOZ_ANDROID_GCM',
-         help='Enable GCM registration on Nightly builds only',
-         default=enabled_in_nightly,
-         set_for_old_configure=True)
+project_flag('MOZ_ANDROID_GCM',
+             help='Enable GCM registration on Nightly builds only',
+             default=enabled_in_nightly,
+             set_for_old_configure=True)
 
-env_flag('MOZ_ANDROID_DOWNLOADS_INTEGRATION',
-         help='Enable system download manager on Android',
-         default=True)
+project_flag('MOZ_ANDROID_DOWNLOADS_INTEGRATION',
+             help='Enable system download manager on Android',
+             default=True)
 
-env_flag('MOZ_ANDROID_BEAM',
-         help='Enable NFC permission on Android',
-         default=True)
+project_flag('MOZ_ANDROID_BEAM',
+             help='Enable NFC permission on Android',
+             default=True)
 
-env_flag('MOZ_ANDROID_SEARCH_ACTIVITY',
-         help='Include Search Activity on Android',
-         default=True)
+project_flag('MOZ_ANDROID_SEARCH_ACTIVITY',
+             help='Include Search Activity on Android',
+             default=True)
 
-env_flag('MOZ_ANDROID_MLS_STUMBLER',
-         help='Include Mozilla Location Service Stumbler on Android',
-         default=True)
+project_flag('MOZ_ANDROID_MLS_STUMBLER',
+             help='Include Mozilla Location Service Stumbler on Android',
+             default=True)
 
-env_flag('MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
-         help='Background service for downloading additional content at runtime',
-         default=True)
+project_flag('MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE',
+             help='Background service for downloading additional content at runtime',
+             default=True)
 
 # Enable the Switchboard A/B framework code.
 # Note: The framework is always included in the app. This flag controls
 # usage of the framework.
-env_flag('MOZ_SWITCHBOARD',
-         help='Include Switchboard A/B framework on Android',
-         default=True)
+project_flag('MOZ_SWITCHBOARD',
+             help='Include Switchboard A/B framework on Android',
+             default=True)
 
 option('--disable-android-apz', env='MOZ_ANDROID_APZ',
        help='Disable the C++ async pan/zoom code and use the Java version instead')
 
 android_apz = depends_if('--disable-android-apz')(lambda _: True)
 
 set_config('MOZ_ANDROID_APZ', android_apz)
 set_define('MOZ_ANDROID_APZ', android_apz)