Bug 1257823 - Move add_old_configure_assignment() to the global scope. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 23 Mar 2016 16:34:59 +0900
changeset 328031 76d58b17343e47d057bbbc22634e0ff3e537b8b5
parent 328030 06dc23858ed715e62229c2f80147af28b0416fff
child 328032 3e142ba20ecad6ee3aab402740a7f8f903089a5b
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1257823
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 1257823 - Move add_old_configure_assignment() to the global scope. r=nalexander Similar to set_config, set_define and imply_option, but this is a sandboxed function that stays sandboxed.
build/moz.configure/init.configure
js/moz.configure
moz.configure
toolkit/moz.configure
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -126,20 +126,26 @@ def mozconfig(current_project, mozconfig
 def old_configure_assignments(help):
     return []
 
 @depends('--help')
 def extra_old_configure_args(help):
     return []
 
 @template
-def add_old_configure_assignment(var, value):
-    @depends(old_configure_assignments)
+@advanced
+def add_old_configure_assignment(var, value_func):
+    from mozbuild.configure import DummyFunction
+    assert isinstance(value_func, DummyFunction)
+
+    @depends(old_configure_assignments, value_func)
     @advanced
-    def add_assignment(assignments):
+    def add_assignment(assignments, value):
+        if value is None:
+            return
         if value is True:
             assignments.append('%s=1' % var)
         elif value is False:
             assignments.append('%s=' % var)
         else:
             from mozbuild.shellutil import quote
             assignments.append('%s=%s' % (var, quote(value)))
 
@@ -217,20 +223,20 @@ def virtualenv_python(env_python, build_
         # Windows.
         sys.exit(subprocess.call([python] + sys.argv))
 
     # We are now in the virtualenv
     import distutils.sysconfig
     if not distutils.sysconfig.get_python_lib():
         error('Could not determine python site packages directory')
 
-    add_old_configure_assignment('PYTHON', python)
     return python
 
 set_config('PYTHON', virtualenv_python)
+add_old_configure_assignment('PYTHON', virtualenv_python)
 
 # Inject mozconfig options
 # ==============================================================
 @template
 @advanced
 def command_line_helper():
     # This escapes the sandbox. Don't copy this. This is only here because
     # it is a one off and because the required functionality doesn't need
@@ -500,56 +506,59 @@ def target_variables(target):
         os_arch = 'GNU_kFreeBSD'
     elif target.kernel == 'Darwin' or (target.kernel == 'Linux' and
                                        target.os == 'GNU'):
         os_target = target.kernel
         os_arch = target.kernel
     else:
         os_target = target.os
         os_arch = target.kernel
-    add_old_configure_assignment('OS_TARGET', os_target)
-    add_old_configure_assignment('OS_ARCH', os_arch)
 
     if target.os == 'Darwin' and target.cpu == 'x86':
         os_test = 'i386'
     else:
         os_test = target.raw_cpu
-    add_old_configure_assignment('OS_TEST', os_test)
-
-    add_old_configure_assignment('CPU_ARCH', target.cpu)
 
     return namespace(
         OS_TARGET=os_target,
         OS_ARCH=os_arch,
         OS_TEST=os_test,
         INTEL_ARCHITECTURE=target.cpu in ('x86', 'x86_64') or None,
     )
 
 set_config('OS_TARGET', delayed_getattr(target_variables, 'OS_TARGET'))
+add_old_configure_assignment('OS_TARGET',
+                             delayed_getattr(target_variables, 'OS_TARGET'))
 set_config('OS_ARCH', delayed_getattr(target_variables, 'OS_ARCH'))
+add_old_configure_assignment('OS_ARCH',
+                             delayed_getattr(target_variables, 'OS_ARCH'))
 set_config('OS_TEST', delayed_getattr(target_variables, 'OS_TEST'))
+add_old_configure_assignment('OS_TEST',
+                             delayed_getattr(target_variables, 'OS_TEST'))
 set_config('CPU_ARCH', delayed_getattr(target, 'cpu'))
+add_old_configure_assignment('CPU_ARCH', delayed_getattr(target, 'cpu'))
 set_config('INTEL_ARCHITECTURE', delayed_getattr(target_variables,
                                                  'INTEL_ARCHITECTURE'))
 set_config('TARGET_CPU', delayed_getattr(target, 'raw_cpu'))
 set_config('TARGET_OS', delayed_getattr(target, 'raw_os'))
 
 
 @depends(host)
 def host_variables(host):
     if host.kernel == 'kFreeBSD':
         os_arch = 'GNU_kFreeBSD'
     else:
         os_arch = host.kernel
-    add_old_configure_assignment('HOST_OS_ARCH', os_arch)
     return namespace(
         HOST_OS_ARCH=os_arch,
     )
 
 set_config('HOST_OS_ARCH', delayed_getattr(host_variables, 'HOST_OS_ARCH'))
+add_old_configure_assignment('HOST_OS_ARCH',
+                             delayed_getattr(host_variables, 'HOST_OS_ARCH'))
 
 @depends(target)
 def target_is_windows(target):
     if target.kernel == 'WINNT':
         return True
 
 set_define('_WINDOWS', target_is_windows)
 set_define('WIN32', target_is_windows)
@@ -619,42 +628,41 @@ option('--with-external-source-dir', env
 @depends('--enable-project', '--with-external-source-dir',
          check_build_environment, '--help')
 def include_project_configure(project, external_source_dir, build_env, help):
     if not project:
         error('--enable-project is required.')
 
     base_dir = build_env.topsrcdir
     if external_source_dir:
-        add_old_configure_assignment('EXTERNAL_SOURCE_DIR',
-                                     external_source_dir[0])
         base_dir = os.path.join(base_dir, external_source_dir[0])
 
     path = os.path.join(base_dir, project[0], 'moz.configure')
     if not os.path.exists(path):
         error('Cannot find project %s' % project[0])
     return path
 
 @depends('--with-external-source-dir')
 def external_source_dir(value):
     if value:
         return value[0]
 
 set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
+add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)
 
 
 @depends(include_project_configure, check_build_environment, '--help')
 def build_project(include_project_configure, build_env, help):
     ret = os.path.dirname(os.path.relpath(include_project_configure,
                                           build_env.topsrcdir))
-    add_old_configure_assignment('MOZ_BUILD_APP', ret)
     return ret
 
 set_config('MOZ_BUILD_APP', build_project)
 set_define('MOZ_BUILD_APP', build_project)
+add_old_configure_assignment('MOZ_BUILD_APP', build_project)
 
 
 # set RELEASE_BUILD 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_BUILD)
 @depends(check_build_environment)
@@ -664,31 +672,33 @@ def milestone(build_env):
                                   'config',
                                   'milestone.txt')
     with open(milestone_path, 'r') as fh:
         milestone = fh.read().splitlines()[-1]
 
     is_nightly = is_release = None
 
     if 'a1' in milestone:
-        add_old_configure_assignment('NIGHTLY_BUILD', True)
         is_nightly = True
     elif 'a' not in milestone:
-        add_old_configure_assignment('RELEASE_BUILD', True)
         is_release = True
 
     return namespace(version=milestone,
                      is_nightly=is_nightly,
                      is_release=is_release)
 
 set_config('GRE_MILESTONE', delayed_getattr(milestone, 'version'))
 set_config('NIGHTLY_BUILD', delayed_getattr(milestone, 'is_nightly'))
 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'))
 
 
 # This is temporary until js/src/configure and configure are merged.
 # Use instead of option() in js/moz.configure
 @template
 def js_option(*args, **kwargs):
     opt = option(*args, **kwargs)
 
@@ -709,9 +719,11 @@ def gonkdir(help):
 
 include(include_project_configure)
 
 # By now, gonkdir is either the dummy function above or a real function
 # depending on --with-gonk from b2g/moz.configure.
 @depends(gonkdir)
 def gonkdir_for_old_configure(value):
     if value:
-        add_old_configure_assignment('gonkdir', value)
+        return value
+
+add_old_configure_assignment('gonkdir', gonkdir_for_old_configure)
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -16,20 +16,20 @@ def building_js(build_project, help):
 # top-level configure, it can go away, although the JS_STANDALONE config
 # will still need to be set depending on building_js above.
 option(env='JS_STANDALONE', default=building_js,
        help='Reserved for internal use')
 
 @depends('JS_STANDALONE')
 def js_standalone(value):
     if value:
-        add_old_configure_assignment('JS_STANDALONE', True)
         return True
 
 set_config('JS_STANDALONE', js_standalone)
+add_old_configure_assignment('JS_STANDALONE', js_standalone)
 
 js_option('--disable-js-shell', default=building_js,
        help='Do not build the JS shell')
 
 @depends('--disable-js-shell')
 def js_disable_shell(value):
     if not value:
         return True
@@ -57,20 +57,20 @@ js_option('--disable-shared-js', default
 js_option('--disable-export-js', default=building_js,
           help='Do not mark JS symbols as DLL exported/visible')
 
 @depends('--disable-shared-js', '--disable-export-js')
 def shared_js(shared_js, export_js):
     if shared_js:
         if not export_js:
             error('Must export JS symbols when building a shared library.')
-        add_old_configure_assignment('JS_SHARED_LIBRARY', True)
         return True
 
 set_config('JS_SHARED_LIBRARY', shared_js)
+add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
 
 @depends('--disable-shared-js', '--disable-export-js')
 def exportable_js_api(shared_js, export_js):
     if not shared_js and export_js:
         return True
 
 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
 
@@ -117,21 +117,21 @@ js_option('--enable-instruments', env='M
           help='Enable instruments remote profiling')
 
 @depends('--enable-instruments', target)
 def instruments(value, target):
     if value and target.os != 'OSX':
         error('--enable-instruments cannot be used when targeting %s'
               % target.os)
     if value:
-        add_old_configure_assignment('MOZ_INSTRUMENTS', True)
         return True
 
 set_config('MOZ_INSTRUMENTS', instruments)
 set_define('MOZ_INSTRUMENTS', instruments)
+add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
 
 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
           help='Enable callgrind profiling')
 
 @depends('--enable-callgrind')
 def callgrind(value):
     if value:
@@ -142,19 +142,20 @@ imply_option('--enable-profiling', callg
 
 js_option('--enable-profiling', env='MOZ_PROFILING',
           help='Set compile flags necessary for using sampling profilers '
                '(e.g. shark, perf)')
 
 @depends('--enable-profiling')
 def profiling(value):
     if value:
-        add_old_configure_assignment('MOZ_PROFILING', True)
         return True
 
+add_old_configure_assignment('MOZ_PROFILING', profiling)
+
 @depends(profiling, target)
 def imply_vtune(value, target):
     if value and (target.kernel == 'WINNT' or (target.kernel == 'Linux' and
                                                target.os == 'GNU')):
         return True
 
 set_config('MOZ_PROFILING', profiling)
 set_define('MOZ_PROFILING', profiling)
--- a/moz.configure
+++ b/moz.configure
@@ -44,20 +44,20 @@ def imply_disable_compile_environment(va
 imply_option('--enable-compile-environment', imply_disable_compile_environment)
 
 option('--disable-compile-environment',
        help='Disable compiler/library checks')
 
 @depends('--disable-compile-environment')
 def compile_environment(value):
     if value:
-        add_old_configure_assignment('COMPILE_ENVIRONMENT', True)
         return True
 
 set_config('COMPILE_ENVIRONMENT', compile_environment)
+add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
 
 
 @depends('--help')
 @advanced
 def build_backends_choices(help):
     from mozbuild.backend import backends
     return tuple(backends)
 
@@ -79,27 +79,31 @@ set_config('BUILD_BACKENDS', build_backe
 
 # Awk detection
 # ==============================================================
 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)
+    return value
+
+add_old_configure_assignment('AWK', awk_for_old_configure)
 
 
 # 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)
+    return value
+
+add_old_configure_assignment('PERL', perl_for_old_configure)
 
 @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
@@ -140,24 +144,27 @@ yasm = check_prog('YASM', ['yasm'], allo
 @advanced
 def yasm_version(yasm):
     if yasm:
         import subprocess
         try:
             version = Version(subprocess.check_output(
                 [yasm, '--version']
             ).splitlines()[0].split()[1])
-            # Until we move all the yasm consumers out of old-configure.
-            # bug 1257904
-            add_old_configure_assignment('_YASM_MAJOR_VERSION', version.major)
-            add_old_configure_assignment('_YASM_MINOR_VERSION', version.minor)
             return version
         except subprocess.CalledProcessError as e:
             error('Failed to get yasm version: %s' % e.message)
 
+# Until we move all the yasm consumers out of old-configure.
+# bug 1257904
+add_old_configure_assignment('_YASM_MAJOR_VERSION',
+                             delayed_getattr(yasm_version, 'major'))
+add_old_configure_assignment('_YASM_MINOR_VERSION',
+                             delayed_getattr(yasm_version, 'minor'))
+
 @depends(yasm, target)
 def yasm_asflags(yasm, target):
     if yasm:
         asflags = {
             ('OSX', 'x86'): '-f macho32',
             ('OSX', 'x86_64'): '-f macho64',
             ('WINNT', 'x86'): '-f win32',
             ('WINNT', 'x86_64'): '-f x64',
@@ -166,28 +173,28 @@ def yasm_asflags(yasm, target):
             # We're assuming every x86 platform we support that's
             # not Windows or Mac is ELF.
             if target.cpu == 'x86':
                 asflags = '-f elf32'
             elif target.cpu == 'x86_64':
                 asflags = '-f elf64'
         if asflags:
             asflags += ' -rnasm -pnasm'
-            # Until the YASM variable is not necessary in old-configure.
-            add_old_configure_assignment('YASM', True)
         return asflags
 
 set_config('YASM_ASFLAGS', yasm_asflags)
 
 @depends(yasm_asflags)
 def have_yasm(value):
     if value:
         return True
 
 set_config('HAVE_YASM', have_yasm)
+# Until the YASM variable is not necessary in old-configure.
+add_old_configure_assignment('YASM', have_yasm)
 
 
 # Miscellaneous programs
 # ==============================================================
 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
 check_prog('TAR', ('gnutar', 'gtar', 'tar'))
 check_prog('UNZIP', ('unzip',))
 check_prog('XARGS', ('xargs',))
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -54,21 +54,21 @@ set_define('MOZ_ENABLE_PROFILER_SPS', sp
 
 option('--enable-dmd', env='MOZ_DMD',
        help='Enable Dark Matter Detector (heap profiler). '
             'Also enables jemalloc, replace-malloc and profiling')
 
 @depends('--enable-dmd')
 def dmd(value):
     if value:
-        add_old_configure_assignment('MOZ_DMD', True)
         return True
 
 set_config('MOZ_DMD', dmd)
 set_define('MOZ_DMD', dmd)
+add_old_configure_assignment('MOZ_DMD', dmd)
 imply_option('--enable-profiling', dmd)
 
 # Javascript engine
 # ==============================================================
 include('../js/moz.configure')
 
 
 # L10N
@@ -133,21 +133,20 @@ def toolkit(value, target, gonkdir):
 
 
 @depends(toolkit)
 def toolkit(toolkit):
     if toolkit == 'cairo-gtk2-x11':
         widget_toolkit = 'gtk2'
     else:
         widget_toolkit = toolkit.replace('cairo-', '')
-    add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', widget_toolkit)
-
     return widget_toolkit
 
 set_config('MOZ_WIDGET_TOOLKIT', toolkit)
+add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', toolkit)
 
 @depends(toolkit)
 def toolkit_gtk(toolkit):
     if toolkit == 'gtk2':
         return '2'
     elif toolkit == 'gtk3':
         return '3'
 
@@ -168,25 +167,23 @@ def x11(value, toolkit):
     if not value and toolkit != 'qt':
         error('--without-x is only valid with --enable-default-toolkit=qt')
 
     x11_toolkits = ('gtk2', 'gtk3', 'qt')
     if value and value.origin != 'default' and toolkit not in x11_toolkits:
         error('--with-x is only valid with --enable-default-toolkit={%s}'
               % ','.join(x11_toolkits))
 
-    if value and toolkit in x11_toolkits:
-        add_old_configure_assignment('MOZ_X11', True)
-
     return True if value and toolkit in x11_toolkits else None
 
 set_config('MOZ_ENABLE_XREMOTE', x11)
 set_define('MOZ_ENABLE_XREMOTE', x11)
 set_config('MOZ_X11', x11)
 set_define('MOZ_X11', x11)
+add_old_configure_assignment('MOZ_X11', x11)
 
 # GL Provider
 # ==============================================================
 option('--with-gl-provider', nargs=1, help='Set GL provider backend type')
 
 @depends('--with-gl-provider')
 def gl_provider(value):
     if value:
@@ -255,29 +252,31 @@ set_define('MOZ_INSTRUMENT_EVENT_LOOP', 
 # ==============================================================
 option(env='USE_FC_FREETYPE',
        help='Force-enable the use of fontconfig freetype')
 
 @depends('USE_FC_FREETYPE', toolkit)
 def fc_freetype(value, toolkit):
     if value or (toolkit in ('gtk2', 'gtk3', 'qt') and
                  value.origin == 'default'):
-        add_old_configure_assignment('USE_FC_FREETYPE', True)
+        return True
+
+add_old_configure_assignment('USE_FC_FREETYPE', fc_freetype)
 
 
 # Apple platform decoder support
 # ==============================================================
 @depends(toolkit)
 def applemedia(toolkit):
     if toolkit in ('cocoa', 'uikit'):
-        add_old_configure_assignment('MOZ_APPLEMEDIA', True)
         return True
 
 set_config('MOZ_APPLEMEDIA', applemedia)
 set_define('MOZ_APPLEMEDIA', applemedia)
+add_old_configure_assignment('MOZ_APPLEMEDIA', applemedia)
 
 # Windows Media Foundation support
 # ==============================================================
 option('--disable-wmf',
        help='Disable support for Windows Media Foundation')
 
 @depends('--disable-wmf', target)
 def wmf(value, target):
@@ -320,21 +319,21 @@ option('--disable-fmp4', env='MOZ_FMP4',
 
 @depends('--disable-fmp4', target, wmf, applemedia)
 def fmp4(value, target, wmf, applemedia):
     enabled = bool(value)
     if value.origin == 'default':
         # target.os == 'Android' includes all B2G versions
         enabled = wmf or applemedia or target.os == 'Android'
     if enabled:
-        add_old_configure_assignment('MOZ_FMP4', True)
         return True
 
 set_config('MOZ_FMP4', fmp4)
 set_define('MOZ_FMP4', fmp4)
+add_old_configure_assignment('MOZ_FMP4', fmp4)
 
 # EME Support
 # ==============================================================
 option('--enable-eme', nargs='*', choices=('adobe',),
        help='Enable support for Encrypted Media Extensions')
 
 @depends('--enable-eme', fmp4)
 def eme(value, fmp4):