build :: import "std/build";
// Minimal — just works with defaults
doc_step :: build.doc({ name: "doc", root: "./src/lib.yo" });
// Full customization
doc_step :: build.doc({
name: "doc",
root: "./src",
output: "docs/api",
format: DocFormat.Markdown,
title: "My Library API",
version: "v1.0.0"
});
install :: build.step("install", "Build all artifacts");
install.depend_on(doc_step);
Module build
Declarative build API for Yo projects.
All functions are compile-time only — they register build artifacts and steps that the build runner uses to orchestrate compilation.
Example
build :: import "std/build";
mod :: build.module({ name: "default" }); // a [modules] entry of yo.toml
exe :: build.executable({ name: "my-app", root: "./src/main.yo" });
install :: build.step("install", "Build all artifacts");
install.depend_on(exe);
Stability
unstable — this is the API a project's build.yo is written against, so
it is the one place where a breaking change costs every downstream project
a manual edit, and two things still move. The step model is one:
StepKind and Step expose the runner's DAG vocabulary directly, and the
runner's scheduling is still being changed (levels, artifact caching), so
a build file that reaches past Executable/TestSuite into Step is
reaching at something not yet settled. The other is CompilationTarget,
which gained the canonical Rust triples in
plans/reference/TARGET_TRIPLES.md and may still gain fields as targets
are added.
The declarative face — Executable, StaticLibrary, SharedLibrary,
TestSuite, BuildModule, target_host, the Optimize/Allocator/
Sanitize enums — is what yo init scaffolds and what is expected to
keep its names and meanings. Write build files against that.
Types
Optimization level for compiled artifacts.
Variants
| Variant | Fields | Description |
|---|---|---|
Debug | No optimizations, full debug info.
Compiler Flags: | |
ReleaseSafe | Optimized with safety checks.
Compiler Flags: | |
ReleaseFast | Maximum speed optimizations.
Compiler Flags: | |
ReleaseSmall | Optimize for binary size.
Compiler Flags |
Memory allocator to use in the compiled artifact.
Variants
| Variant | Fields | Description |
|---|---|---|
Mimalloc | High-performance allocator (mimalloc). | |
System | The platform's system allocator (macOS malloc zones, Windows CRT heap, glibc/musl malloc on Linux). | |
Fixed | A general-purpose TLSF allocator over ONE statically-sized region in
|
Runtime sanitizer to enable.
Variants
| Variant | Fields | Description |
|---|---|---|
None | No sanitizer. | |
Address | AddressSanitizer — detects memory errors and leaks. | |
Leak | LeakSanitizer — detects memory leaks only. | |
Thread | ThreadSanitizer — detects data races in multi-threaded code. |
Kind of build step.
Variants
| Variant | Fields | Description |
|---|---|---|
Executable | Configuration for building an executable. | |
StaticLibrary | Configuration for building a static library. | |
SharedLibrary | Configuration for building a shared/dynamic library. | |
SystemLibrary | System C library discovered via | |
TestSuite | Configuration for a test suite. | |
Run | ||
Custom | ||
Documentation |
Configuration for building an executable.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
root | comptime_str | Root source file or directory to document. |
target | comptime_str | Compilation target triple (defaults to host). |
optimize | Optimize | Optimization level. |
allocator | Allocator | Memory allocator. |
heap_size | usize | Fixed-region heap size in bytes ( |
sanitize | Sanitize | Runtime sanitizer. |
emit_c_to | comptime_str | Write the single generated C file to this path instead of the default
|
emit_chunks | comptime_int | Split the emitted C into this many translation units, compiled in
PARALLEL behind a content-addressed object cache and then linked
(plans/reference/CHUNKED_C_EMISSION.md). 0 = off, one C file as before — which is
the default because the single-file emission is what the bootstrap gates
and the portable-C distribution compare. At -O1 and above a chunked
build also gets |
Configuration for building a static library.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
root | comptime_str | Root source file or directory to document. |
target | comptime_str | Compilation target triple (defaults to host). |
optimize | Optimize | Optimization level. |
Configuration for a test suite.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
root | comptime_str | Root source file or directory to document. |
target | comptime_str | Compilation target triple (defaults to host). |
exclude | comptime_str | Comma-separated paths (files or directories, relative to the project root) excluded from the test walk — a path is excluded if it equals an entry or lives under one, e.g. "tests/internal,tests/cli-cases". |
verbose | bool | Print each test as it runs ( |
bail | bool | Stop at the first failing test ( |
parallel | usize | Test files to compile at once ( |
A named module of this package or of a dependency, as a handle for
linking system libraries (mod.link(sys)). Which FILE the module is —
and what import("name") resolves to — is the manifest's business
(yo.toml [modules], plans/BUILD_AND_DEPENDENCY_SYSTEM_REDESIGN.md §4.1).
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
_dep | comptime_str | The dependency the module belongs to ( |
impl(BuildModule, ...)
link : (BuildModule) fn(self : BuildModule, library : Step) -> unitLink a system library into this module.
Parameters
| Name | Type | Notes |
|---|---|---|
self | BuildModule | comptime |
library | Step | comptime |
Returns: unit
A build step returned by all registration functions.
Use step.depend_on(dep) to wire dependencies between steps.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
kind | StepKind | Kind of step. |
impl(Step, ...)
depend_on : (Step) fn(self : Step, dep : Step) -> unitlink : (Step) fn(self : Step, library : Step) -> unitadd_c_flags : (Step) fn(self : Step, flags : comptime_str) -> unitAdd extra C compiler flags to this step.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Step | comptime |
flags | comptime_str | comptime |
Returns: unit
User-configurable build option (declared in build.yo, set via yo build -Dname=value).
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
description | comptime_str | Human-readable description. |
default | comptime_str | Default value if not provided. |
System C library discovered via pkg-config.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
fallback_include | comptime_str | Fallback include path if pkg-config fails. |
fallback_lib | comptime_str | Fallback library path. |
fallback_link | comptime_str | Fallback link flags. |
defines | comptime_str | Extra C preprocessor defines. |
Handle to a manifest dependency. Use .artifact() or .module() to access its exports.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
impl(Dependency, ...)
artifact : (Dependency) fn(self : Dependency, artifact_name : comptime_str) -> StepAccess a named artifact from the dependency's build.yo.
Returns a Step that can be linked to the consumer's artifacts.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Dependency | comptime |
artifact_name | comptime_str | comptime |
Returns: Step
module : (Dependency) fn(self : Dependency, module_name : comptime_str) -> BuildModuleGet a module from the dependency's build.yo.
Empty module_name defaults to the sole module if exactly one exists.
Parameters
| Name | Type | Notes |
|---|---|---|
self | Dependency | comptime |
module_name | comptime_str | comptime, default: "" |
Returns: BuildModule
Module configuration. The module's root file is declared in yo.toml's
[modules] table (default = "src/lib.yo", board = "src/board.yo");
build.module names one of those to attach system libraries to it.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
Output format for documentation generation.
Variants
| Variant | Fields | Description |
|---|---|---|
Html | ||
Markdown | ||
Json |
Configuration for documentation generation.
Fields
| Name | Type | Description |
|---|---|---|
name | comptime_str | Step name (e.g., "doc"). |
root | comptime_str | Root source file or directory to document. |
output | comptime_str | Output directory (default: "yo-out/doc"). |
format | DocFormat | Output format (default: Html). |
include_private | bool | Document non-exported (private) items. |
title | comptime_str | Custom site title (default: project name). |
version | comptime_str | Release version to display (e.g., "v1.0.0"). When empty, auto-detects from git tag or commit hash. |
logo | comptime_str | Path to logo image. |
favicon | comptime_str | Path to favicon. |
Functions
Register an executable artifact. Returns a Step for dependency wiring.
Parameters
| Name | Type | Notes |
|---|---|---|
config | Executable | comptime |
Returns: comptime(Step)
Register a static library artifact. Returns a Step for dependency wiring.
Parameters
| Name | Type | Notes |
|---|---|---|
config | StaticLibrary | comptime |
Returns: comptime(Step)
Create a run step (compile + execute an artifact). Returns a Step.
Parameters
| Name | Type | Notes | Description |
|---|---|---|---|
artifact | Step | comptime | Access a named artifact from the dependency's |
Returns: comptime(Step)
Register a named build step. Use step.depend_on(dep) to add dependencies.
Parameters
| Name | Type | Notes | Description |
|---|---|---|---|
name | comptime_str | comptime | Step name (e.g., "doc"). |
description | comptime_str | comptime | Human-readable description. |
Returns: comptime(Step)
The handle of a dependency declared in yo.toml's [dependencies] (or
[dev-dependencies]) — Zig's b.dependency(name, .{}). Where the
dependency comes from (git, version, path) is the manifest's; the build
file only names it. The runner rejects a name the manifest lacks.
Parameters
| Name | Type | Notes | Description |
|---|---|---|---|
name | comptime_str | comptime | Step name (e.g., "doc"). |
Returns: comptime(Dependency)
Register a system C library discovered via pkg-config. Returns a Step for linking.
Parameters
| Name | Type | Notes |
|---|---|---|
config | SystemLibrary | comptime |
Returns: comptime(Step)
Get a module from the dependency's build.yo.
Empty module_name defaults to the sole module if exactly one exists.
Parameters
| Name | Type | Notes |
|---|---|---|
config | ModuleConfig | comptime |
Returns: BuildModule
Declare a user-configurable build option.
Returns the option value (from CLI -Dname=value, or the default).
Example
strip :: build.option({
name: "strip",
description: "Strip debug symbols",
default: "false"
});
Parameters
| Name | Type | Notes |
|---|---|---|
config | BuildOption | comptime |
Returns: comptime(str)
The environment variable name, or fallback when it is unset.
Readable ONLY from a build file. An ordinary module that read the
environment would mean something different under yo build, yo check,
yo test and the editor, so the builtin is a compile error everywhere else.
Every read is folded into the artifact input stamp, so changing a variable the build file branches on rebuilds rather than serving a stale artifact.
PREFER build.option and -Dname=value: an option is declared, listed by
yo build --list-options, and visible in the command that produced a build.
Reach for env for what genuinely belongs to the environment — CI
detection, PKG_CONFIG_PATH, a default that depends on the machine.
Parameters
| Name | Type | Notes | Description |
|---|---|---|---|
name | comptime_str | comptime | Step name (e.g., "doc"). |
fallback | comptime_str | comptime |
Returns: comptime(str)
Whether name is set at all, which env alone cannot tell you: a variable
set to the same text as the fallback is indistinguishable from an unset one.
Parameters
| Name | Type | Notes | Description |
|---|---|---|---|
name | comptime_str | comptime | Step name (e.g., "doc"). |
Returns: comptime(bool)
Register a documentation generation step. Returns a Step for dependency wiring.
Examples
build :: import "std/build";
// Minimal — just works with defaults
doc_step :: build.doc({ name: "doc", root: "./src/lib.yo" });
// Full customization
doc_step :: build.doc({
name: "doc",
root: "./src",
output: "docs/api",
format: DocFormat.Markdown,
title: "My Library API",
version: "v1.0.0"
});
install :: build.step("install", "Build all artifacts");
install.depend_on(doc_step);
Parameters
| Name | Type | Notes |
|---|---|---|
config | DocConfig | comptime |
Returns: comptime(Step)
Examples
Constants
The supported compilation targets, named by their canonical Rust-style
triple (<arch>-<vendor>-<os>[-<env>], plus wasm32-wasip1) — the same
strings yo compile --target takes and the release assets are named by.
There are no aliases: an unrecognised spelling is rejected with this list.
Value: struct_yo_id_20092(X86_64_Unknown_Linux_Gnu: "x86_64-unknown-linux-gnu", X86_64_Unknown_Linux_Musl: "x86_64-unknown-linux-musl", Aarch64_Unknown_Linux_Gnu: "aarch64-unknown-linux-gnu", Aarch64_Unknown_Linux_Musl: "aarch64-unknown-linux-musl", Aarch64_Apple_Darwin: "aarch64-apple-darwin", X86_64_Apple_Darwin: "x86_64-apple-darwin", X86_64_Pc_Windows_Msvc: "x86_64-pc-windows-msvc", Aarch64_Pc_Windows_Msvc: "aarch64-pc-windows-msvc", Wasm32_Unknown_Emscripten: "wasm32-unknown-emscripten", Wasm32_Wasip1: "wasm32-wasip1")
Host compilation target string.
Value: "x86_64-unknown-linux-gnu"