5.5 KiB
Declaration SDK (Void::Build)
Status: Full v1 declaration SDK, JSON schema_version: 1.
Documents include/Void/Build.hpp and src/Build.cpp.
The SDK uses namespace Void::Build, PascalCase types/enum constants, and snake_case functions/methods. Future incompatible schema changes increment schema_version.
Entry Points and Profiles
void build(Void::Build::Project &project): declares targets, dependencies, and install rules for one evaluatedProfileContext.void profiles(Void::Build::Profiles &profiles): declares build profiles (optional if using defaults).
Void::Build::default_profiles() provides "debug" (-O0, -g) and "release" (-O3, -DNDEBUG).
Profiles supports:
add(name, compile_options)inherit(name, parent, compile_options)define(ProfileDescription)(supportscompile_options,link_options,defines,parent,compiler,cxx_standard,lto,sanitizers,sysroot,compiler_path,reproducibility_epoch,nondeterministic)resolve(name, compiler_or_opt, os, architecture)-> returns an immutableProfileContext, throwingstd::invalid_argumenton unknown profile names, missing parents, or profile inheritance cycles.
Targets and Usage Requirements
Project supports seven TargetKind constructors:
| Constructor | TargetKind |
|---|---|
project.executable(name) |
TargetKind::Executable |
project.static_library(name) |
TargetKind::StaticLibrary |
project.shared_library(name) |
TargetKind::SharedLibrary |
project.header_only_library(name) |
TargetKind::HeaderOnly |
project.object_library(name) |
TargetKind::ObjectLibrary |
project.custom_action(name) |
TargetKind::CustomAction |
project.test(name) |
TargetKind::Test |
Target names must be nonempty and unique per Project. Operations validate inputs immediately and throw std::invalid_argument on invalid arguments or std::logic_error on expired handles or cross-project links.
| Method | Purpose |
|---|---|
.sources(SourceSet) |
Explicit files ({"a.cpp"} / SourceSet::file), globs (project.glob("src/*.cpp")), or SourceSet::module_interface / module_partition / header_unit |
.conventional_sources() |
Enable conventional source discovery (src/, source/, etc.) |
.module_sources(SourceSet) / .header_unit(path) |
C++20/23/26 module units and explicit header units |
.include_directory(path, visibility) / .system_include_directory(path, visibility) |
Scoped -I / -isystem paths |
.compile_option(opt) / .compile_option(opt, visibility) |
Ordered compile flags |
.define(macro, visibility) |
Scoped -D preprocessor defines |
.link_option(opt, visibility) |
Scoped linker flags |
.link(Target|ImportedTarget, visibility) |
Local or foreign imported library links (Visibility::Private, Public, Interface) |
.depends_on(Target) |
Explicit action prerequisite ordering (for example, codegen producer before consumer) |
.cxx_standard(CxxStandard) |
Default, Cxx17, Cxx20, Cxx23, Cxx26 |
.precompiled_header(path) / .unity_build(enabled, batch_size) |
PCH and deterministic unity batching |
.lto(LtoMode) / .sanitizer(Sanitizer) |
LtoMode::None|Full|Thin; Sanitizer::Address|Undefined|Thread|Memory|Leak |
.per_file_option(source, opt) |
Per-TU compile flag override (excluded from unity batches) |
.command(argv) / .inputs(paths) / .outputs(paths) / .working_directory(dir) / .env(k, v) / .nondeterministic(flag) |
Custom action execution specification |
.enabled(flag) |
Enable/disable target lowering |
.install(destination, component) |
Target installation rule |
Dependencies, TOML Manifests & Install Rules
project.dependency(alias)registers a uniqueDependencyhandle:.git(url, Commit{sha40})(requires exact 40-hex commit hash).path(local_path).archive(url, sha256).package(id, semver_range)with optional.registry(authority_url)and.feature(name)- Builders:
.cmake(options),.meson(options),.conan(ref, options),.native_builder(options) .build_dependency(bool)marks host-tool dependencies.target(exported_name)produces anImportedTargethandle for.link(...)
project.dependencies_file(path)records symbolic TOML manifest references (e.g.vbs.deps.toml) resolved and merged by the core engine (vbs deps/vbs build) with origin-preserving conflict checks.project.install_file(src, dest, component)andproject.install_directory(src, dest, component)declare non-target artifact installation rules.
OptionValue accepts std::string, const char*, bool, or signed/range-checked std::int64_t values.
JSON Serialization (schema_version: 1)
Project::to_json() validates UTF-8 on every emitted string (rejecting malformed byte sequences, overlong encodings, surrogates U+D800..U+DFFF, and code points above U+10FFFF with std::invalid_argument) and emits deterministic JSON consumed by Graph::ProjectDescription::from_json.
See tests/SdkDeclarations.cpp, tests/ExampleContexts.cpp, and docs/agent-workflow/VERIFICATION.md.