mozbuild.controller package¶
Submodules¶
mozbuild.controller.building module¶
- class mozbuild.controller.building.BuildDriver(*args, **kwargs)¶
Bases:
mozbuild.base.MozbuildObject
Provides a high-level API for build actions.
- build(metrics, what=None, jobs=0, job_size=0, directory=None, verbose=False, keep_going=False, mach_context=None, append_env=None)¶
Invoke the build backend.
what
defines the thing to build. If not defined, the default target is used.
- configure(metrics, options=None, buildstatus_messages=False, line_handler=None, append_env=None)¶
- install_tests()¶
Install test files.
- class mozbuild.controller.building.BuildMonitor(topsrcdir, settings, log_manager, topobjdir=None, mozconfig=<object object>, virtualenv_name=None)¶
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.
- property 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.
message is either None, or the content of a message to be displayed 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, message)¶
Bases:
tuple
- message¶
Alias for field number 2
- state_changed¶
Alias for field number 1
- warning¶
Alias for field number 0
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, is_version_4_4_or_newer=False)¶
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 = {'cache_files', 'cache_max_size', 'cache_size'}¶
- DIRECTORY_DESCRIPTION = 'cache directory'¶
- DIRECTORY_DESCRIPTION_4_4 = 'Summary/Cache directory'¶
- FORMAT_KEYS = {'cache_max_size', 'cache_size'}¶
- GiB = 1073741824¶
- KiB = 1024¶
- MiB = 1048576¶
- PRIMARY_CONFIG_DESCRIPTION = 'primary config'¶
- PRIMARY_CONFIG_DESCRIPTION_4_4 = 'Summary/Primary config'¶
- SECONDARY_CONFIG_DESCRIPTION = 'secondary config'¶
- SECONDARY_CONFIG_DESCRIPTION_4_4 = 'Summary/Secondary config'¶
- SKIP_KEYS_4_4 = ['Summary/Uncacheable', 'Summary/Misses/Direct', 'Summary/Misses/Preprocessed', 'Primary storage/Hits', 'Primary storage/Misses']¶
- STATS_KEYS = [('stats_zeroed', 'stats zero time'), ('stats_zeroed', 'stats zeroed'), ('stats_updated', 'stats updated'), ('cache_hit_direct', 'cache hit (direct)'), ('cache_hit_preprocessed', 'cache hit (preprocessed)'), ('cache_hit_rate', 'cache hit rate'), ('cache_miss', 'cache miss'), ('link', 'called for link'), ('preprocessing', 'called for preprocessing'), ('multiple', 'multiple source files'), ('stdout', 'compiler produced stdout'), ('no_output', 'compiler produced no output'), ('empty_output', 'compiler produced empty output'), ('failed', 'compile failed'), ('error', 'ccache internal error'), ('preprocessor_error', 'preprocessor error'), ('cant_use_pch', "can't use precompiled header"), ('compiler_missing', "couldn't find the compiler"), ('cache_file_missing', 'cache file missing'), ('bad_args', 'bad compiler arguments'), ('unsupported_lang', 'unsupported source language'), ('compiler_check_failed', 'compiler check failed'), ('autoconf', 'autoconf compile/link'), ('unsupported_code_directive', 'unsupported code directive'), ('unsupported_compiler_option', 'unsupported compiler option'), ('out_stdout', 'output to stdout'), ('out_device', 'output to a non-regular file'), ('no_input', 'no input file'), ('bad_extra_file', 'error hashing extra file'), ('num_cleanups', 'cleanups performed'), ('cache_files', 'files in cache'), ('cache_size', 'cache size'), ('cache_max_size', 'max cache size')]¶
- STATS_KEYS_4_4 = [('stats_updated', 'Summary/Stats updated'), ('cache_hit_rate', 'Summary/Hits', <function CCacheStats.<lambda>>), ('cache_hit_direct', 'Summary/Hits/Direct', <function CCacheStats.<lambda>>), ('cache_hit_preprocessed', 'Summary/Hits/Preprocessed', <function CCacheStats.<lambda>>), ('cache_miss', 'Summary/Misses'), ('error', 'Summary/Errors'), ('linking', 'Uncacheable/Called for linking'), ('preprocessing', 'Uncacheable/Called for preprocessing'), ('failed', 'Uncacheable/Compilation failed'), ('preprocessor_error', 'Uncacheable/Preprocessing failed'), ('cache_file_missing', 'Errors/Missing cache file'), ('bad_args', 'Uncacheable/Bad compiler arguments'), ('autoconf', 'Uncacheable/Autoconf compile/link'), ('no_input', 'Uncacheable/No input file'), ('num_cleanups', 'Primary storage/Cleanups'), ('cache_files', 'Primary storage/Files'), ('cache_size', 'Primary storage/Cache size (GB)', <function CCacheStats.<lambda>>, True), ('cache_max_size', 'Primary storage/Cache size (GB)', <function CCacheStats.<lambda>>)]¶
- static check_version_4_4_or_newer(ccache)¶
- hit_rate_message()¶
- hit_rates()¶
- 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)¶
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 or file.
- on_line(line)¶
- write(path, output_format)¶
- 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)¶
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
- flush()¶
Ensure all logging output has been flushed.
This version does nothing and is intended to be implemented by subclasses.
- 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, substs=None)¶
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.
- collect_subdirs(root, exclude)¶
Gathers a list of subdirectories excluding specified items.
- delete_dirs(root, paths_to_delete)¶
Deletes the given subdirectories in an optimal way.
- have_winrm()¶
- maybe_do_clobber(cwd, allow_auto=False, fh=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)¶
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.