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: Path =
PosixPath('/'), lcov: Path =PosixPath('usr/bin/lcov'), gcov: Path =PosixPath('usr/bin/gcov'))¶ Bases:
objectDescribes the toolchain associated with a host’s products.
- Variables:¶
- sysroot : pathlib.Path¶
Root directory of the toolchain installation. Defaults to
/(system toolchain).- lcov : pathlib.Path¶
Path to the
lcovbinary, relative to sysroot.- gcov : pathlib.Path¶
Path to the
gcovbinary (or anllvm-covwrapper), relative to sysroot.
- 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-gcov→arm-linux-gnueabihf-gcc).For Clang/LLVM toolchains where the gcov path contains
llvm-cov, the compiler is assumed to beclangin the same directory.Returns
Nonewhen 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-gcc→arm-linux-gnueabihf-gcovClang:
clang→ generates a wrapper script that invokesllvm-cov gcov(required becauselcov --gcov-tooltakes a single command).
-
async otto.host.toolchain_discovery.discover_toolchain_from_gcno(gcno_dir: Path, localhost: LocalHost, work_dir: Path | None =
None) Toolchain | None¶ Inspect
.gcnofiles to discover the compiler toolchain.Runs
stringson a sample of.gcnofiles and looks for absolute paths togcc,g++,clang, orclang++. From that path the matchinggcovbinary and sysroot are derived.
- otto.host.toolchain_discovery.toolchain_from_gcov(gcov: Path) Toolchain¶
Build a
Toolchainfrom an explicitly-configured gcov binary.A
.gcnoembeds 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’sbin/directory.- Parameters:¶
gcov – Absolute path to the cross
gcovbinary.