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,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.