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:
objectDescribes the toolchain associated with a host’s products.
- Variables:¶
- 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(orllvm-covwrapper), relative to sysroot.
- property lcov_bin : str¶
Absolute path to the
lcovbinary.
- property gcov_bin : str¶
Absolute path to the
gcovbinary.
- 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, localhost, work_dir=
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.- Parameters:¶
gcno_dir – Directory containing
.gcnofiles from the build.localhost –
LocalHostfor running shell commands.work_dir – Directory for writing wrapper scripts (Clang only). If
None, defaults togcno_dir / '_toolchain_work'.
- Return type:¶
Toolchain|None- Returns:¶
A
Toolchainif discovery succeeds,Noneotherwise.
- otto.host.toolchain_discovery.toolchain_from_gcov(gcov)¶
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.