Files
Build-System/docs/build-system/consumer/dependencies.md
T

11 KiB

title, description, section, badge, order, tags, updated
title description section badge order tags updated
Dependencies, Locking and Providers Declare Git, path, archive, registry, Conan and pkg-config dependencies, lock them, build foreign projects natively, and enforce signatures Dependencies & Packages solver + lock 1
dependencies
toml
semver
lockfile
registry
cmake
meson
conan
pkg-config
signing
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++

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:

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

[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:

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

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

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:

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:

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:

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