Turn a recipe pattern into a .bbclass. Start with a guided template, understand each decision, then take the metadata into your own layer.
One class, many recipes. Changes affect every inheriting recipe. Review generated metadata and only trust code you understand before running BitBake.
LIVE METADATA
Your class, ready to review.
● Browser only
ZIP includes class, sample recipe, any source asset, layer.conf and a usage README. Downloads never run automatically. Requires an existing configured Scarthgap environment with the core layer.
THE FIELD GUIDE
Generate here. Verify in BitBake.
A structured preview is not a build result. Custom code is unparsed and untrusted; your sources, providers, overrides and toolchain must be checked in your real environment.
01 / Put it in a layer
Recipe: classes-recipe/name.bbclass with inherit name in a recipe. Global: classes-global/name.bbclass with INHERIT += "name" in configuration. Global generation is deliberately variables-only.
classes/ is the fallback shared directory for both contexts. Scoped directories are searched first across BBPATH; layer order can shadow same-named classes. Don't use a global class for per-recipe install tasks.
Run from an initialized Yocto build shell, after adding the layer. Replace your-sample with the generated recipe name. -p parses metadata; -e expands it (including trusted anonymous Python); -g writes dependency graphs, not a build. Inspect ${T}/log.do_* and run.do_* after tasks. The ZIP guide has exact commands.
03 / Advanced, intentionally explicit
Advanced controls now generate prefuncs/postfuncs logging helpers, EXPORT_FUNCTIONS implementations with recipe replacement examples, and guided or custom anonymous Python. Anonymous python () runs at parse finalization, even with -p/-e; keep it deterministic and trust all code.
BBCLASSEXTEND is generated on report/preflight sample recipes only; they omit allarch for native/SDK variants. Variable rows support conditional append/prepend/remove. Configuration and systemd templates supply their actual files, install tasks and package-scoped metadata. Native variants and target install templates cannot be mixed.
04 / Respect the build contract
Use ${D} for staged installation and the provided ${CC}/${CFLAGS}/${LDFLAGS} for cross-compilation. Never use host gcc or disable QA to hide errors. The data template uses install, not a compiler.
Signatures track task bodies and detected variable dependencies; stamps can skip unchanged work. vardeps fills analysis gaps. We deliberately omit cleandirs: it deletes and recreates directories before execution. No template performs host cleanup.
Release contract
Yocto 5.0.13 Scarthgap · bundled BitBake 2.8.1. Poky commit f16cffd030d21d12dd57bb95cfc310bda41f8a1f. Annotated tag object 529843b1c189ab7b133b7fdf197d4b2a4b71a6db points to that commit; it is not a commit SHA.