Implement VoidBuildSystem v1 (Plans 01-19) with VoidLibrary integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s

This commit is contained in:
faumaray committed 2026-11-26 20:45:54 +03:00
1 parent 3cac890ce9
commit ab64147f9d
114 files changed
+23777 -1392

No files matched your search

+56 -100
View File
@@ -1,118 +1,74 @@
# Bootstrap declaration SDK
# Declaration SDK (`Void::Build`)
Status: implemented declaration subset, schema version 1. This documents the
[public header](../include/vbs/build.hpp) and the compiled
[example](../build.cpp), not a completed native build engine. The SDK is experimental;
future incompatible protocol changes must change its schema version.
Status: Full v1 declaration SDK, JSON `schema_version: 1`.
Documents [include/Void/Build.hpp](file:///home/faumaray/Projects/VoidBuildSystem/include/Void/Build.hpp) and [src/Build.cpp](file:///home/faumaray/Projects/VoidBuildSystem/src/Build.cpp).
## Entry points and context
The SDK uses namespace `Void::Build`, `PascalCase` types/enum constants, and `snake_case` functions/methods. Future incompatible schema changes increment `schema_version`.
`void build(vbs::Project&)` declares one concrete graph for one effective profile.
`void profiles(vbs::Profiles&)` declares available profiles. The current example
defines both and links them into `vbs_describe`; automatic loading of arbitrary
projects and optional-profile fallback belong to the future frontend.
## Entry Points and Profiles
`vbs::default_profiles()` contains debug (`-O0`, `-g`) and release (`-O3`, `-DNDEBUG`).
`Profiles::add(name, options)` adds a distinct profile. `Profiles::resolve(name,
compiler, os, architecture)` returns a `ProfileContext` with those target facts and
the profile's options. Unknown names and invalid contexts throw
`std::invalid_argument`.
- `void build(Void::Build::Project &project)`: declares targets, dependencies, and install rules for one evaluated `ProfileContext`.
- `void profiles(Void::Build::Profiles &profiles)`: declares build profiles (optional if using defaults).
`Project::context()` exposes name, compiler family, OS, architecture and effective
compile options. The bootstrap harness accepts `--profile debug|release` and
`--compiler gcc|clang`. OS and architecture come from its CMake configuration.
Selecting Clang here does not prove a Clang build or probe a target toolchain.
`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)` (supports `compile_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 immutable `ProfileContext`, throwing `std::invalid_argument` on unknown profile names, missing parents, or profile inheritance cycles.
## Targets and source membership
## Targets and Usage Requirements
`Project::executable(name)` and `static_library(name)` return handles to new target
records. Names must be nonempty and unique in the target namespace. Other target
kinds, cycle detection, usage propagation and command lowering are planned.
`Project` supports seven `TargetKind` constructors:
| Operation | Recorded data |
| Constructor | `TargetKind` |
| --- | --- |
| `target.sources({"src/main.cpp"})` | Explicit source files |
| `target.sources(project.glob("src/*.cpp"))` | A symbolic glob |
| `target.include_directory("include", visibility)` | Include path and visibility |
| `target.compile_option("-Wall")` | An ordered compile option |
| `target.link(other, visibility)` | A local target reference |
| `target.link(dependency.target("Name::Target"), visibility)` | An imported target reference |
| `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` |
`Visibility` values are `private_`, `public_`, `interface_`; the default is private.
Source paths/patterns are retained without filesystem access. `SourceSet::file`
and `SourceSet::glob` are also available. Repeated operations append records;
semantic graph validation beyond the declaration invariants is future work.
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.
## Dependencies and options
`Project::dependency(alias)` creates a unique dependency handle. It records one of:
- `.git(url, vbs::Commit{sha})`: a nonempty URL and an exact 40-hex-digit revision.
- `.package(id, range)`: a nonempty package identity and version constraint string.
`.cmake(options)` selects the CMake builder for a source dependency. Options retain
string, boolean or signed 64-bit integer types through `vbs::OptionValue`. Out-of-range
integers, empty option names and contradictory source/builder declarations fail.
Package range syntax is recorded but is not parsed or solved in this milestone.
Imported target names are symbolic; the future provider validates that they exist.
An unset dependency source is permitted during declaration construction but fails
when serializing a complete project. Source downloads, CMake execution, TOML and
other providers are outside the implemented SDK.
## Ownership and failures
`Project` cannot be copied or moved. Target/dependency handles store a weak owner
identity and index, so adding more records does not invalidate handles. Cross-project
links and operations after owner destruction throw. An imported target also carries
its dependency's owner identity.
`record()`, `targets()`, `dependencies()` and `Profiles::records()` expose borrowed
const views. Do not retain element references across container growth or after owner
destruction. Stable handles do not imply stable references into vectors.
Declaration errors are exceptions; the example harness catches them, prints a
diagnostic and exits 2. Successful output is only JSON on stdout. The SDK is intended
for one configuration evaluation at a time; it does not promise concurrent mutation.
Ordinary user C++ executes as trusted code without a sandbox.
## JSON protocol
`Project::to_json()` emits a deterministic object with these fields:
| Field | Shape |
| Method | Purpose |
| --- | --- |
| `schema_version` | Integer `1` |
| `profile` | `name`, `compiler`, `os`, `architecture`, ordered `compile_options` |
| `targets` | Ordered target records |
| `dependencies` | Ordered dependency records |
| `.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 |
Each target has `name`, `kind` (`executable` or `static_library`), `sources`
(`kind`: `file`/`glob`, `path`), `include_directories` (`path`, `visibility`),
`compile_options` and `links`. A link has `kind` (`local`/`imported`), `target`,
`dependency` (empty for local links) and `visibility` (`private`/`public`/`interface`).
## Dependencies, TOML Manifests & Install Rules
Each dependency has `name`, `source`, `builder` and `options`. A Git source has
`kind: "git"`, `location` and `revision`; a package source has `kind: "package"`,
`package` and `version`. Options are a key-sorted JSON object with their native
string/bool/integer types. An unspecified builder is the empty string.
- `project.dependency(alias)` registers a unique `Dependency` handle:
- `.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 an `ImportedTarget` handle 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)` and `project.install_directory(src, dest, component)` declare non-target artifact installation rules.
Declaration order is preserved; string escaping covers quotes, backslashes and
control characters. All strings, including keys, must be valid UTF-8 at serialization.
`to_json()` preserves valid Unicode and throws `std::invalid_argument` on malformed
UTF-8, including overlong sequences, surrogate encodings and values above U+10FFFF.
Declaration methods may record raw bytes, but they cannot cross the JSON boundary
without this validation. Non-UTF-8 filesystem names therefore require an explicit
future path-encoding policy; they are not silently replaced or reinterpreted.
This protocol currently describes inputs; it contains no resolved
packages, expanded files, actions, build results or capability claims.
`OptionValue` accepts `std::string`, `const char*`, `bool`, or signed/range-checked `std::int64_t` values.
## Tests
## JSON Serialization (`schema_version: 1`)
`vbs_sdk_tests` uses Void::Testing. CTest checks the complete suite, named registration,
CLI exit/output behavior and the four runtime contexts. The JSON test roundtrips
through Void::Json::Strict; CMake independently parses example output. Registration
checks ensure the aggregate test cannot pass merely because no SDK cases were found.
`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](file:///home/faumaray/Projects/VoidBuildSystem/include/Void/Build/Graph/Graph.hpp).
See [verification](agent-workflow/VERIFICATION.md) for actual commands and results,
and [plan 01](roadmap/01-bootstrap-sdk.md) for milestone acceptance.
See [tests/SdkDeclarations.cpp](file:///home/faumaray/Projects/VoidBuildSystem/tests/SdkDeclarations.cpp), [tests/ExampleContexts.cpp](file:///home/faumaray/Projects/VoidBuildSystem/tests/ExampleContexts.cpp), and [docs/agent-workflow/VERIFICATION.md](file:///home/faumaray/Projects/VoidBuildSystem/docs/agent-workflow/VERIFICATION.md).