author Gregory Szorc <>
Fri, 05 Oct 2012 12:13:18 -0700
changeset 112939 d04782dc009156e114f27da3a468321a99edc47b
parent 112938 python/mach/mach/
child 117041 e0e1220d2c5a1086a4911be8d69e2937b842d116
permissions -rw-r--r--
Bug 794509 - Part 2: Move mach command modules into a mach.commands sub-module; r=jhammel This patch on its own will break mach. Part 3 will refactor mach's loader to discover and load modules using a modified module finding method.

# 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 unicode_literals

import logging
import os

from mach.base import CommandProvider
from mach.base import Command
from mozbuild.base import MozbuildObject

class Build(MozbuildObject):
    """Interface to build the tree."""

    @Command('build', help='Build the tree.')
    def build(self):
        # This code is only meant to be temporary until the more robust tree
        # building code in bug 780329 lands.
        from mozbuild.compilation.warnings import WarningsCollector
        from mozbuild.compilation.warnings import WarningsDatabase

        warnings_path = self._get_state_filename('warnings.json')
        warnings_database = WarningsDatabase()

        if os.path.exists(warnings_path):

        warnings_collector = WarningsCollector(database=warnings_database,

        def on_line(line):
                warning = warnings_collector.process_line(line)
                if warning:
                    self.log(logging.INFO, 'compiler_warning', warning,
                        'Warning: {flag} in {filename}: {message}')
                # This will get logged in the more robust implementation.

            self.log(logging.INFO, 'build_output', {'line': line}, '{line}')

        self._run_make(srcdir=True, filename='', line_handler=on_line,
            log=False, print_directory=False)

        self.log(logging.WARNING, 'warning_summary',
            {'count': len(warnings_collector.database)},
            '{count} compiler warnings present.')