mozbuild.compilation package

Submodules

mozbuild.compilation.codecomplete module

mozbuild.compilation.codecomplete.compileflags(command_context, what)

mozbuild.compilation.database module

class mozbuild.compilation.database.CompileDBBackend(environment)

Bases: CommonBackend

CFLAGS = {'.c': 'CFLAGS', '.cpp': 'CXXFLAGS', '.m': 'CFLAGS', '.mm': 'CXXFLAGS'}
COMPILERS = {'.c': 'CC', '.cpp': 'CXX', '.m': 'CC', '.mm': 'CXX'}
consume_finished()

Called when consume() has completed handling all objects.

consume_object(obj)

Consumes an individual TreeMetadata instance.

This is the main method used by child classes to react to build metadata.

mozbuild.compilation.util module

mozbuild.compilation.util.check_top_objdir(topobjdir)
mozbuild.compilation.util.get_build_vars(directory, cmd)
mozbuild.compilation.util.sanitize_cflags(flags)

mozbuild.compilation.warnings module

class mozbuild.compilation.warnings.CompilerWarning

Bases: dict

Represents an individual compiler warning.

copy()

Returns a copy of this compiler warning.

class mozbuild.compilation.warnings.WarningsCollector(cb, objdir=None)

Bases: object

Collects warnings from text data.

Instances of this class receive data (usually the output of compiler invocations) and parse it into warnings.

The collector works by incrementally receiving data, usually line-by-line output from the compiler. Therefore, it can maintain state to parse multi-line warning messages.

process_line(line)

Take a line of text and process it for a warning.

class mozbuild.compilation.warnings.WarningsDatabase

Bases: object

Holds a collection of warnings.

The warnings database is a semi-intelligent container that holds warnings encountered during builds.

The warnings database is backed by a JSON file. But, that is transparent to consumers.

Under most circumstances, the warnings database is insert only. When a warning is encountered, the caller simply blindly inserts it into the database. The database figures out whether it is a dupe, etc.

During the course of development, it is common for warnings to change slightly as source code changes. For example, line numbers will disagree. The WarningsDatabase handles this by storing the hash of a file a warning occurred in. At warning insert time, if the hash of the file does not match what is stored in the database, the existing warnings for that file are purged from the database.

Callers should periodically prune old, invalid warnings from the database by calling prune(). A good time to do this is at the end of a build.

deserialize(fh)

Load serialized content from a handle into the current instance.

has_file(filename)

Whether we have any warnings for the specified file.

insert(warning, compute_hash=True)
load_from_file(filename)

Load the database from a file.

prune()

Prune the contents of the database.

This removes warnings that are no longer valid. A warning is no longer valid if the file it was in no longer exists or if the content has changed.

The check for changed content catches the case where a file previously contained warnings but no longer does.

save_to_file(filename)

Save the database to a file.

serialize(fh)

Serialize the database to an open file handle.

type_counts(dirpath=None)

Returns a mapping of warning types to their counts.

property warnings

All the CompilerWarning instances in this database.

warnings_for_file(filename)

Obtain the warnings for the specified file.

Module contents