docs: add VoidBuildSystem handbook

This commit is contained in:
faumaray committed 2026-12-06 12:58:59 +03:00
1 parent 1f9a5d5804
commit 00e14bae98
19 files changed
+3240

No files matched your search

@@ -0,0 +1,249 @@
---
title: Declaring Builds in C++26
description: build.cpp entry points, targets, usage requirements, custom actions, profiles, modules, shaders and install rules
section: Build Descriptions
badge: build.cpp
order: 1
tags: [build.cpp, sdk, targets, profiles, visibility, modules, shaders]
updated: 2026-12-06
---
# Declaring Builds in C++26
A VBS project is ordinary C++26. The description is compiled once on the host, then executed out of process for each resolved profile. The program emits a versioned (`schema_version: 1`) JSON description that the engine validates and lowers; it never calls back into the engine while declaring targets.
```cpp
#include <Void/Build.hpp>
void build(Void::Build::Project &project) {
project.dependencies_file("vbs.deps.toml");
auto core = project.static_library("core");
core.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources(project.glob("src/core/**/*.cpp"))
.include_directory("include", Void::Build::Visibility::Public);
auto app = project.executable("app");
app.sources({"src/main.cpp"}).link(core).install("bin");
auto tests = project.test("app_tests");
tests.sources({"tests/app_test.cpp"}).link(core).label("unit");
}
```
## What the engine discovers
| File | Role |
| --- | --- |
| `build.cpp` | Required for a single-package project. Must define `void build(Void::Build::Project &)`. |
| `build.profiles.cpp` | Optional. Must define `void profiles(Void::Build::Profiles &)`; without it the default profiles are used. |
| `build-support/**/*.{cpp,cc,cxx}` and `.hpp` | Optional helpers. C++ implementation files are compiled into the host description; headers are discovered through depfiles. Sorted deterministically. |
| `workspace.cpp` | Marks a workspace root and defines `void workspace(Void::Build::Workspace &)`. |
| `vbs.deps.toml` | Optional declarative dependency manifest, when referenced by `project.dependencies_file(...)`. |
| `vbs.lock` | Generated lockfile; never edited by hand. |
| `compile_commands.json`, `.vbs/`, `build/` | Generated editor and build state; ignored by convention. |
Discovery is filesystem-based and works without `.git`. Additional description sources can be passed with `vbs build --build-source FILE`; the same files may be declared in a package manifest so exported sources remain buildable.
:::callout{type="info" title="Host compilation is separate from target evaluation"}
`build.cpp` is compiled with the fixed SDK and the host compiler before any project dependency is resolved. It may use the C++ standard library, your own `build-support` helpers, `project.context()`, and environment variables. It must not depend on a target toolchain or on files produced by the build.
:::
## Profiles and context
`void profiles(Profiles &)` declares named profiles once. `Profiles::resolve(name, compiler_override, os, architecture)` produces an immutable `ProfileContext`; `project.context()` exposes it while the description evaluates.
```cpp
void profiles(Void::Build::Profiles &profiles) {
profiles.add("debug", {"-O0", "-g"});
Void::Build::ProfileDescription release;
release.name = "release";
release.parent = "debug";
release.compile_options = {"-O3", "-DNDEBUG"};
release.lto = Void::Build::LtoMode::Thin;
profiles.define(release);
Void::Build::ProfileDescription asan;
asan.name = "asan";
asan.parent = "debug";
asan.sanitizers = {Void::Build::Sanitizer::Address, Void::Build::Sanitizer::Undefined};
profiles.define(asan);
}
```
The default profiles when no `build.profiles.cpp` exists are:
| Profile | Compile options |
| --- | --- |
| `debug` | `-O0 -g` |
| `release` | `-O3 -DNDEBUG` |
`ProfileDescription` also accepts `link_options`, `defines`, `compiler`, `c_standard`, `cxx_standard`, `sysroot`, `compiler_path`, `reproducibility_epoch` and `nondeterministic`. Inheritance is resolved transitively; unknown parents, self-inheritance and cycles are explicit errors.
`ProfileContext` carries `name`, `compiler`, `os`, `architecture`, `compile_options`, `link_options`, `defines`, `c_standard`, `cxx_standard`, `lto`, `sanitizers`, `sysroot`, `compiler_path`, `reproducibility_epoch` and `nondeterministic`.
:::callout{type="tip" title="Ordinary C++ conditionals are the point"}
Because the description is compiled C++, context-sensitive declarations use normal `if`/`else` rather than generator expressions. `os` is the host system name (`Linux`) or the `--target-os` spelling (`windows`), so compare it case-insensitively:
```cpp
#include <Void/Text/Str.hpp>
if (Void::Str::to_lower_ascii(project.context().os) == "windows") {
app.link_option("-lws2_32");
}
if (project.context().compiler == Void::Build::CompilerFamily::Clang) {
app.compile_option("-Wextra-semi");
}
```
:::
## Targets
There are seven `TargetKind`s, created by these project methods:
| Method | Kind | Primary output |
| --- | --- | --- |
| `project.executable(name)` | `Executable` | `out/bin/<name>` (`.exe` on Windows targets) |
| `project.static_library(name)` | `StaticLibrary` | `out/lib<name>.a` |
| `project.shared_library(name)` | `SharedLibrary` | `out/lib<name>.so` (`.dll` on Windows targets) |
| `project.header_only_library(name)` | `HeaderOnly` | No compiled artifact; exports usage requirements |
| `project.object_library(name)` | `ObjectLibrary` | Object files linked into consumers |
| `project.custom_action(name)` | `CustomAction` | Declared outputs under `gen/` unless absolute |
| `project.test(name)` | `Test` | Executable in `out/bin/` that `vbs test` runs |
`project.shader_bundle(name)` is a helper that creates a `CustomAction` with shader sources and per-source SPIR-V outputs.
Target names must be non-empty and unique. Handles validate ownership and lifetime; a stale handle or a link across projects throws instead of recording an invalid edge.
### Sources
```cpp
target.sources({"src/main.cpp", "src/window.cpp"}); // explicit files
target.sources(project.glob("src/**/*.cpp")); // glob
target.sources(Void::Build::SourceSet::file("src/one.cpp"));
target.sources(Void::Build::SourceSet::module_interface("src/core.cppm"));
target.module_sources(Void::Build::SourceSet::module_partition("src/part.cppm"));
target.header_unit("include/legacy.hpp");
target.conventional_sources(); // src/, source/, include/
```
- `project.glob(...)` returns a symbolic `SourceSet`; expansion happens during graph lowering against the validated project root.
- `conventional_sources()` scans `src/` and `source/` recursively for C++ and assembly sources, and adds `include/` as an include directory. It does not add files from `build/`, `.vbs/`, `build-support/`, `.git/` or editor metadata.
- `module_interface`, `module_partition` and `header_unit` mark module-aware sources for the P1689 scanner.
- `$GEN/<path>` refers to the profile's generated directory (`build/profiles/<profile>/gen`). Generated sources and headers produced by a `custom_action` can be consumed with `$GEN/...` or `gen/...`.
C and C++ sources share one target graph. `.c` files use the C driver and `c_standard(...)`; `.cpp` files use the C++ driver and `cxx_standard(...)`. `.s` and preprocessed `.S` assembly compile through the C driver without C/C++ standard flags, LTO or sanitizers, and are excluded from unity and module scanning.
### Usage requirements and visibility
Every scoped requirement takes a `Visibility`:
| Visibility | Applied to the declaring target | Exported to consumers |
| --- | --- | --- |
| `Private` | Yes | No |
| `Public` | Yes | Yes |
| `Interface` | No | Yes |
```cpp
core.include_directory("include", Void::Build::Visibility::Public)
.define("CORE_EXPORTS", Void::Build::Visibility::Private)
.compile_option("-Wall")
.link_option("-pthread", Void::Build::Visibility::Public);
```
- Include directories, defines and compile options follow the table exactly.
- A `Private` static-library dependency still contributes its static archives and transitive link inputs to the final linker; this preserves the link closure even when the dependency is not part of the public API. Consumers do not inherit its compile requirements.
- Link order is preserved: a dependency's own libraries come before its transitive libraries. The engine never sorts the link line.
- Imported targets from a dependency are linked with `target.link(dep.target("Exported::Name"))`; a missing imported target is a hard error, never silently dropped.
- `depends_on(other)` adds action ordering without linking. Use it for generated headers and code generators.
### Compilation features
| Method | Effect |
| --- | --- |
| `c_standard(CStandard)` | `Default`, `C11`, `C17`, `C23` |
| `cxx_standard(CxxStandard)` | `Default`, `Cxx17`, `Cxx20`, `Cxx23`, `Cxx26` |
| `precompiled_header(path)` | Builds and uses a PCH for compatible sources |
| `unity_build(enabled, batch_size)` | Batches TUs deterministically; excludes `.c`, modules and per-file overrides |
| `lto(LtoMode)` | `None`, `Full`, `Thin` |
| `sanitizer(Sanitizer)` | `Address`, `Undefined`, `Thread`, `Memory`, `Leak` |
| `per_file_option(source, opt)` | Per-TU flag; excluded from unity batches |
| `enabled(false)` | Keeps the target declared but does not lower it |
Incompatible sanitizer combinations are rejected during description validation or graph lowering (for example `Memory` with `Address`, or `Thread` with `Leak`). Profile sanitizers and target sanitizers combine.
### Custom actions and shaders
```cpp
auto generate = project.custom_action("generate_table");
generate.command({"python3", "tools/gen.py", "--out", "$GEN/table.hpp"})
.inputs({"tools/gen.py", "data/table.json"})
.outputs({"table.hpp"})
.working_directory(".")
.env("GEN_MODE", "strict");
core.include_directory("$GEN", Void::Build::Visibility::Private)
.depends_on(generate);
```
A custom action must declare `command()` and at least one output. Relative outputs are placed under the profile's generated root; relative inputs are resolved against the project root. The command line expands `$GEN`, `$PROJECT_ROOT` and `$BUILD_DIR`. Deterministic actions receive `SOURCE_DATE_EPOCH`, `TZ=UTC` and `LC_ALL=C`; declaring `nondeterministic()` disables cache and incremental reuse.
Shader bundles compile each declared source to SPIR-V:
```cpp
auto shaders = project.shader_bundle("shaders");
shaders.shader("shaders/tri.vert")
.shader("shaders/tri.frag", Void::Build::ShaderLanguage::Glsl)
.shader("shaders/particles.comp", Void::Build::ShaderLanguage::Slang,
Void::Build::ShaderStage::Compute);
```
The toolchain is discovered from `PATH`: `glslangValidator` for GLSL/HLSL, `slangc` for Slang, and `dxc` for HLSL. A missing compiler for a declared shader is an explicit error.
### Installation rules
```cpp
app.install("bin");
core.install("lib");
project.install_directory("include", "include");
project.install_file("LICENSE", "share/doc/core/LICENSE", "docs");
```
`install(destination, component)` uses the target's primary artifact and default destination when omitted (executables to `bin`, libraries to `lib`). `install_file` and `install_directory` declare non-target artifacts. Components are selected with `vbs install --component NAME`.
### Tests, labels, resources and fixtures
```cpp
auto db_test = project.test("db_integration");
db_test.sources({"tests/db.cpp"})
.link(core)
.label("integration")
.resource("database")
.fixture_setup("database")
.fixture_required("database");
auto db_cleanup = project.test("db_cleanup");
db_cleanup.label("fixture").fixture_cleanup("database");
```
- `label(...)` lets `vbs test --label NAME` select tests; labels are repeatable and ORed.
- `resource(...)` serializes tests that share a resource, even under higher `--jobs`.
- Fixtures follow the CTest model: a setup test runs before its users, a required fixture pulls the setup in automatically, and cleanup runs after every user. If setup fails, dependents are skipped.
## Validation and deterministic output
Before any action runs, the engine rejects:
- duplicate target names, unknown prerequisite/link targets and target cycles;
- output path collisions and outputs that overlap editable source files outside the build directory;
- invalid standards, incompatible sanitizers, empty names and contradictory declarations;
- Windows case-insensitive output collisions (`Tool.exe` vs `tool.exe`) and reserved device names (`CON`, `NUL`, `COM1`, …).
The description serializer validates every emitted string as UTF-8 and emits deterministic JSON, so identical declarations produce identical description bytes.
## Next steps
- [Add dependencies and lock them](/build-system/consumer/dependencies)
- [Use the everyday command line](/build-system/consumer/command-reference)
- [See how the graph is lowered internally](/build-system/developer/configuration-and-graph)
@@ -0,0 +1,215 @@
---
title: Command and Environment Reference
description: Every vbs and vbs-registry command, the flags that matter, build-tree conventions and environment variables
section: Daily Workflows
badge: CLI
order: 1
tags: [cli, reference, build, test, gc, doctor, graph, describe, environment]
updated: 2026-12-06
---
# Command and Environment Reference
All help text is generated by `Void::Argparse::Parser`. Use `vbs <command> --help` or `vbs <command> <subcommand> --help` for the authoritative flag list. Global flags apply before or after the command: `--verbose`/`-v`, `--quiet`/`-q`, `--no-color`, `--version`/`-V`, `--help`/`-h`.
Most project commands accept:
| Flag | Default | Meaning |
| --- | --- | --- |
| `--project`, `-C` | current directory | Project root |
| `--build-dir`, `-B` | `<project>/build` | Build root; a relative value resolves against the current directory. `clean` and `gc` take no `--project`, so their default is `<cwd>/build`. |
| `--profile`, `-p` | `debug` | Profile; repeatable on build/test |
| `--compiler` | discovered GCC | `gcc` or `clang` |
| `--target-os` | host OS | Cross/target OS (for example `windows`) |
| `--target-arch` | host architecture | Cross/target architecture |
## Build and test
```sh
vbs build [--project DIR] [--build-dir DIR] [--profile NAME]... [--target NAME]...
vbs test [same build flags] [test flags]
```
Build flags:
- `--locked`: require an existing, matching `vbs.lock`; never create or update it. This check only applies when the project declares dependencies.
- `--offline`: forbid network fetches; use verified cached data only.
- `--no-cache`: bypass action-cache reads while still recording successes.
- `--native-foreign`: translate supported CMake/Meson dependency graphs into native VBS actions.
- `--jobs`, `-j`: parallel action limit; `0` or omitted uses the hardware concurrency.
- `--editor-profile`: which profile may publish `compile_commands.json` when multiple profiles are selected.
- `--build-source FILE`: extra description source, repeatable.
- `--member NAME`: workspace member, repeatable.
- `--changed-since REF`: select workspace members changed since a Git ref.
- `--sbom FILE` and `--sbom-format spdx|cyclonedx`: write a deterministic SBOM after success.
- `--remote-cache URL` and `--remote-cache-token-env VAR`: shared HTTP action cache.
- `--trusted-public-key HEX` and `--trusted-key-file FILE`: signed-package enforcement, repeatable.
Test flags:
- `--label NAME`: only run tests carrying this label, repeatable and ORed.
- `--test-timeout SECONDS`: per-test timeout, default `300`, allowed `1..86400`.
- `--junit FILE`: write JUnit XML for all executed tests.
- `--coverage DIR`: compile and link with `--coverage`, then write `coverage.info` (lcov) and `summary.txt`.
- `--cdash URL`, `--cdash-project NAME`, `--cdash-build NAME`, `--cdash-output FILE`: render/upload a CTest-compatible `Test.xml`.
A successful build prints `built (N executed, M cached)`. Compiler warnings from successful actions are printed too, not hidden until a failure. Build results are per profile, so `-p debug -p release` produces independent outputs.
## Inspect the project
| Command | Purpose |
| --- | --- |
| `vbs describe` | Evaluate the description and print a compact JSON summary (`profile`, target count, dependency count). |
| `vbs graph --format dot` | Graphviz target dependency graph. |
| `vbs graph --format json` | Machine-readable target/link graph. |
| `vbs doctor` | Host, compiler, optional tool and backend capabilities; non-zero when a required tool is missing. |
| `vbs lock show` | Print lock contexts and entries (package, version, source, digest, signed state). |
| `vbs presets` | List `CMakePresets.json` mappings, or print the equivalent `vbs build` command for one preset. |
| `vbs compdb-entries` | Query bounded entries from the active compilation database. |
| `vbs daemon info` | Paths, version, host facts and enabled backends from the daemon. |
`vbs graph` and `vbs describe` never compile project targets. They still compile the host description, evaluate the profile and probe the toolchain; `vbs graph` also imports provider metadata. `vbs ide` resolves dependencies in offline mode and never fetches.
## Compilation database and editor metadata
| Command | Purpose |
| --- | --- |
| `vbs compdb export` | Evaluate and publish the profile `compile_commands.json` without compiling targets. |
| `vbs compdb use PROFILE` | Switch the active editor profile to an already published database. |
| `vbs compdb show` | Print the active profile, generation, ticket and path. |
| `vbs compdb watch` | Watch project metadata and refresh the database without building. |
| `vbs ide generate` | Write `.clangd`, `.vscode/`, `.zed/`, `.idea/` and the CMake File API reply tree. |
| `vbs ide query` | Print versioned JSON with project, toolchain, compdb and per-target metadata. |
| `vbs ide plugin` | Export extension assets for `vscode`, `zed` or `clion`; VS Code can be packaged as `.vsix`. |
`vbs ide generate --editor all|clangd|vscode|clion|zed` supports `--force`. Generated files are non-destructive by default: an existing editor file is skipped rather than overwritten. The project-root `compile_commands.json` alias is only managed when it is absent or already VBS-owned.
## Lifecycle
```sh
vbs init [--dir DIR] [--name NAME] [--library] [--with-toml] [--force]
vbs clean [--build-dir DIR] [--all]
vbs gc [--build-dir DIR] [--max-bytes N]
```
- `vbs init` scaffolds an executable or `--library` project, with a test target and optional TOML manifest. `--force` overwrites an existing `build.cpp`.
- `vbs clean` removes `build/profiles/` and the build-root compilation database, preserving `.vbs` cache and state. Workspace member outputs under `build/members/**` are not removed by this form.
- `vbs clean --all` removes the entire build root.
- `vbs gc` recovers interrupted state and removes unreferenced CAS blobs. `--max-bytes 0` (default) removes only unreferenced data. A positive value is a **quota check**, not an eviction policy: GC fails with `limit_exceeded` when pinned data exceeds it, because there is no LRU or size-based pruning in 1.0.0.
## Dependencies
```sh
vbs deps resolve [--offline]
vbs deps update [--offline]
vbs lock show
```
`resolve` preserves compatible pinned versions; `update` allows compatible SemVer upgrades. Both accept project/build/profile selection. A solve that conflicts with the current lock reports the context and declaration fingerprint; a concurrent update reports busy instead of overwriting. With `--offline`, `update` cannot upgrade registry packages because no live index is available.
## Installers and source archives
```sh
vbs install --prefix DIR [install flags]
vbs uninstall --prefix DIR
vbs pack [--output FILE]
```
Install flags:
- `--profile NAME`, `--compiler`, `--target-os`, `--target-arch`, `--jobs`.
- `--prefix DIR`: required destination.
- `--package-name NAME`, `--package-version VER` (default `0.1.0`).
- `--component NAME`: install one component only.
- `--bundle-dependencies`: copy installed targets' runtime shared libraries into `<prefix>/lib`.
- `--no-cmake-export`, `--no-native-export`: suppress the corresponding metadata.
- `--archive FILE`: write a deterministic installer archive.
- `--archive-format tar|sh|zip|deb|rpm|wix|dmg|nuget` (default `tar`).
- `--signing-key SEED`: sign the archive and write `.sha256`, `.sig`, `.pub` and `.msg`; requires `--archive`.
`vbs uninstall` removes only files listed in `<prefix>/.vbs-install-manifest.json` and preserves unrelated files. `vbs pack` writes a deterministic USTAR source archive (default `package.tar`) that can be consumed as an archive dependency.
## Registry and provenance
```sh
vbs publish --registry URL --name PKG --version X.Y.Z [--description TEXT]
[--private] [--signing-key FILE] [--token-env VAR]
vbs publish-binary --registry URL --name PKG --version X.Y.Z --variant ID --file ARTIFACT
[--signing-key FILE] [--token-env VAR]
vbs binaries list --registry URL --name PKG --version X.Y.Z
vbs binaries show --registry URL --name PKG --version X.Y.Z --variant ID
vbs binaries fetch --registry URL --name PKG --version X.Y.Z --variant ID --output FILE
[--trusted-public-key HEX]... [--trusted-key-file FILE]...
vbs releases list --registry URL --name PKG
vbs releases show --registry URL --name PKG --version X.Y.Z
vbs releases yank --registry URL --name PKG --version X.Y.Z [--unyank]
vbs tokens list --registry URL
vbs tokens revoke --registry URL --token-id ID
vbs verify --name PKG --version X.Y.Z --file ARTIFACT --signature HEX --public-key HEX
[--trusted-public-key HEX]... [--trusted-key-file FILE]...
```
`--registry` falls back to `VBS_REGISTRY_URL`; `--token-env` names the environment variable holding the bearer token (default `VBS_REGISTRY_TOKEN`). Plaintext tokens are never read back from the registry. `vbs verify` checks a detached Ed25519 signature over the canonical package message; with trusted keys it also rejects a signer that is not trusted.
## Editor plugin, migration and tests helper
```sh
vbs ide plugin --editor vscode|zed|clion --output DIR [--vsix FILE] [--force]
vbs migrate --input CMakeLists.txt --output build.cpp [--dry-run] [--force]
vbs gen-tests --input FILE --output-dir DIR
vbs bridge --request FILE --output FILE
```
- `vbs migrate` reads a bounded CMake subset (`project`, `set`, `add_library`/`add_executable`, `target_link_libraries`, `target_include_directories`, `target_compile_definitions`, `install(TARGETS)`) and reports everything it cannot translate. `--dry-run` prints without writing.
- `vbs gen-tests` emits a `Void::Testing` registration unit; it is useful for build descriptions that do not use `VOID_TEST`'s self-registration directly.
- `vbs bridge` is the backend for `cmake/bridge/VbsDeps.cmake`. It is not normally called by hand.
## Daemon
```sh
vbs daemon run --project DIR [--build-dir DIR] [--socket PATH] [--max-requests N]
vbs daemon status|stop|recover|gc
vbs daemon describe|build|test|graph|actions|target|workspace|deps|doctor|info
vbs daemon compdb export|use|entries|generations
vbs daemon ide query|generate|poll|wait|status|configs
vbs daemon clean|pack|install|uninstall|init|gen-tests
```
The socket defaults to `<build>/.vbs/vbs-daemon.sock`. The daemon is POSIX-only in 1.0.0 and is compiled out on Windows. See [Editors and the daemon](/build-system/consumer/daemon) for the request model and limits.
## Registry service
```sh
vbs-registry --data-dir DIR --web-root DIR \
[--bind 127.0.0.1] [--port 8080] [--admin-password-env VBS_REGISTRY_ADMIN_PASSWORD]
```
`--port 0` binds an ephemeral port. The default web root is `registry/web` beside the source checkout. The service is POSIX-only in 1.0.0.
## Environment variables
| Variable | Used by | Meaning |
| --- | --- | --- |
| `VBS_VOID_SOURCE_DIR` | dependency fetch | Development-only local checkout override for the **VoidLibrary** Git dependency |
| `VBS_REGISTRY_URL` | deps, publish, registry CLI | Default registry when `--registry` is omitted |
| `VBS_REGISTRY_TOKEN` | registry operations | Default bearer token environment variable |
| `VBS_TRUSTED_PUBLIC_KEYS` | build/test/daemon | Comma- or whitespace-separated trusted Ed25519 public keys |
| `VBS_REMOTE_CACHE` | build/test | Default shared action-cache URL |
| `VBS_REMOTE_CACHE_TOKEN` | build/test | Default remote-cache bearer token variable |
| `VBS_DEP_NAME` | native dependency description | Alias of the dependency being built |
| `VBS_DEP_OPTION_<NAME>` | native dependency description | Value of a `.native_builder({...})` option |
| `VBS_WORKSPACE_MEMBER_<name>` | member description | Canonical member directory provided by a workspace build |
| `VBS_BIN` | generated editor extension | Override the `vbs` executable used by tasks |
| `NO_COLOR` | all CLIs | Disable ANSI color, same as `--no-color` |
| `PKG_CONFIG_PATH`, `PKG_CONFIG_LIBDIR` | pkg-config provider | `.pc` search paths |
| `VBS_REGISTRY_ADMIN_PASSWORD` | `vbs-registry` | Bootstrap admin password variable (change with `--admin-password-env`) |
`VBS_*` variables are read at process start and are never persisted into `vbs.lock`, action records or logs. Network credentials are runtime-only.
## Exit codes
- `0`: success, including help and an empty `--changed-since` selection.
- `1`: build, test, resolution, provider, cache or I/O failure.
- `2`: invalid command-line usage, unknown subcommand, invalid option value or description context error.
When a build/test fails, the failing action's diagnostic and captured stderr are printed before the final summary.
+175
View File
@@ -0,0 +1,175 @@
---
title: Editors and the Build Daemon
description: Run the warm Unix-socket daemon, drive builds and IDE metadata over JSON lines, and understand its bounds
section: Editors & Daemon
badge: vbs daemon
order: 2
tags: [daemon, socket, protocol, ide, workspace, watch, json]
updated: 2026-12-06
---
# Editors and the Build Daemon
`vbs daemon` keeps a warm `StateStore` and a project file watcher in one long-lived process. Editors and automation send newline-delimited JSON requests over a Unix-domain socket instead of paying descriptor compilation, toolchain probing and dependency resolution on every action.
:::callout{type="warning" title="Daemon availability"}
The daemon transport is a POSIX Unix-domain socket. It is compiled out on Windows in 1.0.0. The registry service is also POSIX-only. Linux is the supported daemon host.
:::
## Start and stop
```sh
vbs daemon run --project . --build-dir build
vbs daemon status --project .
vbs daemon stop --project .
```
The socket defaults to `<build>/.vbs/vbs-daemon.sock`. The daemon:
- binds with mode `0600`, so only the owning user can connect;
- probes an existing socket and replaces it only when it is stale;
- removes only its own socket on shutdown, after checking device and inode;
- refuses a second live daemon for the same socket;
- accepts `--max-requests N` for bounded test runs (`0` = unlimited).
`vbs daemon info` returns version, host, roots, lockfile state, socket path and enabled backends. `vbs daemon doctor` returns structured host/tool diagnostics. `vbs daemon status` reports PID, uptime, recorded actions, watched directories, event sequence and pending changes.
## Protocol
One request object per line, one response object per line:
```sh
printf '%s\n' '{"op":"ping"}' | socat - UNIX-CONNECT:build/.vbs/vbs-daemon.sock
```
```json
{"ok":true,"op":"ping"}
```
- Requests are strict JSON objects with a string `op`.
- Maximum request size is 64 KiB; maximum JSON depth is 16.
- Malformed JSON, a non-object, a missing `op` or an invalid field type returns a JSON error object with `"ok": false`; the connection remains usable.
- Field validation is explicit and bounded. Unknown fields are ignored; invalid values are errors.
The daemon is single-threaded. `watch_wait` is a bounded long poll (0–5000 ms, default 2000), and other requests queue behind it. A request either completes or returns an explicit error; there is no request cancellation API in 1.0.0. Daemon builds also lower without an input snapshot in 1.0.0, so their action keys and cache records do not match `vbs build`; expect a warm daemon cache rather than CLI cache reuse.
## Request catalog
| Operation | Purpose | Key fields |
| --- | --- | --- |
| `ping` | Liveness | — |
| `status` | Warm-store and watcher status | — |
| `info` | Version, host, roots, backends, lockfile | — |
| `doctor` | Structured host/tool diagnostics | — |
| `describe` | Evaluate and summarize a graph | `profile`, `member` |
| `build` | Build a graph in-process | `profile`, `targets`, `jobs`, `member`, `compiler` |
| `test` | Build and run test targets | same as `build` |
| `deps` | Resolve/materialize dependencies | `profile`, `offline`, `update`, `member` |
| `graph` | Export target dependencies | `profile`, `format` (`dot`, `json`, `mermaid`), `member` |
| `actions` | List lowered actions | `profile`, `kind`, `limit`, `member` |
| `target_list` | Sorted target names/kinds | `profile`, `limit`, `member` |
| `target_info` | One target's kind, sources, outputs, runtime libraries | `name`, `profile`, `member` |
| `target_flags` | Per-unit arguments, defines and compile options | `name`, `file`, `profile`, `member` |
| `workspace_members` | Declared members without evaluation | — |
| `workspace_info` | Members plus root lockfile presence/size | — |
| `install` | Build and stage an install prefix | `profile`, `prefix`, `component`, export flags |
| `uninstall` | Remove manifest-owned files | `prefix` |
| `pack` | Deterministic source archive confined to the build root | `output` |
| `clean` | Remove profile outputs or the whole build root | `all` |
| `init` | Scaffold a project confined to the project root | `dir`, `name`, flags |
| `gen_tests` | Generate a native test registration unit | `input`, `output_dir` |
| `gc` | Recover interrupted state and collect CAS garbage | `max_bytes` |
| `recover` | Run interrupted-state recovery | — |
| `shutdown` | Stop the daemon | — |
Editor and compilation-database requests:
| Operation | Purpose |
| --- | --- |
| `ide_query` | Publish/select the profile database and return IDE workspace/target JSON |
| `ide_generate` | Write `.clangd`, `.vscode/`, `.zed/`, `.idea/` presets |
| `ide_configs` | Report which editor configuration files exist |
| `editor_status` | Active selection: ticket, profile, build root, generation, compdb path and entry count |
| `compdb_export` | Publish the profile database and return its path/entry count |
| `compdb_use` | Switch the active editor profile to a published database |
| `compdb_entries` | Bounded entries filtered by file suffix and limit |
| `compdb_generations` | Immutable generations for a profile with active selection and counts |
| `compdb_stale` | Mark a profile generation stale with a bounded reason |
| `watch_poll` | Drain buffered changes immediately; optional `prefix` filter |
| `watch_wait` | Bounded long poll for changes; optional `prefix` and `timeout_ms` |
### Watch protocol example
```json
{"op":"watch_wait","prefix":"src/","timeout_ms":2000}
```
```json
{"ok":true,"op":"watch_wait","sequence":42,"watch_events":7,
"changed":["src/main.cpp"],"timed_out":false}
```
`watch_poll` additionally reports `overflowed` and `rescan_required` when the watcher could not guarantee an exhaustive event list. Buffered paths are capped at 4096; a prefix filter returns matching paths and retains non-matching ones for a later request.
### Build request example
```json
{"op":"build","profile":"debug","targets":["app"],"jobs":8}
```
```json
{"ok":true,"op":"build","profile":"debug","targets":["app"],
"actions":12,"executed":0,"cached":12,"failed":0}
```
The response also carries a `diagnostic` on failure and a bounded `failed_actions` list. Dependency materialization happens inside the daemon for `build`, `test`, `deps` and `install`, using the same resolver as the CLI; the response reports the dependency context.
## Workspaces
- `describe` accepts an optional `member`. A workspace root without `member` returns a bounded per-member summary; an unknown member is rejected.
- `build` with no member builds every member in declared order against the shared root lock and CAS and returns per-member outcomes plus aggregate `executed`/`cached`/`failed`.
- `test` does the same for declared test targets.
- `ide_query`, `ide_generate` and `compdb_export` require `member` for a workspace root and reject it for a plain project.
- `workspace_members` lists members without evaluating them; `workspace_info` adds root lockfile metadata.
## Bounds and limitations
| Limit | Value |
| --- | --- |
| Request size | 64 KiB |
| JSON depth | 16 |
| Describe target names | 128 entries × 200 bytes |
| Describe/evaluate timeout | 10 s |
| Build target list | 64 targets |
| Compilation-database entries | 500 |
| Compilation-database generations | 128 |
| Install file list | 128 paths × 512 bytes |
| Actions list | 1000 |
| Pending watch paths | 4096 |
| Long-poll timeout | 5000 ms |
| Registry/editor build requests | One at a time (single-threaded) |
The daemon is not a sandbox. It evaluates trusted `build.cpp` code with the user's privileges, like the CLI. It does not add authentication on top of filesystem permissions; protect the build root and socket like any other user-owned development artifact.
Additional 1.0.0 limits:
- Daemon `build`/`deps` materialize dependencies but do not publish updated `vbs.lock` contexts; run the CLI for lock updates.
- Metadata-only requests (`describe`, `actions`, `target_info`, `target_flags`, `ide_query`, `ide_generate`) lower without provider imports, so a project that links imported dependency targets can fail with an unresolved-target error. Use `vbs build` or the CLI IDE commands to populate provider metadata first.
- Daemon `test` is a reduced runner: no labels, resources, fixtures, Wine, JUnit, coverage or CDash, and no per-case reporting.
- Daemon `clean --all` removes the live build root while the daemon keeps running; later requests can fail until it is restarted.
- `compdb_export`, `compdb_entries`, `compdb_use`, `editor_status` and `ide_configs` are root-scoped and are not member-aware.
## When to use the daemon
:::cards
@@card[Long editor sessions|badge=IDE]
Keep descriptor, toolchain and compdb work warm while the editor polls for changes.
@@card[Repeated builds|badge=build]
Reuse the warm state store and watcher across actions instead of restarting `vbs`.
@@card[Remote workers|href=/build-system/consumer/remote-ci|badge=CI]
The registry worker protocol and remote cache cover distributed execution; the daemon is local.
@@card[Scripting|badge=JSON]
Any language that can open a Unix socket can query targets, flags, entries and graphs.
:::
Next: [run tests and reports](/build-system/consumer/testing) or [use a remote cache](/build-system/consumer/remote-ci).
+219
View File
@@ -0,0 +1,219 @@
---
title: Dependencies, Locking and Providers
description: Declare Git, path, archive, registry, Conan and pkg-config dependencies, lock them, build foreign projects natively, and enforce signatures
section: Dependencies & Packages
badge: solver + lock
order: 1
tags: [dependencies, toml, semver, lockfile, registry, cmake, meson, conan, pkg-config, signing]
updated: 2026-12-06
---
# Dependencies, Locking and Providers
Dependencies can be declared in C++ or in TOML. Both normalize to one `DependencyRecord` model, solve together, and are pinned in the same `vbs.lock`.
## Declare a dependency in C++
```cpp
void build(Void::Build::Project &project) {
auto lib = project.dependency("fmt");
lib.package("fmt", "^11.0")
.registry("https://packages.example.com")
.feature("header-only");
app.link(lib.target("fmt::fmt"));
auto tool = project.dependency("codegen");
tool.git("https://git.faumaray.com/Void/Codegen.git",
Void::Build::Commit{"0123456789abcdef0123456789abcdef01234567"})
.native_builder({})
.build_dependency();
}
```
| Declaration | Meaning |
| --- | --- |
| `.git(url, Commit{sha40})` | Exact 40-hex commit; the checkout is never modified. |
| `.path(local_path)` | Local source tree; content is snapshotted for identity. |
| `.archive(url, sha256)` | Remote or local archive verified before extraction. |
| `.package(id, range)` | Registry release resolved by the SemVer solver. |
| `.conan(reference, options)` | Conan 2 provider; fails explicitly when `conan` is unavailable. |
| `.pkgconfig(spec)` | System library resolved from `.pc` files, never fetched. |
| `.cmake(options)` / `.meson(options)` / `.native_builder(options)` | Select the provider for a source dependency. |
| `.registry(authority_url)` | Registry authority for a package dependency. |
| `.feature(name)` | Requested package feature; recorded in constraints and the lock (not yet used for acquisition in 1.0.0). |
| `.build_dependency(bool)` | Marks the dependency as a build-machine/host tool. |
| `.target(exported_name)` | Handle used in `.link(...)`. |
A dependency has exactly one source. Declaring a second source, an unknown builder, or a contradictory builder on a registry package is rejected at declaration time or during manifest loading.
### Native builder options
When a dependency is built with `.native_builder({...})`, VBS runs the dependency's own `build.cpp` and passes each option as `VBS_DEP_OPTION_<NAME>` (uppercase). The dependency reads them with:
```cpp
const std::string modules = Void::Build::dependency_option("VOID_ENABLED_MODULES");
```
`VBS_DEP_NAME` is also set. Plain option names such as `VOID_ENABLED_MODULES` are exported for upstream projects whose CMake or build descriptions read them directly, so a dependency can support both worlds without special cases.
## Declare dependencies in TOML
```toml
[dependencies.VoidLibrary]
git = "https://git.faumaray.com/Void/VoidLibrary.git"
rev = "de1fdcda72ddd6ac069fba433b13f643327efa3f"
builder = "native"
[dependencies.VoidLibrary.options]
VOID_ENABLED_MODULES = "Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing;Log"
VOID_ENABLE_TESTING = false
[dependencies.fmt]
package = "fmt"
version = "^11.0"
registry = "https://packages.example.com"
features = ["header-only"]
[build_dependencies.codegen]
path = "tools/codegen"
builder = "native"
```
Supported top-level tables are `dependencies` and `build_dependencies`; `registries` is accepted as a reserved placeholder but is not read in 1.0.0. Each alias is a table. Allowed fields are:
`git`, `rev`, `path`, `archive`, `sha256`, `package`, `version`, `conan`, `builder`, `options`, `registry`, `features`, `build_dependency`.
Rules enforced by the loader:
- Exactly one of `git`, `package`, `path`, `archive`, `conan` must be present.
- `git` requires an exact 40-hex `rev`; `archive` requires a 64-hex `sha256`; `package` requires `version`.
- `builder` must be `cmake`, `meson`, `conan` or `native`. A registry package may only use `native` as an explicit builder.
- Option values may be strings, booleans or signed integers. Arrays, floats and nested tables are rejected.
- Unknown top-level keys, unknown dependency fields and duplicate keys fail with `file:line:column` origins.
- When a C++ and a TOML declaration share an alias, they must describe the same dependency; otherwise the error names both origins (`build.cpp` and `vbs.deps.toml`).
Reference the manifest from the description:
```cpp
project.dependencies_file("vbs.deps.toml");
```
Multiple manifest files may be declared and are merged. The manifest path is a configuration input, not a build output.
## Resolution and `vbs.lock`
Registry package constraints across the transitive graph are solved together with a deterministic backtracking solver (described as PubGrub-style in the codebase, but without clause learning in 1.0.0). Registry authority is part of the package identity, so the same name in two registries never silently substitutes.
The lockfile is JSON (`schema_version: 1`) and contains:
- `revision_hash`: a SHA-256 over the canonical context payload;
- one context per `profile:compiler:os:architecture:role`, with `declaration_fingerprint`;
- one entry per dependency: source kind, package identity, exact version, digest, builder, features and optional signature metadata.
```sh
vbs deps resolve # preserve compatible pinned versions
vbs deps update # allow compatible upgrades
vbs build --locked # fail instead of creating or changing vbs.lock
vbs lock show # print contexts and entries
```
Behavior worth knowing:
- The first ordinary build may create a missing lock. `--locked` forbids that.
- A declaration change makes the existing context invalid. A normal build republishes the context after re-solving; `--locked` fails with the fingerprint mismatch.
- Lock updates are compare-and-swap under a short project mutex. A competing update is reported as busy rather than overwriting another profile's context.
- A build pins one immutable lock revision at its start, so a concurrent `deps update` cannot mix revisions inside a run.
- `--offline` forbids network access and uses only cached, verified data.
:::callout{type="warning" title="Lockfiles never contain credentials"}
Bearer tokens, passwords and registry secrets are runtime-only. They are not written to `vbs.lock`, action records, logs or package metadata.
:::
## Where sources are cached
All dependency state lives under the build root's `.vbs`:
```text
build/.vbs/cache/
├── archives/<sha256>/ # verified extracted archives
├── binaries/<sha256> # verified prebuilt binary artifacts
├── downloads/<sha256>.tar # downloaded archives
├── git/<alias>_<rev>/ # exact Git checkouts
├── locks/ # per-digest fetch locks
├── packages/<sha256>/src/ # extracted registry source packages
└── path-snapshots/ # content identity for local paths
```
Fetches are bounded, verified before publication, and serialized per digest. An interrupted download or extraction remains uncommitted. Local path dependencies are hashed through a snapshot and are never written to.
`VBS_VOID_SOURCE_DIR` is a development-only override for the dependency named **VoidLibrary** when its source is Git; it substitutes an existing checkout without changing the lock or the checkout.
## Providers
A source dependency is built by one provider:
| Builder | Mechanism |
| --- | --- |
| `native` | Compiles the dependency's own `build.cpp` with VBS, including the built-in VoidLibrary recipe. No CMake. |
| `cmake` | Configures CMake and reads the File API `codemodel-v2` reply; builds through VBS actions when translation is requested, otherwise runs the foreign build. |
| `meson` | Runs `meson setup` only, reads `meson-info` introspection, and translates the graph. Never runs `meson compile` on the native path. |
| `conan` | Adapter checks for and runs `conan install`; the current source-materialization path does not yet consume a standalone `.conan(...)` dependency in `vbs build` (it fails explicitly). |
| `pkg-config` | Parses `.pc` files directly; no `pkg-config` executable required. |
If a registry package has no explicit builder, VBS inspects the extracted source: `build.cpp` selects native, `CMakeLists.txt` selects CMake, and `meson.build` selects Meson.
### Bounded native translation
`vbs build --native-foreign` asks the provider to translate supported CMake or Meson targets into VBS actions. The policy is explicit:
- **Completeness is audited first.** CMake File API targets, compile groups, artifacts and dependencies are checked; Meson `intro-targets.json` is checked against the graph.
- **Only bounded constructs are translated.** C and C++ compile/link groups, mixed C/C++ targets, hermetic custom commands and generated sources are supported.
- **Unsafe or unbounded constructs fall back or fail.** Console pools, `.util`-only side effects, out-of-tree writes, in-tree codegen tools, `run` targets, PCH and non-C/C++ languages are diagnosed rather than guessed. The default policy is `FallbackToForeignBuild`; a hard requirement can be selected in the API.
Native translation uses the same toolchain driver, snapshots, depfiles and CAS as ordinary VBS targets. It is not a wrapper around `cmake --build`.
### pkg-config
```cpp
auto zlib = project.dependency("zlib");
zlib.pkgconfig("zlib >= 1.2");
app.link(zlib.target("zlib"));
```
`.pc` files are searched through `PKG_CONFIG_PATH` and `PKG_CONFIG_LIBDIR`, plus conventional prefixes. Variables such as `${prefix}` and `${pcfiledir}` expand (including nested references), `Requires` chains merge their flags, and RPM-style version comparison enforces the constraint at every level. `Cflags` become include directories, defines and compile options; `Libs` become link options or library paths. The dependency is recorded as `pkgconfig` in `vbs.lock` and is never fetched.
## Signing and trusted keys
Registry releases can carry an Ed25519 detached signature over:
```text
vbs-package-v1
<name>@<version>
sha256:<archive-digest>
```
Publishing with `vbs publish --signing-key SEED` signs the canonical message. When trusted keys are configured, every registry package must verify before extraction:
```sh
vbs build --trusted-public-key HEX
vbs build --trusted-key-file keys.txt
VBS_TRUSTED_PUBLIC_KEYS=HEX1,HEX2 vbs build
```
Keys are also read from a project `vbs.keys` file (one key per line, `#` comments). They must be 64 hex characters and are normalized to lowercase. With no trusted keys, unsigned releases keep the legacy behavior; with keys configured, unsigned, untrusted and invalid releases fail closed. Signature enforcement is wired into `vbs build`/`vbs test` and the daemon; `vbs deps resolve|update` do not accept trusted keys yet.
Prebuilt binary variants use the same primitives with the canonical message:
```text
vbs-binary-v1
<variant-id>
sha256:<artifact-digest>
```
`vbs binaries fetch` verifies the selected variant's signature when trusted keys are supplied. Normal dependency resolution still builds from source packages in 1.0.0; binary variants are published, listed, fetched and verified explicitly.
## Next steps
- [Use workspaces for multi-package repositories](/build-system/consumer/workspaces)
- [Read the package and provider internals](/build-system/developer/packages-and-providers)
- [Publish releases and binaries](/build-system/consumer/shipping)
+148
View File
@@ -0,0 +1,148 @@
---
title: Editors, Compilation Databases and Presets
description: Publish compile_commands.json per profile, generate editor configs, consume the CMake File API shim, and import CMake presets
section: Editors & Daemon
badge: IDE
order: 1
tags: [compile_commands, clangd, vscode, zed, clion, cmake-file-api, presets, ide]
updated: 2026-12-06
---
# Editors, Compilation Databases and Presets
VBS never approximates commands from filenames or flags. The compilation database is projected from the same configured graph that execution uses, with physical paths rewritten to editable logical sources and immutable generated views. The description files themselves (`build.cpp`, `build.profiles.cpp`, `build-support/`) also appear as entries so `clangd` can complete and navigate the build description.
## Compilation database model
```text
project/
├── compile_commands.json # managed alias, only if absent or VBS-owned
├── .vbs/editor_selection.json # authoritative selection: ticket, profile, generation
└── build/
├── compile_commands.json # active build-root alias (symlink/pointer)
└── profiles/debug/
├── compile_commands.json # the profile's selected database
└── editor/
├── status.json # generation status, diagnostic, entry count
└── generations/<id>/compile_commands.json
```
- A single-profile build publishes its generation and updates selection unless `--editor-profile` redirects it. A multi-profile build requires `--editor-profile` to choose which selected profile may publish.
- Generation publication is atomic. Late completions compare a monotonic ticket and cannot overwrite a newer selection.
- A failed configuration marks the profile stale or invalid. The last valid database stays identifiable instead of being replaced with fabricated commands.
- A watcher refresh updates the already-selected profile but never steals selection.
- An unrelated user-owned project-root `compile_commands.json` is preserved, never overwritten.
```sh
vbs compdb export --profile debug
vbs compdb use release
vbs compdb show
vbs compdb watch --profile debug
```
`vbs compdb export` evaluates the description, probes the toolchain, publishes the database and exits without compiling project targets. It does **not** select the profile on a fresh tree; run `vbs compdb use PROFILE` or a build to make it active. `vbs compdb watch` is metadata-only: it may rebuild local descriptions and run known native probes/scanners, but it never fetches packages, updates the lock, configures CMake/Meson or runs generators.
`vbs ide generate` and `vbs ide query` publish the profile database but select it only when no editor selection exists. If a different profile is already selected, their `.clangd` and editor settings point at that selected database; use `vbs compdb use <profile>` to switch.
## Editor configuration
```sh
vbs ide generate --editor all
vbs ide generate --editor vscode
vbs ide generate --editor vscode --force
```
| Editor | Files written |
| --- | --- |
| clangd | `.clangd` with GCC-16 flag sanitization and a compilation-database path |
| VS Code / Cursor | `.vscode/tasks.json`, `.vscode/launch.json`, `.vscode/settings.json` |
| Zed | `.zed/tasks.json`, `.zed/debug.json` |
| CLion | `.idea/customTargets.xml` |
The generated VS Code and Zed task sets include build, test, clean, install and package-installer entries. Launch/debug configurations are per runnable target. Existing files are skipped unless `--force` is given.
`vbs ide query` emits versioned JSON consumed by editor extensions:
```json
{
"schema_version": 1,
"project_root": "/path/to/project",
"build_root": "/path/to/project/build",
"profile": "debug",
"profile_identity": "…",
"compiler_family": "gcc",
"c_compiler": "/path/to/gcc",
"cxx_compiler": "/path/to/g++",
"sdk_include_dir": "/path/to/vbs/include",
"compdb_path": "/path/to/project/build/compile_commands.json",
"targets": [
{
"name": "app",
"kind": "executable",
"enabled": true,
"is_executable": true,
"is_test": false,
"sources": ["src/main.cpp"],
"primary_outputs": ["/path/to/project/build/profiles/debug/out/bin/app"],
"runtime_shared_libraries": []
}
]
}
```
`vbs compdb-entries --file src/main.cpp --limit 20` returns bounded entries from the active database for plugins that do not want to parse the whole file. Limits and argument lengths are capped.
## CMake File API shim
`vbs ide generate` regenerates a CMake File API reply tree:
```text
build/.cmake/api/v1/reply/
├── index-<hash>.json
├── codemodel-v2-<hash>.json
├── cmakeFiles-v1-<hash>.json
├── toolchains-v1-<hash>.json
├── cache-v2-<hash>.json
├── directory-<hash>.json
└── target-<hash>.json
```
The codemodel includes target type, artifacts, `nameOnDisk`, sources and compile groups (language, command fragments, defines, includes). The full reply set lets CMake-aware IDEs such as CLion and VS Code CMake Tools read a VBS project without CMake being installed.
## Import CMake presets
```sh
vbs presets
vbs presets --name linux-debug
```
`vbs presets` reads `CMakePresets.json` (or `--file`), resolves `inherits` as a string or array with cycle detection, expands `${sourceDir}`, merges `cacheVariables`, and maps:
- `CMAKE_BUILD_TYPE` → profile;
- `CMAKE_CXX_COMPILER` → compiler override.
It lists the mapping or prints the equivalent `vbs build` command. It does not write a description file. For a generated scaffold, use `vbs migrate`.
## Editor extensions
```sh
vbs ide plugin --editor vscode --output build/plugin
vbs ide plugin --editor vscode --output build/plugin --vsix build/vbs.vsix
vbs ide plugin --editor zed --output build/zed-plugin
vbs ide plugin --editor clion --output build/clion-plugin
```
- **VS Code** assets include `package.json` with six commands, `extension.js`, a README, and a mock-tested `test/extension.test.js`. `--vsix` packages a real installable extension (ZIP with `extension.vsixmanifest` and `[Content_Types].xml`).
- **Zed** assets include `extension.toml`, `tasks.json` and a README.
- **CLion** assets include `plugin.xml` with Tools-menu actions, a Kotlin action source, `build.gradle.kts` and a README.
The generated extension runs `vbs` from `PATH`; set `VBS_BIN` when the binary is elsewhere. Published plugin repositories live at [VbsVsCode](https://git.faumaray.com/Void/VbsVsCode), [VbsZed](https://git.faumaray.com/Void/VbsZed) and [VbsCLion](https://git.faumaray.com/Void/VbsCLion).
:::callout{type="info" title="Daemon-backed editors"}
Editor extensions can avoid spawning a fresh `vbs` process per action by talking to the daemon. `vbs daemon ide query|generate|poll|wait|status|configs`, `vbs daemon compdb export|use|entries|generations` and `vbs daemon target info|flags` expose the same metadata over a local socket. See [Editors and the daemon](/build-system/consumer/daemon).
:::
## Next steps
- [Use the daemon protocol](/build-system/consumer/daemon)
- [Understand editor generations internally](/build-system/developer/configuration-and-graph)
@@ -0,0 +1,143 @@
---
title: Getting Started with VoidBuildSystem
description: Requirements, bootstrap, first vbs project, build and test workflow, output layout, and the concepts behind the tool
section: Getting Started
badge: v1.0.0
order: 1
tags: [quickstart, bootstrap, cmake, vbs, gcc16, build]
updated: 2026-12-06
---
# Getting Started with VoidBuildSystem
**VoidBuildSystem** (`vbs`) is a native C++26 build system and package manager for Void projects. A project is described in ordinary C++ — `build.cpp`, optional `build.profiles.cpp`, helpers under `build-support/`, and a `workspace.cpp` for multi-package roots — rather than in a separate build language. `vbs` compiles that description on the host, evaluates it once per profile, lowers a validated action graph, and executes it directly without generating Ninja, Make, or Visual Studio files.
The same binary also resolves dependencies, maintains `vbs.lock`, writes compilation databases, runs tests, installs and packages products, publishes to a package registry, and can serve editor and build requests from a daemon. Version 1.0.0 is the first release built and packaged by `vbs` itself.
:::callout{type="info" title="What 1.0.0 covers"}
- **Descriptions**: C++26 `build.cpp` with profiles, targets, usage requirements, modules, shaders and install rules.
- **Execution**: hermetic snapshots, direct action execution, local CAS and action cache, remote action cache.
- **Packages**: SemVer solver, context-aware lockfile, Git/path/archive/registry sources, native/CMake/Meson/Conan/pkg-config providers.
- **Ecosystem**: compile databases, `vbs ide`, daemon, test runner, registry service, `vbs worker`, installers and provenance.
- **Platforms**: Linux is the primary host; Windows targets are built with MinGW-w64 and tested under Wine. macOS is not supported.
:::
## Requirements
| Requirement | Why |
| --- | --- |
| GCC 16+ with `-freflection` | The bootstrap and VoidLibrary use C++26 reflection and contracts |
| CMake 4.0+ and Ninja | Only for bootstrapping `vbs`; user projects do not need CMake |
| Git | Fetching the pinned VoidLibrary during bootstrap and exact Git dependencies |
| C and C++ toolchain for targets | GCC or Clang are discovered and capability-probed at build time |
The Void development environment provides everything through `dev cpp-gcc` (GCC 16.2, CMake 4.4, Ninja 1.13, Meson 1.12). On another host, make sure `g++`, `cmake`, `ninja` and `git` are on `PATH`. Clang 23 is supported as a target compiler when `--compiler clang` is selected and `clang-scan-deps` is available for modules.
:::callout{type="warning" title="Bootstrap compiler is not the target compiler"}
The CMake bootstrap must use GCC 16 with reflection because the description SDK and VoidLibrary are compiled on the host. `vbs build --compiler clang` selects the compiler for the project's targets; it does not change the host compiler used to build `vbs`.
:::
## Bootstrap the tool
```sh
dev cpp-gcc -c cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
dev cpp-gcc -c cmake --build build --parallel 4
dev cpp-gcc -c ctest --test-dir build --output-on-failure
```
The executable is `build/bin/vbs`. The bootstrap also builds `vbs-registry`, `vbs_describe`, `vbs_benchmarks`, and the test binaries. Expect eight CTest entries: five `VOID_TEST` executables plus SDK registration, CLI and description contract checks.
If CMake is available directly in your shell, drop the `dev cpp-gcc -c` prefix.
### Self-host with `vbs`
Once the bootstrap binary exists, the project's own [`build.cpp`](https://git.faumaray.com/Void/Build-System/src/branch/main/build.cpp) builds VoidLibrary through the native provider and declares every VBS target, with no CMake invocation:
```sh
build/bin/vbs test --build-dir build/vbs-stage2 --profile release --jobs 8
build/vbs-stage2/profiles/release/out/bin/vbs --version
```
For local VoidLibrary development, `VBS_VOID_SOURCE_DIR=/path/to/VoidLibrary` substitutes an existing checkout for the **VoidLibrary** Git dependency only. It never writes to that checkout, and it is a development override rather than a replacement for the pinned revision.
## Create and run a project
```sh
build/bin/vbs init --dir hello --name hello
cd hello
../build/bin/vbs build
./build/profiles/debug/out/bin/hello
../build/bin/vbs test
```
`vbs init` writes a ready-to-build project: `build.cpp`, a public header, a library source, an application source, a test source, `.gitignore`, and optionally `vbs.deps.toml`. The generated project uses `CxxStandard::Cxx26`, a static library, an executable, and a `project.test(...)` target.
A first build logs each phase (`Config`, `Toolchain`, `Eval`, `Snapshot`, `Graph`, `Build`) and then each action. A second build with unchanged inputs reports `0 executed, N cached` and finishes in milliseconds. `vbs test` builds the graph and runs every enabled test target, printing `PASSED` or `FAILED` for each.
:::tabs
@@tab[Use a local `vbs`]
```sh
vbs build
vbs test
```
@@tab[Use the bootstrap binary]
```sh
../build/bin/vbs build
../build/bin/vbs test
```
@@tab[Pick a profile and target]
```sh
vbs build --profile release --target hello
vbs test --profile release --target hello_tests
```
:::
## What the build produces
The build directory defaults to `<project>/build`. Each profile is isolated:
```text
build/
├── .vbs/ # state, CAS, descriptor cache, probes, snapshots
├── compile_commands.json # active editor compilation database
└── profiles/
└── debug/
├── compile_commands.json
├── editor/ # immutable editor generations and status
├── gen/ # generated headers and code
├── obj/ # object files, BMIs, PCHs, per target
├── rsp/ # response files when needed
└── out/
├── libhello_lib.a
└── bin/
├── hello
└── hello_tests
```
Windows targets use PE names: executables get `.exe`, shared libraries get `.dll`, and archives keep the `.a` convention. A shared library on Linux is written as `out/lib<name>.so`.
`build/.vbs` is the local content-addressed state: compiled descriptor executables, toolchain probes, immutable input snapshots, the action database (SQLite when available, durable JSON otherwise), and CAS blobs. `vbs clean` removes profile outputs while preserving that cache; `vbs clean --all` removes the entire build root.
## Core concepts
:::cards
@@card[Build description|href=/build-system/consumer/build-descriptions|badge=model]
Targets, profiles and usage requirements are compiled C++26, evaluated out-of-process per profile.
@@card[Dependencies|href=/build-system/consumer/dependencies|badge=packages]
Declare sources in C++ or TOML; resolve, lock, fetch and import them as typed targets.
@@card[Command reference|href=/build-system/consumer/command-reference|badge=CLI]
Every command, flag, environment variable and build-tree convention in one place.
@@card[Editors|href=/build-system/consumer/editors|badge=IDE]
A real compilation database, editor presets, a CMake File API shim and a daemon protocol.
:::
## When something fails
- **`vbs doctor`** reports host compilers, optional tools, and which VBS backends were compiled in. Its exit code is non-zero when a required tool is missing.
- **Description errors** are reported with the failing `build.cpp` context; no project package is resolved while compiling the description.
- **Lock errors** say which context and declaration fingerprint changed. Use `vbs deps resolve` after intentional declaration changes, or `vbs build --locked` in CI to forbid silent updates.
- **Cache problems** are conservative: corrupted blobs and interrupted staging are recovered by `vbs gc`, and a missing or invalid cache entry causes a rebuild rather than stale output.
Next: [declare targets and profiles](/build-system/consumer/build-descriptions), then [add dependencies](/build-system/consumer/dependencies).
@@ -0,0 +1,153 @@
---
title: Run a Package Registry
description: Start vbs-registry, bootstrap an administrator, create tokens, publish releases, and operate storage safely
section: Shipping & Publishing
badge: vbs-registry
order: 2
tags: [registry, server, rbac, tokens, csrf, web-ui, storage, backup]
updated: 2026-12-06
---
# Run a Package Registry
`vbs-registry` is the reference package registry and shared cache. It serves immutable source releases, binary variants, metadata, owner/token administration, an audit log, a web UI and the remote-cache/worker endpoints.
:::callout{type="warning" title="Scope in 1.0.0"}
- POSIX only; the registry is not built on Windows.
- HTTP/1.1 with one request per connection and serialized API handling.
- No built-in TLS. Run it behind a TLS-terminating reverse proxy for anything other than loopback.
- Sessions, workers, leases and the action queue are in memory and are lost on restart. Packages, blobs, users, tokens and audit entries persist.
:::
## Start the service
```sh
export VBS_REGISTRY_ADMIN_PASSWORD='a long bootstrap password'
vbs-registry \
--data-dir /var/lib/vbs-registry \
--web-root ./registry/web \
--bind 127.0.0.1 \
--port 8080
```
| Flag | Default | Meaning |
| --- | --- | --- |
| `--data-dir` | `registry-data` | Metadata and CAS root |
| `--web-root` | `<source>/registry/web` | Static admin UI; point it at the packaged assets in a deployment |
| `--bind` | `127.0.0.1` | IPv4 bind address |
| `--port` | `8080` | `0` selects an ephemeral port |
| `--admin-password-env` | `VBS_REGISTRY_ADMIN_PASSWORD` | Environment variable holding the bootstrap password |
The administrator is created from `bootstrap_admin_user = "admin"` plus that password **only when the database has no metadata yet**. The environment password is ignored for an existing database; there is no password-reset CLI. If you start an empty registry without the environment variable, it has no users and no way to log in.
Storage defaults, configurable only through the C++ `RegistryConfig` API in 1.0.0:
| Setting | Default |
| --- | --- |
| Maximum request/upload body | 32 MiB |
| Maximum reported package storage | 2 GiB |
| Bootstrap admin user | `admin` |
| Audit cap | 2000 entries (oldest 500 trimmed) |
## Data directory
```text
registry-data/
├── metadata.v1.json # users, tokens, packages, releases, audit
├── registry.lock # per-save advisory lock
├── cas/blobs/<2>/<sha256> # package and binary blobs (0444)
└── action-cache/
├── blobs/<2>/<sha256> # remote-cache output blobs
└── actions/<2>/<sha256>.json # remote-cache action records
```
Metadata is rewritten synchronously on every mutation. Blobs are published before the metadata commit that references them, so a crash cannot advertise a missing artifact. Interrupted staging files are conservative: they are simply not referenced.
## Authentication and authorization
There are three roles: `reader`, `publisher` and `admin`.
- **Sessions**: `POST /api/v1/auth/login` sets an HttpOnly `SameSite=Strict` session cookie and returns a CSRF token. Sessions last 24 hours and are not persisted. Mutating cookie requests must send `X-CSRF-Token`; bearer requests are exempt from CSRF.
- **Tokens**: `POST /api/v1/tokens` returns `vbs_tok_…` exactly once. Only its SHA-256 is stored. A token can be listed and revoked, never re-read.
- **Scopes**: `read`, `publish` and `admin` are consulted. Publishing to an existing package requires ownership unless you are an admin. A new publisher becomes the package owner.
- **Private packages**: hidden from anonymous listing and access, but any authenticated principal with `read` can read them. This is team-level visibility, not a per-user ACL.
```sh
curl -sS -X POST http://127.0.0.1:8080/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"…"}'
```
The response includes `csrf_token`; send it as `X-CSRF-Token` on cookie-authenticated mutations. For automation, create a token and use `Authorization: Bearer vbs_tok_…`, which avoids CSRF and session lifetime concerns.
## Web administration
Open `http://127.0.0.1:8080/` and sign in. The UI supports:
- package search and detail, release download and yank;
- source release upload;
- token creation, listing and revocation;
- storage usage, user creation and the audit log.
It does **not** expose binary-variant browsing/publishing, owner management, metadata editing or upload progress in 1.0.0. Those operations are available through the HTTP API and `vbs` commands.
## Publish from the CLI
```sh
export VBS_REGISTRY_URL=http://127.0.0.1:8080
export VBS_REGISTRY_TOKEN=vbs_tok_...
vbs publish --name my-lib --version 1.2.3 --description "A small library"
vbs releases list --name my-lib
vbs releases show --name my-lib --version 1.2.3
```
`vbs publish` uploads a deterministic source archive. The registry validates safe extraction, enforces immutability, and stores the blob before committing metadata. Publishing identical bytes again is idempotent; different bytes for the same version is `409`.
Binary variants:
```sh
vbs publish-binary --name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release \
--file dist/libmy_lib.a
vbs binaries list --name my-lib --version 1.2.3
vbs binaries fetch --name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release --output libmy_lib.a
```
## Metadata, owners and audit
| Operation | Route | Authority |
| --- | --- | --- |
| Update description/private | `PATCH /api/v1/packages/<name>` | Publish authority + CSRF |
| List owners | `GET /api/v1/packages/<name>/owners` | Read access |
| Add owner | `PUT /api/v1/packages/<name>/owners/<user>` | Publish authority + CSRF |
| Remove owner | `DELETE /api/v1/packages/<name>/owners/<user>` | Publish authority + CSRF; last owner is rejected |
| Users | `GET/POST /api/v1/users` | Admin |
| Audit | `GET /api/v1/audit?actor=&action=&outcome=&limit=&offset=` | Admin |
| Stats | `GET /api/v1/stats` | Admin |
| Storage | `GET /api/v1/admin/storage` | Admin |
An empty registry can be bootstrapped with an admin token, but there is no CLI for user management in 1.0.0; use the API or web UI.
## Backup and recovery
The service exposes `backup_to(dir)` and `restore_from(dir)` in the C++ `RegistryService` API, but no CLI or HTTP route in 1.0.0. Those helpers copy metadata and source-release blobs only; binary blobs and the action cache are not included.
For a complete backup:
1. Stop the writer so no metadata or blob publication is in flight.
2. Copy the entire `--data-dir` tree, preserving ownership and permissions.
3. Restart the service and verify metadata, a release download, a binary download and a CAS action.
Restoring metadata without its blobs produces explicit `500 integrity_error` responses rather than silent partial downloads, but the data is still lost. Copying the whole data directory is the only complete backup path in 1.0.0.
## Operational limits
- One request per connection; API calls serialize on the registry mutex. A slow download does not block package mutations, but a slow publish does hold the upload path.
- Header limit 64 KiB, body limit 32 MiB, 10 s socket timeouts.
- `Range` supports a single range. `HEAD` is routed as `GET` with the body suppressed and `Content-Length` preserved.
- Strong `ETag` and `If-None-Match` (including weak prefixes, lists and `*`) are supported for metadata and downloads.
- Rate limiting, login throttling, token expiry through the HTTP API, user deactivation and TLS are not built in.
Next: [connect a remote cache and workers](/build-system/consumer/remote-ci) or [read the registry API internals](/build-system/developer/registry-internals).
+160
View File
@@ -0,0 +1,160 @@
---
title: Remote Cache and Distributed Workers
description: Share cached actions through the registry CAS, drain the action queue with vbs worker, and understand the trust boundaries
section: Remote & CI
badge: remote
order: 1
tags: [remote-cache, cas, workers, queue, leases, ci, distributed]
updated: 2026-12-06
---
# Remote Cache and Distributed Workers
A `vbs-registry` instance can act as a shared HTTP action cache and as a broker for remote execution. Both use the same bearer-authenticated transport and the same content-addressed storage as packages.
:::callout{type="warning" title="Trust boundary"}
Remote cache records and remote action specs are trusted input. A worker executes a `command` from a registry-provided action record with its own privileges and inherited environment. Do not point a worker at an untrusted registry; the protocol is not a sandbox.
:::
## Shared action cache
```sh
vbs build --remote-cache https://cache.example.com
vbs build --remote-cache https://cache.example.com \
--remote-cache-token-env MY_CACHE_TOKEN
```
Environment form:
```sh
export VBS_REMOTE_CACHE=https://cache.example.com
export VBS_REMOTE_CACHE_TOKEN=...
vbs build
```
### What happens
1. The local cache is checked first.
2. On a local miss, VBS asks `GET /api/v1/cas/actions/<action-key>`.
3. A hit must match the declared output count, have every output blob available and verified, and pass discovered-input/lookup-guard checks.
4. Missing blobs are fetched with `GET /api/v1/cas/blobs/<sha256>` and re-hashed before use.
5. After a local success, blobs are uploaded first, then the action record (`PUT /api/v1/cas/blobs/...`, `PUT /api/v1/cas/actions/...`). Upload is best-effort; a cache outage does not fail a successful local build.
Action keys are normalized to be build-directory independent: `${SNAPSHOT}`, `${PROFILE}`, `${BUILD}` and `${PROJECT}` replace absolute prefixes. The key still includes profile identity, toolchain identity, action id/kind, argv, response-file content, environment, declared input digests and the nondeterministic flag. Cross-toolchain reuse is intentionally impossible.
:::callout{type="info" title="Offline is not the same as isolated"}
`--offline` disables registry *package* resolution, not remote-cache traffic. If a build must not contact a remote cache, unset `VBS_REMOTE_CACHE` and omit `--remote-cache`. Use `--no-cache` to bypass both local reads and remote reads in one run; successes are still recorded locally and uploaded.
:::
The cache stores full output blobs, so the token holder can read build products. Use a private registry, a dedicated cache instance and short-lived tokens when products are sensitive.
## Remote execution model
The registry maintains:
- worker registration and heartbeat records;
- an in-memory FIFO action queue;
- exclusive leases with a TTL and a lease token;
- action records and output blobs in the action-cache CAS.
Leases, workers, sessions and the queue are **in-memory**. Restarting the registry invalidates them and drops queued work; published blobs and action records persist in the data directory.
## Direct worker mode
```sh
vbs worker --registry https://cache.example.com \
--action-key <64-hex-key> \
--record build/action-record.json \
--lease-seconds 300
```
1. Register a worker.
2. Lease the exact action key. The registry returns the record inline when the key exists.
3. Publish every referenced output blob and the record to the CAS.
4. Submit the result with the lease token.
Use direct mode when an orchestrator already knows the action key and the record.
## Queue worker mode
```sh
vbs worker --queue --registry https://cache.example.com
vbs worker --queue --once
vbs worker --queue --idle-timeout 60 --parallel 4
```
- `--queue` leases the next queued action, executes or publishes it, submits the result, and repeats.
- `--once` stops after one action.
- `--idle-timeout SECONDS` keeps watching an empty queue before exiting; `0` exits immediately.
- `--parallel N` (1–32) runs N concurrent lease/execute loops in one process. The registry leases an action to exactly one worker, so loops do not duplicate work.
- Transient lease failures are retried three times before the worker exits.
If an action is already built locally, the worker exports the local action record. Otherwise it fetches the record from the CAS and executes the action spec:
```json
{
"command": ["sh", "-c", "cat input.txt > output.txt"],
"working_directory": "/path/to/project",
"inputs": {
"input.txt": {"sha256": "…", "size": 12, "mode": 420}
},
"output_paths": ["output.txt"]
}
```
Inputs are downloaded and digest-verified, outputs are uploaded, and the result is submitted only after the required blobs exist. A missing `command` skips the action with a warning; a failed execution leaves the lease to expire rather than submitting a false success. There is no retry/backoff or capacity-aware scheduling in 1.0.0.
:::callout{type="warning" title="Size the lease above the execution"}
The worker CLI does not renew leases while an action runs. Set `--lease-seconds` larger than `--exec-timeout` (default `600`) or a long action can finish after its lease expired and fail its result upload with `409 not_leased`. The registry exposes a renewal endpoint and client API; the CLI loop does not call it yet.
:::
## Registry-side endpoints
| Method + path | Purpose |
| --- | --- |
| `PUT/GET /api/v1/cas/blobs/<sha256>` | Store/fetch a content-addressed blob |
| `PUT/GET /api/v1/cas/actions/<action-key>` | Store/fetch an action record |
| `POST /api/v1/workers` | Register a worker |
| `POST /api/v1/workers/<id>/heartbeat` | Refresh worker liveness (owner/admin) |
| `GET /api/v1/workers` | List workers |
| `POST /api/v1/queue` | Enqueue action keys (publish scope or admin) |
| `GET /api/v1/queue` | List pending and leased keys |
| `POST /api/v1/queue/lease` | Lease the oldest unleased key |
| `POST /api/v1/actions/lease` | Lease a specific key and return its record |
| `POST /api/v1/actions/<key>/renew` | Extend a lease with its token |
| `POST /api/v1/actions/<key>/result` | Upload a result record and complete the lease |
All worker, lease and result endpoints require an authenticated principal. Enqueueing on `POST /api/v1/queue` additionally requires the `publish` scope or admin. The endpoints do not check ownership of a supplied worker id, so treat registry accounts as trusted build infrastructure; do not give a shared worker token to an untrusted user.
## CI pattern
```sh
# 1. Start a private registry with a bootstrap admin.
export VBS_REGISTRY_ADMIN_PASSWORD='...'
vbs-registry --data-dir /var/lib/vbs-registry --bind 127.0.0.1 --port 8080 &
# 2. Create a publish-scoped token through the API or web UI.
# 3. Warm the cache.
vbs build --locked --remote-cache http://127.0.0.1:8080
# 4. A second clean checkout reuses verified actions.
git clone ... clean && cd clean
vbs build --locked --remote-cache http://127.0.0.1:8080
```
Use a separate build directory per job, but the same toolchain/profile identity. A cold build populates the cache; a second clean build reports cached actions instead of recompiling.
## Limits
| Item | 1.0.0 behavior |
| --- | --- |
| Cache key reuse | Same toolchain/profile/inputs only |
| Cache verification | SHA-256 on every blob read |
| Upload failures | Warning only; local build still succeeds |
| `--offline` | Does not disable remote cache |
| Worker lease renewal | API exists; CLI does not renew |
| Worker scheduling | FIFO, no affinity, no capacity awareness |
| Worker restart | Queue, leases, workers and sessions are lost |
| Sandboxing | None; action specs run with worker privileges |
Next: [run the registry service](/build-system/consumer/registry-service) or [read the registry internals](/build-system/developer/registry-internals).
+210
View File
@@ -0,0 +1,210 @@
---
title: Installers, Provenance and Publishing
description: Stage install trees, produce eight installer formats, sign and attest products, and publish releases and binary variants
section: Shipping & Publishing
badge: install + registry
order: 1
tags: [install, packaging, tar, zip, deb, rpm, wix, dmg, nuget, sbom, signing, registry, publish]
updated: 2026-12-06
---
# Installers, Provenance and Publishing
VBS covers the path from a built profile to a verifiable release: staged installs with an ownership manifest, relocatable CMake and native exports, deterministic installer archives, SPDX/CycloneDX SBOMs, Ed25519 signatures, and source or binary publication to a registry.
## Install a prefix
```cpp
auto app = project.executable("app");
app.sources({"src/main.cpp"}).link(core).install("bin");
auto core = project.static_library("core");
core.sources(project.glob("src/core/**/*.cpp"))
.include_directory("include", Void::Build::Visibility::Public)
.install("lib");
project.install_directory("include", "include");
project.install_file("LICENSE", "share/doc/app/LICENSE", "docs");
```
```sh
vbs install --prefix dist/prefix --package-name app --package-version 1.2.3
```
`vbs install` builds with the selected profile and resolves dependencies online; it has no `--locked`, `--offline` or `--native-foreign` flag in 1.0.0. Only targets with an install rule and explicitly declared files are installed. An empty destination uses the default for the kind (executables to `bin`, libraries to `lib`). Headers are not installed automatically; declare `install_directory("include", "include")`.
The resulting prefix contains:
```text
prefix/
├── .vbs-install-manifest.json # owned files, used by uninstall
├── bin/app
├── lib/libcore.a
├── include/...
├── lib/cmake/app/appConfig.cmake # unless --no-cmake-export
├── lib/cmake/app/appTargets.cmake
└── share/vbs/app/package.json # unless --no-native-export
```
- Installation is staged privately and published only after every item validates.
- Path traversal, destination collisions, duplicate files and build-tree path leaks are rejected.
- `--component NAME` installs only one component.
- `--bundle-dependencies` copies the installed targets' runtime shared libraries into `<prefix>/lib`, deduplicated.
- `vbs uninstall --prefix DIR` removes only manifest-owned files and preserves everything else.
CMake exports are relocatable: generated targets use `${_vbs_prefix}` and relative include directories, never the original build or snapshot path. The native `package.json` records the package name/version, profile, compiler, OS, architecture, include directory, targets, public defines/options and local target dependencies.
## Installer archives
```sh
vbs install --prefix dist/prefix --archive dist/app.tar
vbs install --prefix dist/prefix --archive dist/app.run --archive-format sh
vbs install --prefix dist/prefix --archive dist/app.deb --archive-format deb
vbs install --prefix dist/prefix --archive dist/app.rpm --archive-format rpm
vbs install --prefix dist/prefix --archive dist/app.zip --archive-format zip
vbs install --prefix dist/prefix --archive dist/app.wxs --archive-format wix
vbs install --prefix dist/prefix --archive dist/app.dmg --archive-format dmg
vbs install --prefix dist/prefix --archive dist/app.nupkg --archive-format nuget
```
| Format | Output |
| --- | --- |
| `tar` (default) | Deterministic USTAR/PAX archive of the owned prefix files |
| `sh` | Executable POSIX self-extracting installer with a tar payload; `--prefix DIR` or `PREFIX` selects the destination |
| `zip` | Stored (uncompressed) deterministic ZIP with CRC-32 and canonical timestamps |
| `deb` | Debian `ar` package with `debian-binary`, `control.tar`, `data.tar`; accepted by `dpkg-deb` |
| `rpm` | Real RPM with lead, signature header, main header and newc cpio payload; accepted by `rpm` |
| `wix` | WiX v3 source XML with deterministic Product/Upgrade GUIDs; compile with candle/light on Windows |
| `dmg` | UDIF container: deterministic tar payload plus a 512-byte `koly` trailer with CRC-32 checksums |
| `nuget` | `.nupkg` OPC ZIP with `.nuspec`, `[Content_Types].xml`, `_rels/.rels` and `runtimes/<rid>/native/**` |
The `wix` output is a source file, not an MSI. The `dmg` output is a valid UDIF container but does not include an HFS+/APFS payload writer, so it is not a mountable macOS image by itself. `deb`, `rpm`, `zip` and `nuget` are validated by their native readers in the test suite.
Archives contain the installed files and generated export metadata. The `.vbs-install-manifest.json` is written into the prefix after the installed-file list is fixed, so it is **not** inside the archive in 1.0.0. Two runs with the same input produce identical archive bytes.
## Sign installer archives
```sh
vbs install --prefix dist/prefix \
--archive dist/app.tar \
--signing-key signing.seed
```
This writes:
| File | Content |
| --- | --- |
| `dist/app.tar.sha256` | `sha256sum` format checksum |
| `dist/app.tar.sig` | Ed25519 detached signature hex |
| `dist/app.tar.pub` | Signer public key hex |
| `dist/app.tar.msg` | Exact signed message |
The signed message is short and size-independent:
```text
vbs-installer-v1
<archive-sha256>
```
Signing streams the archive digest, so large packages do not hit a one-shot crypto limit. If no Ed25519 backend is available, signing fails closed with an explicit error instead of writing a partial signature.
## SBOM
```sh
vbs build --sbom build/app.spdx.json
vbs build --sbom build/app.cdx.json --sbom-format cyclonedx
vbs test --sbom build/app.spdx.json
```
- **SPDX 2.3** is the default; **CycloneDX 1.5** is selected with `--sbom-format`.
- Inputs are the pinned lockfile entries that carry a concrete version (registry packages) and the build graph's primary output files, with SHA-256 digests. Git/path/archive/pkg-config entries without a version are omitted.
- The document namespace/serial is derived from the input content, and the timestamp comes from the reproducibility epoch, so identical inputs produce byte-identical SBOMs.
- Unknown supplier/download locations are encoded as `NOASSERTION`, not omitted silently.
The SBOM records what was resolved and built; it does not prove that the build was honest. Pair it with signed archives and the install manifest for provenance.
## Publish a source release
```sh
vbs publish --registry https://packages.example.com \
--name my-lib --version 1.2.3 \
--description "A small library" \
--signing-key signing.seed
```
`vbs publish`:
1. creates a deterministic source archive of the project;
2. excludes `.git`, `.vbs`, `build`, `.serena`, `.cache`, `keys`, `.env`, `WG.conf`, symlinks and the output archive itself;
3. uploads the raw tar to `PUT /api/v1/packages/<name>/<version>`;
4. optionally signs the canonical `vbs-package-v1` digest message and attaches `X-Package-Signature` / `X-Package-Public-Key`.
Publishing the same bytes again is idempotent. Publishing different bytes for an existing version is rejected as an immutable conflict. The archive must extract safely (no traversal, absolute paths, symlinks, hardlinks, duplicates or quota violations), or the registry rejects it as `422 invalid_archive`.
Registry metadata:
- descriptions and private flags are carried by `X-Package-Description` / `X-Package-Private` on publish and can be changed later with `PATCH /api/v1/packages/<name>` (no CLI in 1.0.0);
- release signature metadata is stored and served but not verified server-side; consumers enforce trust;
- yanking flips a flag used by clients when selecting releases/variants. Download endpoints still serve yanked content, so yanking is advisory, not deletion.
## Publish a binary variant
```sh
vbs publish-binary --registry https://packages.example.com \
--name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release \
--file dist/prefix/lib/libmy_lib.a \
--signing-key signing.seed
```
`vbs publish-binary` computes the artifact SHA-256, optionally signs the canonical binary message, and uploads to `PUT /api/v1/packages/<name>/<version>/binaries/<variant>`. Variant ids are 1–128 characters of `[A-Za-z0-9._-]`. Identical bytes are idempotent; different bytes for the same variant are a 409 immutable conflict.
Binary variants are selected by a compatibility key covering OS, architecture, compiler family and ABI, stdlib ABI, linkage, CPU features, sanitizers, LTO and dependency-closure hash. **Normal `vbs build` dependency resolution still builds registry packages from source in 1.0.0.** Binary variants are published, listed, fetched and verified explicitly.
```sh
vbs binaries list --registry URL --name my-lib --version 1.2.3
vbs binaries show --registry URL --name my-lib --version 1.2.3 --variant linux-x86_64-gcc16-release
vbs binaries fetch --registry URL --name my-lib --version 1.2.3 \
--variant linux-x86_64-gcc16-release --output libmy_lib.a
```
A fetch verifies SHA-256 before writing. With `--trusted-public-key` or `--trusted-key-file`, it also requires a valid Ed25519 signature from a trusted key.
## Releases and tokens
```sh
vbs releases list --registry URL --name my-lib
vbs releases show --registry URL --name my-lib --version 1.2.3
vbs releases yank --registry URL --name my-lib --version 1.2.3
vbs releases yank --registry URL --name my-lib --version 1.2.3 --unyank
vbs tokens list --registry URL
vbs tokens revoke --registry URL --token-id tok_...
```
- `releases show` prints the digest, size, yank state, signature presence and binary count.
- Plaintext token secrets are returned exactly once at creation and are never listed again.
- Token revocation is a soft flag and takes effect on the next verification.
## Private packages
:::callout{type="warning" title="Private means hidden from anonymous access"}
In 1.0.0, a private package is omitted from anonymous listings and requires authentication. Any authenticated principal carrying the default `read` scope can read it; private is not a per-user ACL. Treat a registry as a trusted team service and use separate registries or groups when stronger isolation is required.
:::
## Release checklist
:::steps
@@step[Build and test reproducibly]
`vbs test --profile release --locked --no-cache`
@@step[Generate provenance]
`vbs test --profile release --sbom dist/app.spdx.json`
@@step[Install and package]
`vbs install --profile release --prefix dist/prefix --archive dist/app.tar --signing-key signing.seed`
@@step[Publish the source]
`vbs publish --registry URL --name app --version 1.2.3 --signing-key signing.seed`
@@step[Publish platform binaries]
`vbs publish-binary --registry URL --name app --version 1.2.3 --variant linux-x86_64 --file dist/prefix/bin/app --signing-key signing.seed`
:::
Next: [run the registry yourself](/build-system/consumer/registry-service) or [read the registry internals](/build-system/developer/registry-internals).
+159
View File
@@ -0,0 +1,159 @@
---
title: Tests, Fixtures and Reports
description: Register VOID_TEST cases, declare test targets, use labels, resources and fixtures, and publish JUnit, CDash and coverage results
section: Testing & Reports
badge: vbs test
order: 1
tags: [testing, void-test, fixtures, labels, junit, cdash, coverage, wine]
updated: 2026-12-06
---
# Tests, Fixtures and Reports
VBS runs tests as ordinary `TargetKind::Test` executables. There is no separate test DSL: a test target is built by the normal graph, then the runner schedules test executables in parallel up to `--jobs`, subject to fixtures and exclusive resources. A test passes when its process exits with status `0`.
## Register tests
VoidLibrary's `VOID_TEST(Suite, name)` macro self-registers a case, so no external scanner is needed:
```cpp
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
VOID_TEST(Math, addition_works) {
Void::Testing::expect_eq(1 + 1, 2);
}
```
Declare a test target in `build.cpp`:
```cpp
auto tests = project.test("math_tests");
tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/math_test.cpp"})
.link(core)
.link(library.target("Void::Testing"))
.label("unit");
```
`vbs gen-tests --input FILE --output-dir DIR` emits a registration unit for cases that do not use the self-registering macro. It is also what a CMake-free test setup can use to avoid a scanner.
## Run and select
```sh
vbs test
vbs test --profile release --target math_tests
vbs test --label unit
vbs test --label unit --label integration
vbs test --jobs 8 --test-timeout 120
```
- `--target` selects target names; repeatable.
- `--label` selects tests carrying any listed label. Fixture setup/cleanup targets are pulled in automatically even when their own labels do not match.
- `--test-timeout` is per test, default `300` seconds, allowed `1..86400`.
- A failed fixture setup skips its dependents with an explicit `SKIPPED` line.
- The final summary prints `PASSED`/`FAILED` per test and exits `1` if any test failed.
- `vbs test` does not forward arguments to test executables. To use `Void::Testing` filters or its own reporters, run the test binary directly.
## Fixtures, resources and parallelism
```cpp
auto db_setup = project.test("db_setup");
db_setup.label("fixture").fixture_setup("database");
auto db_test = project.test("db_test");
db_test.link(core)
.label("integration")
.resource("database")
.fixture_required("database");
auto db_cleanup = project.test("db_cleanup");
db_cleanup.label("fixture").fixture_cleanup("database");
```
- **Resources**: tests declaring the same resource never overlap. The resource is held exclusively for the duration of the test; other tests continue in parallel.
- **Fixtures**: setup runs before every user, required fixtures pull their setup in, cleanup runs after all users, and setup failure skips dependents. Cycles are rejected.
- **Ordering** is deterministic for the fixture graph; independent tests may complete in any order.
This matches the CTest fixture/resource model closely enough to migrate existing suites without rewriting their topology.
## JUnit XML
```sh
vbs test --junit build/test-results.xml
```
The report aggregates every executed test **target** across selected profiles. Each profile becomes a `<testsuite>`; each target becomes a `<testcase>` with `classname`, `name`, `time`, a `<failure>` with the exit status and captured output when it fails, and escaped XML text. It does not expand individual `VOID_TEST` cases into separate testcases. This is directly consumable by Gitea Actions, GitHub Actions and most CI dashboards.
## CDash
```sh
vbs test --cdash https://cdash.example.com \
--cdash-project my-project \
--cdash-build linux-debug \
--cdash-output build/Test.xml
```
- `Test.xml` is CTest-compatible and includes the site, build name/stamp, OS and generator.
- `--cdash` submits a multipart form to `<cdash>/submit.php?project=...`.
- The upload uses `Void::Net` when linked, otherwise the POSIX HTTP/1.1 fallback.
- `--cdash-output` writes the same XML locally without uploading.
## Coverage
```sh
vbs test --coverage build/coverage
```
Every compile and link for the selected profiles gets `--coverage`. After the tests run, VBS walks the profile build directories for `.gcda` files, invokes `gcov --json-format`, filters out sources outside the project root, and writes:
- `build/coverage/coverage.info`: lcov records (`TN`, `SF`, `DA`, `LF`, `LH`, `end_of_record`);
- `build/coverage/summary.txt`: one line with percent, hit lines, total lines and file count.
`gcov` must be on `PATH`. A run that produces no `.gcda` data is an explicit failure, not an empty report.
## Cross-platform tests
A Windows target can be built on Linux with MinGW-w64 and executed under Wine:
```sh
vbs test --target-os windows --target-arch x86_64 --target app_tests
```
The toolchain driver selects `x86_64-w64-mingw32-g++`, emits PE artifacts and runs the test through the configured Wine runner. The repository regression test is skipped when MinGW or Wine is unavailable. Windows-specific validation (reserved device names, case-insensitive output collisions and case-insensitive file lookup) is exercised by that path.
## CTest during bootstrap
The CMake bootstrap exposes eight CTest entries:
| Test | Scope |
| --- | --- |
| `vbs_sdk_tests` | Declaration SDK and example description |
| `vbs_core_tests` | SHA-256, process supervisor, profiles, snapshots, state, end-to-end |
| `vbs_v1_tests` | CompDB, providers, packages, install, modules, daemon, signing, IDE, workspaces |
| `vbs_registry_tests` | Registry API, RBAC, CAS, workers and live CLI E2E |
| `vbs_selfhost_tests` | Native self-host, `VOID_TEST` generation, bit-identical rebuilds |
| `vbs_sdk_registration` | Self-registration and named JSON cases |
| `vbs_cli_contract` | Auto-generated CLI help, subcommands and error contracts |
| `vbs_description_contract` | Four profile/compiler contexts and describe error contracts |
```sh
dev cpp-gcc -c ctest --test-dir build --output-on-failure
```
Under `vbs test`, the same suite executables are declared as test targets, so the self-hosted build runs them without CMake.
## Reporting and CI checklist
:::steps
@@step[Run targeted tests locally]
`vbs test --label unit --jobs 8`
@@step[Produce CI reports]
`vbs test --junit build/junit.xml --coverage build/coverage --cdash-output build/Test.xml`
@@step[Fail the pipeline on any test]
Use the `vbs test` exit status; do not parse only the logs.
@@step[Keep fixtures explicit]
Prefer a resource for exclusive services and a fixture for setup/cleanup ordering.
:::
Next: [use the remote action cache and workers](/build-system/consumer/remote-ci) or [read the self-hosting verification details](/build-system/developer/self-hosting).
+110
View File
@@ -0,0 +1,110 @@
---
title: Multi-Package Workspaces
description: Declare members in workspace.cpp, share one lockfile and CAS, link across members, and select affected builds
section: Workspaces
badge: workspace.cpp
order: 1
tags: [workspace, monorepo, members, changed-since, lockfile, cas]
updated: 2026-12-06
---
# Multi-Package Workspaces
A workspace root is a directory containing `workspace.cpp` instead of `build.cpp`. It lists member projects; each member keeps its own `build.cpp`, profiles and targets, while the workspace shares one `vbs.lock` and one build cache.
```cpp
#include <Void/Build.hpp>
void workspace(Void::Build::Workspace &workspace) {
workspace.member("lib", "packages/lib");
workspace.member("app", "packages/app");
workspace.member("tests", "packages/tests");
}
```
Member names are unique and non-empty. Paths may be relative to the workspace root or absolute; every member must exist and resolve to a directory. Members build sequentially in declaration order; a failure does not stop later members, but the final exit code is `1`.
Workspace-wide `--target NAME` requires every selected member to declare that target; a name missing from one member fails the run.
## Build and select members
```sh
vbs build # every member, in declared order
vbs test # build and test every member
vbs build --member app # one member
vbs test --member app --member lib # several members
vbs build --changed-since origin/main
```
`--changed-since REF` runs `git diff --name-only REF` from the workspace root and selects the deepest member containing each changed path. Only tracked changes are considered; untracked files are not included. A change outside every member selects nothing and exits successfully with `vbs: no workspace members changed since REF`. Selection is by member directory, not by target. `--member` takes precedence over `--changed-since`; both flags are silently ignored for a non-workspace project.
## What is shared and what is not
Workspace orchestration is implemented for `vbs build` and `vbs test` at the root. Root-level `vbs describe`, `graph`, `ide`, `compdb*`, `deps`, `install` and `watch` do **not** evaluate a workspace; they see the generated `build()` stub and fail with “this descriptor declares no build() entry point”. Use member-scoped daemon requests (`vbs daemon describe --member`, `vbs daemon ide query --member`, and so on) or run the command inside a member with its `VBS_WORKSPACE_MEMBER_*` environment supplied.
| Resource | Scope |
| --- | --- |
| `vbs.lock` | Shared at the workspace root |
| Build state / CAS | Shared `<workspace>/build/.vbs` |
| Profiles | Each member declares its own; the same profile name builds with each member's description |
| Outputs | Per member under `build/members/<name>/profiles/<profile>/` |
| Editor selection | Members do not steal the workspace root `compile_commands.json` alias |
A workspace member build is internally a normal project build with:
- `project_root` set to the member directory;
- `build_root` set to `build/members/<name>`;
- `lock_root` set to the workspace root;
- `state_dir` set to the workspace `build/.vbs`.
Member outputs therefore look like:
```text
build/
├── .vbs/ # shared state and CAS
└── members/
├── lib/profiles/debug/out/libcore.a
├── app/profiles/debug/out/bin/app
└── tests/profiles/debug/out/bin/tests
```
`vbs clean` at the root removes only `build/profiles` and `build/compile_commands.json`; member outputs under `build/members/**` survive unless `vbs clean --all` removes the whole build root.
## Link across members
A member declares a workspace dependency by name:
```cpp
void build(Void::Build::Project &project) {
auto lib = project.workspace_dependency("lib");
auto app = project.executable("app");
app.sources({"src/main.cpp"})
.link(lib.target("core"));
}
```
During member evaluation `vbs` exports `VBS_WORKSPACE_MEMBER_<member>` with the canonical member directory. `workspace_dependency` records that path as a native builder dependency, so the target is imported through the same native provider path as an external `build.cpp` dependency. Calling it outside a workspace, or naming an undeclared member, is an explicit error.
The exported target name is the dependency's own target name. In the example, the `lib` member must declare a target named `core`.
## Daemon and workspaces
The daemon understands workspace roots:
- `vbs daemon describe` returns a bounded per-member summary and accepts `--member` to describe one member.
- `vbs daemon build` with no member builds every member in declared order against the warm state store and returns per-member outcomes plus aggregate counts. The wire protocol also accepts a `member` field for a member-scoped build.
- `vbs daemon test` builds and runs declared tests, including workspace-wide runs.
- `vbs daemon ide query|generate` and `vbs daemon compdb export` accept `--member`; a workspace root requires it, while a plain project rejects it.
Member-scoped daemon IDE requests write editor metadata inside the member directory (for example `packages/app/.clangd`), not at the workspace root.
## Practical rules
:::callout{type="tip" title="Keep member ownership clear"}
- Give each member a unique target namespace; cross-member references use the member's exported target name, not a path.
- Keep shared tooling in its own member and depend on it with `workspace_dependency(...)` instead of relative `include_directories`.
- Use `--changed-since` in CI to avoid rebuilding unaffected members; use explicit `--member` flags when a pipeline already knows the affected set.
- The workspace root has no `build()` entry point. Running `vbs build` there is workspace orchestration, not a hidden root target graph.
:::
Next: [use the everyday CLI](/build-system/consumer/command-reference) or [wire an editor and daemon](/build-system/consumer/editors).