author Csoregi Natalia <>
Thu, 16 May 2019 20:17:46 +0300
changeset 536097 ee4b88439111cf03944808dc170dbefa74fbdab0
parent 536065 b4e024474194a21d9ade565abfd8340e93aed07c
child 538712 198001a673f6ae43eb5edfea4f3a095c1ee5682b
permissions -rw-r--r--
Backed out 27 changesets (bug 1542963, bug 1547730) on request from Callek for DWE fails. CLOSED TREE Backed out changeset 9e9c2e06d0fb (bug 1547730) Backed out changeset d282ddabcb3d (bug 1547730) Backed out changeset 3df19a96f8ac (bug 1547730) Backed out changeset 27ff9602d80a (bug 1547730) Backed out changeset 48f2c4980ad0 (bug 1547730) Backed out changeset cef492de6a7f (bug 1547730) Backed out changeset 59a1393697e0 (bug 1547730) Backed out changeset 61b8fcc639e0 (bug 1547730) Backed out changeset 2d6ba80390c8 (bug 1547730) Backed out changeset 75879e53727c (bug 1547730) Backed out changeset 03bdcaab1623 (bug 1547730) Backed out changeset 6c9f98dacbde (bug 1547730) Backed out changeset 3037f5bf1019 (bug 1547730) Backed out changeset 3df74540bde3 (bug 1547730) Backed out changeset 1891cfbb55d1 (bug 1547730) Backed out changeset 16b1c53aba9d (bug 1547730) Backed out changeset b7b1062d0aad (bug 1547730) Backed out changeset aa2acfd554fc (bug 1547730) Backed out changeset fa39fb43fd12 (bug 1547730) Backed out changeset 35e2dc6ad347 (bug 1547730) Backed out changeset 1b766ee6bf23 (bug 1547730) Backed out changeset c846bf431b5c (bug 1547730) Backed out changeset 042cdcc4e103 (bug 1547730) Backed out changeset 81bc9014907e (bug 1547730) Backed out changeset afa5801534e4 (bug 1547730) Backed out changeset b4e024474194 (bug 1547730) Backed out changeset 5f3c10562df3 (bug 1542963)

# 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

from __future__ import print_function, unicode_literals

import codecs
import itertools
import logging
import os
import sys
import textwrap

base_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(base_dir, 'python', 'mozbuild'))
from mozbuild.configure import (
from mozbuild.pythonutil import iter_modules_in_path
from mozbuild.backend.configenvironment import PartialConfigEnvironment
from mozbuild.util import (
import mozpack.path as mozpath

def main(argv):
    config = {}

    sandbox = ConfigureSandbox(config, os.environ, argv)

    if os.environ.get('MOZ_CONFIGURE_TRACE'):
        sandbox._logger.setLevel(TRACE), 'moz.configure'))

    if sandbox._help:
        return 0

    return config_status(config)

def config_status(config):
    # Sanitize config data to feed config.status
    # Ideally, all the backend and frontend code would handle the booleans, but
    # there are so many things involved, that it's easier to keep config.status
    # untouched for now.
    def sanitized_bools(v):
        if v is True:
            return '1'
        if v is False:
            return ''
        return v

    sanitized_config = {}
    sanitized_config['substs'] = {
        k: sanitized_bools(v) for k, v in config.iteritems()
        if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR',
    sanitized_config['defines'] = {
        k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
    sanitized_config['non_global_defines'] = config['non_global_defines']
    sanitized_config['topsrcdir'] = config['TOPSRCDIR']
    sanitized_config['topobjdir'] = config['TOPOBJDIR']
    sanitized_config['mozconfig'] = config.get('MOZCONFIG')

    # Create config.status. Eventually, we'll want to just do the work it does
    # here, when we're able to skip configure tests/use cached results/not rely
    # on autoconf.
    logging.getLogger('moz.configure').info('Creating config.status')
    encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
    with'config.status', 'w', encoding) as fh:
            # coding=%(encoding)s
            from __future__ import unicode_literals
            from mozbuild.util import encode
            encoding = '%(encoding)s'
        ''') % {'python': config['PYTHON'], 'encoding': encoding})
        # A lot of the build backend code is currently expecting byte
        # strings and breaks in subtle ways with unicode strings. (bug 1296508)
        for k, v in sanitized_config.iteritems():
            fh.write('%s = encode(%s, encoding)\n' % (k, indented_repr(v)))
        fh.write("__all__ = ['topobjdir', 'topsrcdir', 'defines', "
                 "'non_global_defines', 'substs', 'mozconfig']")

        if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
                if __name__ == '__main__':
                    from mozbuild.util import patch_main
                    from mozbuild.config_status import config_status
                    args = dict([(name, globals()[name]) for name in __all__])

    partial_config = PartialConfigEnvironment(config['TOPOBJDIR'])

    # Write out a file so the build backend knows to re-run configure when
    # relevant Python changes.
    with open('', 'w') as fh:
        for f in itertools.chain(config['CONFIG_STATUS_DEPS'],
            fh.write('%s\n' % mozpath.normpath(f))

    # Other things than us are going to run this file, so we need to give it
    # executable permissions.
    os.chmod('config.status', 0o755)
    if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
        from mozbuild.config_status import config_status

        # Some values in sanitized_config also have more complex types, such as
        # EnumString, which using when calling config_status would currently
        # break the build, as well as making it inconsistent with re-running
        # config.status. Fortunately, EnumString derives from unicode, so it's
        # covered by converting unicode strings.

        # A lot of the build backend code is currently expecting byte strings
        # and breaks in subtle ways with unicode strings.
        return config_status(args=[], **encode(sanitized_config, encoding))
    return 0

if __name__ == '__main__':