host.toolchain

Per-host toolchain configuration for coverage and build tools.

Each UnixHost carries a Toolchain that describes where lcov, gcov, and the compiler live. Tool paths are stored relative to the sysroot so that a single sysroot change is enough to switch an entire cross-toolchain.

Sensible defaults (sysroot='/', tools under usr/bin/) mean hosts with system-installed toolchains need no configuration at all.

class otto.host.toolchain.Toolchain(sysroot=PosixPath('/'), lcov=PosixPath('usr/bin/lcov'), gcov=PosixPath('usr/bin/gcov'))

Bases: object

Describes the toolchain associated with a host’s products.

Variables:
sysroot=PosixPath('/')

Root directory of the toolchain installation. Defaults to / (system toolchain).

lcov=PosixPath('usr/bin/lcov')

Path to the lcov binary, relative to sysroot.

gcov=PosixPath('usr/bin/gcov')

Path to the gcov binary (or an llvm-cov wrapper), relative to sysroot.

sysroot : --is-rst--:py:class:`~pathlib.Path`

Root directory of the toolchain installation.

lcov : --is-rst--:py:class:`~pathlib.Path`

Path to lcov, relative to sysroot.

gcov : --is-rst--:py:class:`~pathlib.Path`

Path to gcov (or llvm-cov wrapper), relative to sysroot.

property lcov_bin : str

Absolute path to the lcov binary.

property gcov_bin : str

Absolute path to the gcov binary.

property compiler : Path | None

Derive the compiler path from the gcov path.

For GCC toolchains the gcov binary name mirrors the compiler (e.g. arm-linux-gnueabihf-gcovarm-linux-gnueabihf-gcc).

For Clang/LLVM toolchains where the gcov path contains llvm-cov, the compiler is assumed to be clang in the same directory.

Returns None when the compiler cannot be inferred.

host.toolchain_discovery

Auto-discover the toolchain from .gcno files.

When a host has no explicit Toolchain configured, the coverage pipeline can attempt to infer the correct gcov (and by extension lcov) from compiler paths embedded in .gcno files produced by gcc --coverage or clang --coverage.

Both GCC and Clang families are supported:

  • GCC: arm-linux-gnueabihf-gccarm-linux-gnueabihf-gcov

  • Clang: clang → generates a wrapper script that invokes llvm-cov gcov (required because lcov --gcov-tool takes a single command).

async otto.host.toolchain_discovery.discover_toolchain_from_gcno(gcno_dir, localhost, work_dir=None)

Inspect .gcno files to discover the compiler toolchain.

Runs strings on a sample of .gcno files and looks for absolute paths to gcc, g++, clang, or clang++. From that path the matching gcov binary and sysroot are derived.

Parameters:
  • gcno_dir – Directory containing .gcno files from the build.

  • localhostLocalHost for running shell commands.

  • work_dir – Directory for writing wrapper scripts (Clang only). If None, defaults to gcno_dir / '_toolchain_work'.

Return type:

Toolchain | None

Returns:

A Toolchain if discovery succeeds, None otherwise.

otto.host.toolchain_discovery.toolchain_from_gcov(gcov)

Build a Toolchain from an explicitly-configured gcov binary.

A .gcno embeds no compiler path, and not every build system is CMake, so a cross-toolchain is named directly in the repo config ([coverage.embedded].gcov) — the same explicit shape as the Unix coverage config. The sysroot is derived from the gcov’s bin/ directory.

Parameters:

gcov – Absolute path to the cross gcov binary.

Return type:

Toolchain