mozbuild.controller package


mozbuild.controller.building module

class mozbuild.controller.building.BuildDriver(topsrcdir, settings, log_manager, topobjdir=None, mozconfig=<object object>)

Bases: mozbuild.base.MozbuildObject

Provides a high-level API for build actions.

build(what=None, disable_extra_make_dependencies=None, jobs=0, directory=None, verbose=False, keep_going=False, mach_context=None)

Invoke the build backend.

what defines the thing to build. If not defined, the default target is used.

configure(options=None, buildstatus_messages=False, line_handler=None)

Install test files.

class mozbuild.controller.building.BuildMonitor(topsrcdir, settings, log_manager, topobjdir=None, mozconfig=<object object>)

Bases: mozbuild.base.MozbuildObject

Monitors the output of the build.


Record the end of the build.


Produce a data structure containing the low-level resource usage information.

This data structure can e.g. be serialized into JSON and saved for subsequent analysis.

If no resource usage is available, None is returned.


Determine whether there was excessive swapping during the build.

Returns a tuple of (excessive, swap_in, swap_out). All values are None if no swap information is available.


Determine whether there was high Finder CPU usage during the build.

Returns True if there was high Finder CPU usage, False if there wasn’t, or None if there is nothing to report.


Whether resource usage is available.


Create a new monitor.

warnings_path is a path of a warnings database to use.


Summarize the resource usage of this build in a log message.


Consume a line of output from the build system.

This will parse the line for state and determine whether more action is needed.

Returns a BuildOutputResult instance.

In this named tuple, warning will be an object describing a new parsed warning. Otherwise it will be None.

state_changed indicates whether the build system changed state with this line. If the build system changed state, the caller may want to query this instance for the current state in order to update UI, etc.

for_display is a boolean indicating whether the line is relevant to the user. This is typically used to filter whether the line should be presented to the user.


Record the start of the build.

class mozbuild.controller.building.BuildOutputManager(log_manager, monitor, footer)

Bases: mozbuild.controller.building.OutputManager

Handles writing build output to a terminal, to logs, etc.

class mozbuild.controller.building.BuildOutputResult(warning, state_changed, for_display)

Bases: tuple


Alias for field number 2


Alias for field number 1


Alias for field number 0

class mozbuild.controller.building.BuildProgressFooter(terminal, monitor)

Bases: mozterm.widgets.Footer

Handles display of a build progress indicator in a terminal.

When mach builds inside a blessings-supported terminal, it will render progress information collected from a BuildMonitor. This class converts the state of BuildMonitor into terminal output.


Draws this footer in the terminal.

class mozbuild.controller.building.CCacheStats(output=None)

Bases: object

Holds statistics from ccache.

Instances can be subtracted from each other to obtain differences. print() or str() the object to show a ccache -s like output of the captured stats.

ABSOLUTE_KEYS = set([u'cache_size', u'cache_files', u'cache_max_size'])
DIRECTORY_DESCRIPTION = u'cache directory'
FORMAT_KEYS = set([u'cache_size', u'cache_max_size'])
GiB = 1073741824
KiB = 1024
MiB = 1048576
SECONDARY_CONFIG_DESCRIPTION = u'secondary config (readonly)'
STATS_KEYS = [(u'cache_hit_direct', u'cache hit (direct)'), (u'cache_hit_preprocessed', u'cache hit (preprocessed)'), (u'cache_hit_rate', u'cache hit rate'), (u'cache_miss', u'cache miss'), (u'link', u'called for link'), (u'preprocessing', u'called for preprocessing'), (u'multiple', u'multiple source files'), (u'stdout', u'compiler produced stdout'), (u'no_output', u'compiler produced no output'), (u'empty_output', u'compiler produced empty output'), (u'failed', u'compile failed'), (u'error', u'ccache internal error'), (u'preprocessor_error', u'preprocessor error'), (u'cant_use_pch', u"can't use precompiled header"), (u'compiler_missing', u"couldn't find the compiler"), (u'cache_file_missing', u'cache file missing'), (u'bad_args', u'bad compiler arguments'), (u'unsupported_lang', u'unsupported source language'), (u'compiler_check_failed', u'compiler check failed'), (u'autoconf', u'autoconf compile/link'), (u'unsupported_code_directive', u'unsupported code directive'), (u'unsupported_compiler_option', u'unsupported compiler option'), (u'out_stdout', u'output to stdout'), (u'out_device', u'output to a non-regular file'), (u'no_input', u'no input file'), (u'bad_extra_file', u'error hashing extra file'), (u'num_cleanups', u'cleanups performed'), (u'cache_files', u'files in cache'), (u'cache_size', u'cache size'), (u'cache_max_size', u'max cache size')]
class mozbuild.controller.building.OutputManager(log_manager, footer)

Bases: mach.mixin.logging.LoggingMixin

Handles writing job output to a terminal or log.

class mozbuild.controller.building.StaticAnalysisFooter(terminal, monitor)

Bases: mozterm.widgets.Footer

Handles display of a static analysis progress indicator in a terminal.


Draws this footer in the terminal.

class mozbuild.controller.building.StaticAnalysisOutputManager(log_manager, monitor, footer)

Bases: mozbuild.controller.building.OutputManager

Handles writing static analysis output to a terminal.

class mozbuild.controller.building.TerminalLoggingHandler

Bases: logging.Handler

Custom logging handler that works with terminal window dressing.

This class should probably live elsewhere, like the mach core. Consider this a proving ground for its usefulness.

class mozbuild.controller.building.TierStatus(resources)

Bases: object

Represents the state and progress of tier traversal.

The build system is organized into linear phases called tiers. Each tier executes in the order it was defined, 1 at a time.

add_resources_to_dict(entry, start=None, end=None, phase=None)

Helper function to append resource information to a dict.


Record that execution of a tier has begun.


Record that execution of a tier has finished.


Record the set of known tiers.


Obtains an object containing resource usage for tiers.

The returned object is suitable for serialization.

mozbuild.controller.clobber module

class mozbuild.controller.clobber.Clobberer(topsrcdir, topobjdir)

Bases: object


Obtain the cause why a clobber is required.

This reads the cause from the CLOBBER file.

This returns a list of lines describing why the clobber was required. Each line is stripped of leading and trailing whitespace.


Returns a bool indicating whether a tree clobber is required.


Ensure the CLOBBER file in the objdir exists.

This is called as part of the build to ensure the clobber information is configured properly for the objdir.

maybe_do_clobber(cwd, allow_auto=False, fh=<open file '<stderr>', mode 'w'>)

Perform a clobber if it is required. Maybe.

This is the API the build system invokes to determine if a clobber is needed and to automatically perform that clobber if we can.

This returns a tuple of (bool, bool, str). The elements are:

  • Whether a clobber was/is required.
  • Whether a clobber was performed.
  • The reason why the clobber failed or could not be performed. This will be None if no clobber is required or if we clobbered without error.

Remove the object directory.

full controls whether to fully delete the objdir. If False, some directories (e.g. Visual Studio Project Files) will not be deleted.

Module contents