mozbuild.controller package

Submodules

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_tests(test_objs)

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.

ccache_stats()
finish(record_usage=True)

Record the end of the build.

get_resource_usage()

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.

have_excessive_swapping()

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.

have_high_finder_usage()

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.

have_resource_usage

Whether resource usage is available.

init(warnings_path)

Create a new monitor.

warnings_path is a path of a warnings database to use.

log_resource_usage(usage)

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

on_line(line)

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.

start()

Record the start of the build.

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

Bases: mozbuild.controller.building.OutputManager

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

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

Bases: tuple

for_display

Alias for field number 2

state_changed

Alias for field number 1

warning

Alias for field number 0

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

Bases: mozbuild.controller.building.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.

draw()

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
PRIMARY_CONFIG_DESCRIPTION = u'primary config'
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')]
hit_rate_message()
hit_rates()
class mozbuild.controller.building.Footer(terminal)

Bases: object

Handles display of a footer in a terminal.

This class implements the functionality common to all mach commands that render a footer.

clear()

Removes the footer from the current terminal.

write(parts)

Write some output in the footer, accounting for terminal width.

parts is a list of 2-tuples of (encoding_function, input). None means no encoding.

class mozbuild.controller.building.OutputManager(log_manager, footer)

Bases: mach.mixin.logging.LoggingMixin

Handles writing job output to a terminal or log.

refresh()
write_line(line)
class mozbuild.controller.building.StaticAnalysisFooter(terminal, monitor)

Bases: mozbuild.controller.building.Footer

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

draw()

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.

on_line(line)
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.

emit(record)
flush()
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_resource_fields_to_dict(d)
add_resources_to_dict(entry, start=None, end=None, phase=None)

Helper function to append resource information to a dict.

begin_tier(tier)

Record that execution of a tier has begun.

finish_tier(tier)

Record that execution of a tier has finished.

set_tiers(tiers)

Record the set of known tiers.

tiered_resource_usage()

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

clobber_cause()

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.

clobber_needed()

Returns a bool indicating whether a tree clobber is required.

ensure_objdir_state()

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.

have_winrm()
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_objdir(full=True)

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