qibuild.toc – TOC means Obvious Compilation

qibuild.toc.Toc

class qibuild.toc.Toc(work_tree, path_hints=None, config=None, qibuild_cfg=None, build_type='Debug', cmake_flags=None, cmake_generator=None, active_projects=None, solve_deps=True)

This class inherits from qibuild.worktree.WorkTree, so it has a list of projects.

Example of use:

toc = Toc("/path/to/work/tree", build_type="release")

# Look for the foo project in the worktree
foo = toc.get_project("foo")

# Resolve foo dependencies, call cmake on each of them,
toc.configure_project(foo)

# Build the foo project, building all the dependencies in
# the correct order:
toc.build_project(foo)

Since the class is huge, documentation of the Toc class has been splitted in several parts:

Initialisation

Toc.__init__(work_tree, path_hints=None, config=None, qibuild_cfg=None, build_type='Debug', cmake_flags=None, cmake_generator=None, active_projects=None, solve_deps=True)

Create a new Toc object. Most of the keyargs come directly from the command line. (–wortree, –debug, -c, etc.)

Parameters:

Dependency resolution

Toc.resolve_deps(runtime=False)

Return a tuple of three lists: (projects, packages, not_foud), see qibuild.dependencies_solver for more information.

Note that the result depends on how the Toc object has been built.

For instance, assuming you have ‘hello’ depending on ‘world’, and ‘world’ is also a package, you will get:

([‘hello’], [‘world’], []) if user used

$ qibuild configure hello

but:

([‘world’, ‘hello], [], []) if user used:

$ qibuild configure world hello

Attributes

This is only a small list of Toc attributes.

Toc.active_config

See Toc configuration

Toc.config

A qibuild.config.QiBuildConfig instance.

Toc.projects

List of objects of type qibuild.project.Project this is updated using qibuild.worktree.WorkTree.buildable_projects

Toc.toolchain

A qitoolchain.toolchain.Toolchain instance. Will be built from the active configuration name.

Thus, self.toolchain.toolchain_file can be passed as -DCMAKE_TOOLCHAIN_FILE argument when calling configure_project(), and self.toolchain.packages can be used to install contents of binary packages when calling install_project()

Toc configuration

It always has a “current config”. This config can be:

  • None in the simplest case
  • A default configuration specified in the current worktree configuration file (.qi/qibuild.xml)
  • A configuration set by the user with the -c,--config of various qibuild command

Other functions in this module

qibuild.toc.toc_open

qibuild.toc.toc_open(work_tree, args=None, qibuild_cfg=None)

Creates a Toc object.

Parameters:
  • worktree – The worktree to be used. (see qibuild.worktree.WorkTree)
  • args – an argparse.NameSpace object containing the arguments passed from the comand line.
  • qibuild_cfg – A (qibuild.config.QiBuildConfig instance) to use. If None, we built a new instance to store in toc.config

You should always use this function to call Toc methods from a qibuild action.

It takes care of all the options you specify from command line, and calls Toc constructor accordingly (see Toc.__init__())

Typical usage from an action is:

def configure_parser(parser):
    # Add -c option
    qibuild.parsers.toc_parser(parser)

    # Add --release, --cmake-generator, -j options:
    qibuild.parsers.build_parser(parser)

    # Handle specifing zero, one or several project names
    # on the command line
    qibuild.parser.project_parser(parse)


def do(args):
    toc = qibuild.toc.toc_open(args.work_tree, args)
    (project_names, _package_names, _not_found) = toc.resolve_deps()

    for project_name in project_nanes:
        project = toc.get_project(project_name)
        # Do something with 'project'