Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fe31ebf56 | ||
|
|
9840cf6f3f | ||
|
|
b2c869961a | ||
|
|
00e14bae98 | ||
|
|
1f9a5d5804 | ||
|
|
eca1b8264e | ||
|
|
08cc7dc101 | ||
|
|
286b0044d5 | ||
|
|
b6b9527c9c | ||
|
|
ac5a7bf267 | ||
|
|
ed6b5dfdd3 | ||
|
|
20b0324d17 | ||
|
|
2f989f85ea | ||
|
|
4f70e0640c | ||
|
|
b92fd9b1fd | ||
|
|
566b5d3c5b | ||
|
|
f1e52467d7 | ||
|
|
0186711a90 | ||
|
|
c8eb950ca0 | ||
|
|
ca8770812e | ||
|
|
7930528970 | ||
|
|
adb7b4effe | ||
|
|
bd486c802c | ||
|
|
4e4698be7b | ||
|
|
51d437d339 | ||
|
|
a4e855f130 | ||
|
|
7ace7ead5a | ||
|
|
a8bb246095 | ||
|
|
67b89c7d3a | ||
|
|
951b55f67e | ||
|
|
7bdece0680 | ||
|
|
d5f2974cdd | ||
|
|
756fbb9a6b | ||
|
|
f3e6715af1 | ||
|
|
717ab93a99 | ||
|
|
3a69f33dfe | ||
|
|
d367331f85 | ||
|
|
8e3fffd636 | ||
|
|
e333bbe84b | ||
|
|
8768720e54 | ||
|
|
95801ccfd7 | ||
|
|
8b391af480 | ||
|
|
6fa70fb788 | ||
|
|
6129762cc6 | ||
|
|
dbe1b43e85 | ||
|
|
5e01bbf8a1 | ||
|
|
8fddffd127 | ||
|
|
76b15e79c4 | ||
|
|
c4d0783366 | ||
|
|
d95fb0d2f8 | ||
|
|
92c4be9273 | ||
|
|
d420732016 | ||
|
|
05c4aa62b3 | ||
|
|
c901d8d518 | ||
|
|
8e0dc8f1cc | ||
|
|
e17917be5e | ||
|
|
2dc0263e7b | ||
|
|
b7c224cf67 | ||
|
|
97709d37a5 | ||
|
|
a6dfa95ca2 | ||
|
|
fc79652ec4 | ||
|
|
8f06b8b386 | ||
|
|
c79f495013 |
No files matched your search
@@ -0,0 +1,17 @@
|
||||
# Cross-compiles VoidBuildSystem for 64-bit Windows (UCRT) with the MinGW-w64
|
||||
# toolchain on PATH (the Void CI `windows-gcc` image provides GCC 16).
|
||||
# The Wine CI lane runs the executables on Linux.
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
set(CMAKE_AR x86_64-w64-mingw32-ar)
|
||||
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
|
||||
|
||||
# Look for target libraries and headers in the MinGW sysroot, but run host
|
||||
# programs (cmake, ninja, python, ...) from the normal PATH.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# Ensure Ninja >= 1.11 (CMake needs it for C++20 module scanning).
|
||||
#
|
||||
# Tries, in order: the distribution package, the pip wheel, and the official
|
||||
# static release binary (installed into /usr/local/bin so it shadows an older
|
||||
# distro ninja).
|
||||
set -euo pipefail
|
||||
|
||||
minimum=1.11
|
||||
version_ok() {
|
||||
local have="${1:-0}"
|
||||
[ "$(printf '%s\n%s\n' "${minimum}" "${have}" | sort -V | head -n1)" = "${minimum}" ]
|
||||
}
|
||||
|
||||
have="$(ninja --version 2>/dev/null || echo 0)"
|
||||
if version_ok "${have}"; then
|
||||
echo "ninja ${have} already satisfies >= ${minimum}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sudo=""
|
||||
if [ "$(id -u)" -ne 0 ]; then sudo="sudo"; fi
|
||||
|
||||
# 1. Distribution package.
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
${sudo} apt-get update || true
|
||||
${sudo} apt-get install -y ninja-build || true
|
||||
hash -r
|
||||
fi
|
||||
have="$(ninja --version 2>/dev/null || echo 0)"
|
||||
if version_ok "${have}"; then
|
||||
echo "installed ninja ${have} from the distribution"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 2. pip wheel (installs into /usr/local/bin, which shadows the distro binary).
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python3 -m pip install --quiet --break-system-packages ninja ||
|
||||
python3 -m pip install --quiet ninja || true
|
||||
hash -r
|
||||
fi
|
||||
have="$(ninja --version 2>/dev/null || echo 0)"
|
||||
if version_ok "${have}"; then
|
||||
echo "installed ninja ${have} from pip"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3. Official static binary.
|
||||
release=1.12.1
|
||||
tmp="$(mktemp -d)"
|
||||
url="https://github.com/ninja-build/ninja/releases/download/v${release}/ninja-linux.zip"
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fsSL "${url}" -o "${tmp}/ninja.zip"
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -qO "${tmp}/ninja.zip" "${url}"
|
||||
else
|
||||
echo "curl or wget is required to download ninja" >&2
|
||||
exit 1
|
||||
fi
|
||||
python3 -c 'import sys, zipfile; zipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])' \
|
||||
"${tmp}/ninja.zip" "${tmp}"
|
||||
${sudo} install -m 0755 "${tmp}/ninja" /usr/local/bin/ninja
|
||||
hash -r
|
||||
have="$(ninja --version 2>/dev/null || echo 0)"
|
||||
if ! version_ok "${have}"; then
|
||||
echo "Ninja ${minimum}+ is required for C++20 module scanning (found ${have})" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "installed ninja ${have} from the official release"
|
||||
+460
-104
@@ -1,143 +1,499 @@
|
||||
# VoidBuildSystem CI (Gitea Actions).
|
||||
#
|
||||
# Runner: `linux` (host mode) - the machine with the documented dev toolchain:
|
||||
# dev cpp-gcc -c <cmd> (GCC 16.2, CMake, Ninja)
|
||||
# dev cpp -c <cmd> (Clang 23 + libFuzzer)
|
||||
# Optional steps add Nix packages with `dev ... -p <pkg>` (openssl, wine64, MinGW).
|
||||
# The generic `ubuntu-*` Docker runners have no GCC 16, so they are not used here.
|
||||
# Graph:
|
||||
#
|
||||
# 1. Requirements
|
||||
# 2A. Linux build (Debug, RelWithDebInfo, Sanitizers) -> 3A. Linux tests
|
||||
# 2B. Windows Wine build (Debug, RelWithDebInfo) -> 3B. Windows Wine tests
|
||||
# 4A/4B. Packages (one downloadable package per configuration)
|
||||
# 5. Release (RelWithDebInfo Linux + Windows packages)
|
||||
#
|
||||
# Runners: `vulkan` for the Linux lanes and `windows-gcc` for the Windows
|
||||
# (MinGW-w64 cross build + Wine) lane; both are the Void CI images
|
||||
# (git.faumaray.com/void/ci-images). `windows-clang` is not used because VBS's
|
||||
# C++26 reflection requires GCC.
|
||||
#
|
||||
# Jobs are isolated, so build outputs travel between stages as artifacts. The
|
||||
# artifact paths are uploaded relative to the build directory and restored under
|
||||
# the same workspace-relative location, keeping the absolute paths recorded in
|
||||
# the CTest files valid.
|
||||
#
|
||||
# The Windows lane cross-compiles VBS with MinGW-w64 and runs the resulting
|
||||
# executables under Wine, so no Windows runner is required.
|
||||
name: VoidBuildSystem CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
publish:
|
||||
description: "Create/publish the Gitea release (only for a v* tag ref)"
|
||||
required: false
|
||||
default: "false"
|
||||
tag:
|
||||
description: "Release tag to publish (empty: the pushed tag)"
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-and-test-gcc16:
|
||||
runs-on: linux
|
||||
requirements:
|
||||
name: "1 · Requirements"
|
||||
runs-on: vulkan
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check the dev toolchain
|
||||
- name: Check the toolchain
|
||||
run: |
|
||||
command -v dev || { echo "the 'dev' toolchain wrapper is required on this runner" >&2; exit 1; }
|
||||
dev cpp-gcc -c g++ --version | head -1
|
||||
- name: Configure (Debug, Ninja, GCC 16 C++26)
|
||||
run: |
|
||||
dev cpp-gcc -c cmake -S . -B build/ci-gcc -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build
|
||||
run: dev cpp-gcc -c cmake --build build/ci-gcc --parallel 4
|
||||
- name: Run CTest suites
|
||||
run: |
|
||||
set -o pipefail
|
||||
dev cpp-gcc -c ctest --test-dir build/ci-gcc --output-on-failure 2>&1 | tee ctest.log
|
||||
- name: Check formatting on owned C++ files
|
||||
run: |
|
||||
dev cpp-gcc -c clang-format --dry-run --Werror \
|
||||
build.cpp build.profiles.cpp build-support/*.hpp build-support/*.cpp \
|
||||
sdk/*.cpp include/Void/Build.hpp include/Void/Build/*/*.hpp \
|
||||
src/*.cpp src/*/*.cpp src/*/*/*.cpp \
|
||||
recipes/*/*.hpp recipes/*/*.cpp \
|
||||
registry/include/Void/Build/Registry/*.hpp registry/service/*.cpp registry/cli/*.cpp \
|
||||
benchmarks/*.cpp tests/*.cpp
|
||||
- name: Benchmark smoke run
|
||||
run: dev cpp-gcc -c build/ci-gcc/bin/vbs_benchmarks 15
|
||||
- name: Upload build artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-debug-linux-x86_64
|
||||
path: |
|
||||
build/ci-gcc/bin/vbs
|
||||
build/ci-gcc/bin/vbs-registry
|
||||
build/ci-gcc/bin/vbs_v1_tests
|
||||
build/ci-gcc/compile_commands.json
|
||||
ctest.log
|
||||
retention-days: 14
|
||||
|
||||
signing-openssl-gcc16:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure (Debug, Ninja, GCC 16 C++26, OpenSSL)
|
||||
run: |
|
||||
dev cpp-gcc -p openssl -c cmake -S . -B build/ci-openssl -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build vbs_v1_tests
|
||||
run: dev cpp-gcc -p openssl -c cmake --build build/ci-openssl --target vbs_v1_tests --parallel 4
|
||||
- name: Run Signing suite with the OpenSSL backend
|
||||
run: |
|
||||
output=$(dev cpp-gcc -p openssl -c build/ci-openssl/bin/vbs_v1_tests --suite Signing --no-color)
|
||||
printf '%s\n' "$output"
|
||||
if printf '%s\n' "$output" | grep -q 'SKIP'; then
|
||||
echo "Signing checks were skipped: the OpenSSL backend was not enabled" >&2
|
||||
g++ --version | head -1
|
||||
major="$(g++ -dumpversion | cut -d. -f1)"
|
||||
if [ "${major:-0}" -lt 16 ]; then
|
||||
echo "GCC 16 or newer is required for C++26 (found ${major:-unknown})" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo 'int main() { return 0; }' | g++ -std=c++26 -freflection -fsyntax-only -x c++ -
|
||||
cmake --version | head -1
|
||||
cmake_major="$(cmake --version | sed -nE 's/^cmake version ([0-9]+).*/\1/p')"
|
||||
if [ "${cmake_major:-0}" -lt 4 ]; then
|
||||
echo "CMake 4 or newer is required (found ${cmake_major:-unknown})" >&2
|
||||
exit 1
|
||||
fi
|
||||
bash .gitea/scripts/install-ninja.sh
|
||||
git --version
|
||||
|
||||
sanitizers-gcc16:
|
||||
runs-on: linux
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2A / 3A - Linux native
|
||||
# ---------------------------------------------------------------------------
|
||||
linux-build:
|
||||
name: "2A · Linux build (${{ matrix.variant }})"
|
||||
needs: requirements
|
||||
runs-on: vulkan
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- variant: debug
|
||||
build_type: Debug
|
||||
cxx_flags: ""
|
||||
linker_flags: ""
|
||||
- variant: relwithdebinfo
|
||||
build_type: RelWithDebInfo
|
||||
cxx_flags: ""
|
||||
linker_flags: ""
|
||||
- variant: sanitizers
|
||||
build_type: Debug
|
||||
cxx_flags: "-fsanitize=address,undefined -fno-omit-frame-pointer"
|
||||
linker_flags: "-fsanitize=address,undefined"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure with ASan + UBSan
|
||||
- name: Configure
|
||||
run: |
|
||||
dev cpp-gcc -c cmake -S . -B build/ci-asan -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" \
|
||||
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
|
||||
cmake -S . -B "build/linux-${{ matrix.variant }}" -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_CXX_COMPILER=g++ \
|
||||
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.linker_flags }}" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build
|
||||
run: dev cpp-gcc -c cmake --build build/ci-asan --parallel 4
|
||||
- name: Run sanitizer-safe suites
|
||||
run: cmake --build "build/linux-${{ matrix.variant }}" --parallel 4
|
||||
- name: Upload the build
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-linux-build-${{ matrix.variant }}
|
||||
path: |
|
||||
build/linux-${{ matrix.variant }}/bin/
|
||||
build/linux-${{ matrix.variant }}/CTestTestfile.cmake
|
||||
build/linux-${{ matrix.variant }}/tests/CTestTestfile.cmake
|
||||
build/linux-${{ matrix.variant }}/_deps/voidlibrary-src/
|
||||
!build/linux-${{ matrix.variant }}/_deps/voidlibrary-src/.git/
|
||||
build/linux-${{ matrix.variant }}/libVoidBuild_Sdk.a
|
||||
build/linux-${{ matrix.variant }}/compile_commands.json
|
||||
retention-days: 7
|
||||
|
||||
linux-test:
|
||||
name: "3A · Linux test (${{ matrix.variant }})"
|
||||
needs: linux-build
|
||||
runs-on: vulkan
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- variant: debug
|
||||
test_regex: ""
|
||||
- variant: relwithdebinfo
|
||||
test_regex: ""
|
||||
- variant: sanitizers
|
||||
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
||||
env:
|
||||
ASAN_OPTIONS: detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Jobs are fresh containers: the upgrade done by `requirements` does not carry over.
|
||||
- name: Ensure Ninja >= 1.11 (CMake module scanning in the suite)
|
||||
run: bash .gitea/scripts/install-ninja.sh
|
||||
- name: Download the build
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-linux-build-${{ matrix.variant }}
|
||||
path: build/linux-${{ matrix.variant }}
|
||||
- name: Make the restored binaries executable
|
||||
run: chmod +x "build/linux-${{ matrix.variant }}/bin/"*
|
||||
- name: Run CTest
|
||||
run: |
|
||||
dev cpp-gcc -c ctest --test-dir build/ci-asan -R "vbs_sdk_tests|vbs_core_tests" --output-on-failure
|
||||
- name: Upload sanitizer logs
|
||||
set -o pipefail
|
||||
if [ -n "${{ matrix.test_regex }}" ]; then
|
||||
ctest --test-dir "build/linux-${{ matrix.variant }}" --output-on-failure \
|
||||
--no-tests=error -R "${{ matrix.test_regex }}" 2>&1 | tee "ctest-linux-${{ matrix.variant }}.log"
|
||||
else
|
||||
ctest --test-dir "build/linux-${{ matrix.variant }}" --output-on-failure \
|
||||
--no-tests=error 2>&1 | tee "ctest-linux-${{ matrix.variant }}.log"
|
||||
fi
|
||||
- name: Benchmark smoke run
|
||||
if: matrix.variant == 'debug'
|
||||
run: build/linux-debug/bin/vbs_benchmarks --files 15
|
||||
- name: Upload the test log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-asan-ubsan-logs
|
||||
path: build/ci-asan/Testing/**/LastTest.log
|
||||
name: vbs-linux-test-${{ matrix.variant }}
|
||||
path: ctest-linux-${{ matrix.variant }}.log
|
||||
retention-days: 14
|
||||
|
||||
wine-windows-gcc16:
|
||||
runs-on: linux
|
||||
wine-build:
|
||||
name: "2B · Windows Wine build (${{ matrix.variant }})"
|
||||
needs: requirements
|
||||
runs-on: windows-gcc
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- variant: debug
|
||||
build_type: Debug
|
||||
- variant: relwithdebinfo
|
||||
build_type: RelWithDebInfo
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure (Debug, Ninja, GCC 16 C++26)
|
||||
- name: Configure
|
||||
run: |
|
||||
dev cpp-gcc -c cmake -S . -B build/ci-wine -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
- name: Build vbs and vbs_v1_tests
|
||||
run: dev cpp-gcc -c cmake --build build/ci-wine --target vbs vbs_v1_tests --parallel 4
|
||||
- name: Run the Windows target cross-build test under Wine
|
||||
cmake -S . -B "build/wine-${{ matrix.variant }}" -G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$PWD/.gitea/cmake/mingw-w64-toolchain.cmake" \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build
|
||||
run: cmake --build "build/wine-${{ matrix.variant }}" --parallel 4
|
||||
- name: Stage the MinGW runtime DLLs
|
||||
run: |
|
||||
dev cpp-gcc -p wine64 -p pkgsCross.mingwW64.stdenv.cc -c \
|
||||
build/ci-wine/bin/vbs_v1_tests \
|
||||
--filter track_c_windows_target_cross_build_and_wine_test --no-color
|
||||
for lib in libstdc++-6.dll libgcc_s_seh-1.dll libwinpthread-1.dll; do
|
||||
if [ -f "/usr/x86_64-w64-mingw32/bin/${lib}" ]; then
|
||||
cp "/usr/x86_64-w64-mingw32/bin/${lib}" \
|
||||
"build/wine-${{ matrix.variant }}/bin/"
|
||||
fi
|
||||
done
|
||||
- name: Upload the build
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-wine-build-${{ matrix.variant }}
|
||||
# Downstream jobs only run and package the binaries: no sources or
|
||||
# object files are needed, which keeps the artifact small.
|
||||
path: |
|
||||
build/wine-${{ matrix.variant }}/bin/
|
||||
build/wine-${{ matrix.variant }}/libVoidBuild_Sdk.a
|
||||
retention-days: 7
|
||||
|
||||
fuzz-clang:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure (Debug, Ninja)
|
||||
run: |
|
||||
dev cpp-gcc -c cmake -S . -B build/ci-fuzz -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
- name: Build vbs (for the VoidLibrary headers)
|
||||
run: dev cpp-gcc -c cmake --build build/ci-fuzz --target vbs --parallel 4
|
||||
- name: Fuzz the header-only parsers for 60 seconds
|
||||
wine-test:
|
||||
name: "3B · Windows Wine test (${{ matrix.variant }})"
|
||||
needs: wine-build
|
||||
runs-on: windows-gcc
|
||||
# The Wine-hosted suite is still maturing (parts of the Win32 runtime the
|
||||
# tests rely on are incomplete in Wine): it reports but does not block
|
||||
# packaging. Remove continue-on-error once the suite is green.
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- variant: debug
|
||||
- variant: relwithdebinfo
|
||||
env:
|
||||
VOID_INCLUDE_DIR: ${{ github.workspace }}/build/ci-fuzz/_deps/voidlibrary-src/include
|
||||
FUZZ_OUT: ${{ github.workspace }}/build/fuzz
|
||||
run: dev cpp -c bash fuzz/run.sh 60
|
||||
- name: Upload the fuzz corpus
|
||||
WINEDEBUG: "-all"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download the build
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-wine-build-${{ matrix.variant }}
|
||||
path: build/wine-${{ matrix.variant }}
|
||||
- name: Check Wine
|
||||
run: |
|
||||
if ! command -v wine >/dev/null 2>&1; then
|
||||
echo "wine is required to run the Windows test executables" >&2
|
||||
exit 1
|
||||
fi
|
||||
wine --version
|
||||
- name: Run the Windows test executables under Wine
|
||||
run: |
|
||||
# vbs_v1_tests / vbs_selfhost_tests drive the compiler and the shell, which
|
||||
# a Wine-hosted Windows process cannot execute; they run in the Linux lane
|
||||
# (and would run on a native Windows runner). The SDK/core suites cover
|
||||
# the Windows-hosted code that is meaningful under Wine.
|
||||
failed=""
|
||||
for exe in vbs_sdk_tests vbs_core_tests; do
|
||||
binary="build/wine-${{ matrix.variant }}/bin/${exe}.exe"
|
||||
if [ ! -f "${binary}" ]; then
|
||||
continue
|
||||
fi
|
||||
echo "== ${exe}"
|
||||
if ! wine "${binary}" --no-color 2>&1 | tee -a "ctest-wine-${{ matrix.variant }}.log"; then
|
||||
failed="${failed} ${exe}"
|
||||
fi
|
||||
done
|
||||
if [ -n "${failed}" ]; then
|
||||
echo "failing Windows test executables:${failed}" >&2
|
||||
exit 1
|
||||
fi
|
||||
- name: Upload the Wine log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-fuzz-corpus
|
||||
path: build/fuzz/corpus
|
||||
name: vbs-wine-test-${{ matrix.variant }}
|
||||
path: ctest-wine-${{ matrix.variant }}.log
|
||||
retention-days: 14
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 4A2 - the release installers, built and packaged by VBS itself
|
||||
# ---------------------------------------------------------------------------
|
||||
vbs-installers:
|
||||
name: "4A2 · VBS installers (linux target)"
|
||||
needs: linux-test
|
||||
runs-on: vulkan
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download the RelWithDebInfo build
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-linux-build-relwithdebinfo
|
||||
path: build/linux-relwithdebinfo
|
||||
- name: Make the restored binaries executable
|
||||
run: chmod +x build/linux-relwithdebinfo/bin/*
|
||||
- name: Build and package every installer format with VBS
|
||||
run: |
|
||||
set -eu
|
||||
set -o pipefail
|
||||
vbs=build/linux-relwithdebinfo/bin/vbs
|
||||
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
||||
label="${{ github.event.inputs.tag }}"
|
||||
if [ -z "${label}" ]; then
|
||||
case "${GITHUB_REF_NAME}" in
|
||||
v*) label="${GITHUB_REF_NAME}" ;;
|
||||
*) label="dev-$(printf '%s' "${GITHUB_SHA}" | cut -c1-7)" ;;
|
||||
esac
|
||||
fi
|
||||
out=dist-installers
|
||||
prefix="$(mktemp -d)"
|
||||
mkdir -p "${out}"
|
||||
build_dir="build/selfhost-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
|
||||
install_archive() {
|
||||
local fmt="$1" ext="$2"
|
||||
local attempt=1
|
||||
while true; do
|
||||
if "${vbs}" install --project . --build-dir "${build_dir}" --profile release \
|
||||
--jobs 4 --prefix "${prefix}" --package-name VoidBuildSystem \
|
||||
--package-version "${version}" \
|
||||
--archive "${out}/vbs-${label}-linux-x86_64-${fmt}.${ext}" \
|
||||
--archive-format "${fmt}" 2>&1 | tee -a installers-linux.log; then
|
||||
return 0
|
||||
fi
|
||||
if [ "${attempt}" -ge 2 ]; then
|
||||
echo "vbs install (${fmt}) failed after retry" >&2
|
||||
return 1
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
build_dir="${build_dir}-retry${attempt}"
|
||||
echo "retrying vbs install (${fmt}) in '${build_dir}'..." >&2
|
||||
done
|
||||
}
|
||||
for fmt in tar sh zip deb rpm wix dmg nuget; do
|
||||
case "${fmt}" in
|
||||
tar) ext=tar ;;
|
||||
wix) ext=wxs ;;
|
||||
nuget) ext=nupkg ;;
|
||||
*) ext="${fmt}" ;;
|
||||
esac
|
||||
install_archive "${fmt}" "${ext}"
|
||||
done
|
||||
ls -l "${out}/"
|
||||
- name: Upload the installer log
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-linux-log
|
||||
path: installers-linux.log
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
- name: Collect installer diagnostics
|
||||
if: failure()
|
||||
run: |
|
||||
echo "== first errors (compact)"
|
||||
grep -m 10 -E 'error:|undefined reference|Killed|internal compiler' \
|
||||
installers-linux.log 2>/dev/null | cut -c1-240 || true
|
||||
df -h . || true
|
||||
for tree in $(find build/selfhost-* -type d -path '*snapshots/trees/*' \
|
||||
-not -name '*.staging_*' 2>/dev/null); do
|
||||
echo "== ${tree}"
|
||||
echo "files on disk: $(find "${tree}" -type f | wc -l)"
|
||||
ls "${tree}/src/Log" 2>/dev/null | head -5
|
||||
done
|
||||
- name: Upload the installers
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-linux-relwithdebinfo
|
||||
path: dist-installers/
|
||||
retention-days: 30
|
||||
|
||||
vbs-installers-windows:
|
||||
name: "4A2 · VBS installers (windows target)"
|
||||
needs: linux-test
|
||||
runs-on: windows-gcc
|
||||
# Cross-installing for Windows through VBS is new: report it without
|
||||
# blocking the release until it is proven.
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download the RelWithDebInfo build
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-linux-build-relwithdebinfo
|
||||
path: build/linux-relwithdebinfo
|
||||
- name: Make the restored binaries executable
|
||||
run: chmod +x build/linux-relwithdebinfo/bin/*
|
||||
- name: Build and package the Windows installers with VBS
|
||||
run: |
|
||||
set -eu
|
||||
set -o pipefail
|
||||
vbs=build/linux-relwithdebinfo/bin/vbs
|
||||
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
||||
label="${{ github.event.inputs.tag }}"
|
||||
if [ -z "${label}" ]; then
|
||||
case "${GITHUB_REF_NAME}" in
|
||||
v*) label="${GITHUB_REF_NAME}" ;;
|
||||
*) label="dev-$(printf '%s' "${GITHUB_SHA}" | cut -c1-7)" ;;
|
||||
esac
|
||||
fi
|
||||
out=dist-installers-windows
|
||||
prefix="$(mktemp -d)"
|
||||
mkdir -p "${out}"
|
||||
build_dir="build/selfhost-windows-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-1}"
|
||||
for fmt in tar zip nuget wix; do
|
||||
case "${fmt}" in
|
||||
tar) ext=tar ;;
|
||||
wix) ext=wxs ;;
|
||||
nuget) ext=nupkg ;;
|
||||
*) ext="${fmt}" ;;
|
||||
esac
|
||||
"${vbs}" install --project . --build-dir "${build_dir}" --profile release \
|
||||
--jobs 4 --target-os windows --target-arch x86_64 \
|
||||
--prefix "${prefix}" --package-name VoidBuildSystem \
|
||||
--package-version "${version}" \
|
||||
--archive "${out}/vbs-${label}-windows-x86_64-${fmt}.${ext}" \
|
||||
--archive-format "${fmt}" 2>&1 | tee -a installers-windows.log
|
||||
done
|
||||
ls -l "${out}/"
|
||||
- name: Upload the installer log
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-windows-log
|
||||
path: installers-windows.log
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
- name: Collect Windows installer diagnostics
|
||||
if: failure()
|
||||
run: |
|
||||
echo "== first errors (compact)"
|
||||
grep -m 10 -E 'error:|undefined reference|Killed|internal compiler' \
|
||||
installers-windows.log 2>/dev/null | cut -c1-240 || true
|
||||
- name: Upload the Windows installers
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-windows-relwithdebinfo
|
||||
path: dist-installers-windows/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 30
|
||||
|
||||
release:
|
||||
name: "5 · Release"
|
||||
# Linked to every package lane and only dispatched for a release tag or an
|
||||
# explicit publish dispatch (always() would queue the job on every push).
|
||||
needs: [vbs-installers, vbs-installers-windows]
|
||||
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish == 'true'
|
||||
runs-on: vulkan
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download the Linux installers
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-linux-relwithdebinfo
|
||||
path: dist
|
||||
- name: Download the Windows installers (when available)
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: vbs-installers-windows-relwithdebinfo
|
||||
path: dist
|
||||
- name: Verify the tag matches the project version
|
||||
run: |
|
||||
tag="${{ github.event.inputs.tag }}"
|
||||
if [ -z "${tag}" ]; then tag="${GITHUB_REF_NAME}"; fi
|
||||
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
||||
echo "tag=${tag} project version=${version}"
|
||||
case "${tag}" in
|
||||
v*) ;;
|
||||
*) echo "not a release tag (${tag}); skipping the version check" ; exit 0 ;;
|
||||
esac
|
||||
if [ "${tag#v}" != "${version}" ]; then
|
||||
echo "tag ${tag} does not match the project version ${version}" >&2
|
||||
exit 1
|
||||
fi
|
||||
- name: Publish the Gitea release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
tag="${{ github.event.inputs.tag }}"
|
||||
if [ -z "${tag}" ]; then tag="${GITHUB_REF_NAME}"; fi
|
||||
case "${tag}" in
|
||||
v*) ;;
|
||||
*) echo "not a release tag (${tag}); skipping the release upload" ; exit 0 ;;
|
||||
esac
|
||||
rm -f dist/SHA256SUMS
|
||||
(cd dist && sha256sum ./* > SHA256SUMS)
|
||||
ls -l dist/
|
||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")"
|
||||
payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \
|
||||
"${tag}" "${tag}" "${body}")"
|
||||
extract_id() {
|
||||
python3 -c 'import json,sys; s=sys.stdin.read().strip(); print(json.loads(s).get("id","") if s else "")' 2>/dev/null || true
|
||||
}
|
||||
# The release may already exist (e.g. created by hand for the tag): fall back to it.
|
||||
created="$(curl -sS -X POST -H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" -d "${payload}" "${api}/releases" || true)"
|
||||
release_id="$(printf '%s' "${created}" | extract_id)"
|
||||
if [ -z "${release_id}" ]; then
|
||||
existing="$(curl -sS -H "Authorization: token ${TOKEN}" \
|
||||
"${api}/releases/tags/${tag}" || true)"
|
||||
release_id="$(printf '%s' "${existing}" | extract_id)"
|
||||
fi
|
||||
test -n "${release_id}"
|
||||
for file in dist/*; do
|
||||
name="$(basename "${file}")"
|
||||
curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
|
||||
-F "attachment=@${file}" "${api}/releases/${release_id}/assets?name=${name}" >/dev/null
|
||||
echo "uploaded ${name}"
|
||||
done
|
||||
@@ -0,0 +1,23 @@
|
||||
# Temporary diagnostic workflow: can the ubuntu runner install the required toolchain?
|
||||
name: Probe runner
|
||||
on:
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
probe:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install GCC 16 and CMake 4
|
||||
run: |
|
||||
set -x
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y software-properties-common wget gpg ninja-build
|
||||
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
wget -qO- https://apt.kitware.com/keys/kitware-archive-latest.asc | \
|
||||
gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
|
||||
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | \
|
||||
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
|
||||
sudo apt-get update
|
||||
apt-cache policy g++-16 gcc-16 cmake | head -24 || true
|
||||
sudo apt-get install -y g++-16 cmake
|
||||
g++-16 --version | head -1
|
||||
cmake --version | head -1
|
||||
@@ -1,99 +0,0 @@
|
||||
# VoidBuildSystem release (Gitea Actions).
|
||||
#
|
||||
# Triggered by a `v*` tag. Builds a Release configuration, runs the full suite, packages
|
||||
# binaries, the SDK and the deterministic source archive, uploads them as CI artifacts, and
|
||||
# creates (or updates) the Gitea release with the same files attached.
|
||||
#
|
||||
# Runner: `linux` (host) for the dev toolchain (`dev cpp-gcc -c ...`); the release upload uses
|
||||
# the automatically provided GITHUB_TOKEN with repository write access.
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: linux
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check the dev toolchain
|
||||
run: |
|
||||
command -v dev || { echo "the 'dev' toolchain wrapper is required on this runner" >&2; exit 1; }
|
||||
- name: Verify the tag matches the project version
|
||||
run: |
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
version="$(sed -nE 's/^project\(VoidBuildSystem VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)"
|
||||
echo "tag=${tag} project version=${version}"
|
||||
if [ "${tag#v}" != "${version}" ]; then
|
||||
echo "tag ${tag} does not match the project version ${version}" >&2
|
||||
exit 1
|
||||
fi
|
||||
- name: Configure (Release, Ninja)
|
||||
run: |
|
||||
dev cpp-gcc -c cmake -S . -B build/release -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
- name: Build
|
||||
run: dev cpp-gcc -c cmake --build build/release --parallel 4
|
||||
- name: Run the full suite
|
||||
run: |
|
||||
set -o pipefail
|
||||
dev cpp-gcc -c ctest --test-dir build/release --output-on-failure 2>&1 | tee ctest-release.log
|
||||
- name: Package binaries, SDK and source
|
||||
run: |
|
||||
set -eu
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
stage="$(mktemp -d)"
|
||||
mkdir -p "${stage}/bin" "${stage}/include" "${stage}/lib" "dist"
|
||||
cp build/release/bin/vbs build/release/bin/vbs-registry "${stage}/bin/"
|
||||
cp -r include/Void "${stage}/include/"
|
||||
cp build/release/libVoidBuild_Sdk.a "${stage}/lib/" 2>/dev/null || \
|
||||
find build/release -name 'libVoidBuild_Sdk.a' -exec cp {} "${stage}/lib/" \;
|
||||
cp README.md "${stage}/"
|
||||
tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \
|
||||
-czf "dist/vbs-${tag}-linux-x86_64.tar.gz" -C "${stage}" .
|
||||
build/release/bin/vbs pack --project . --output "dist/vbs-${tag}-source.tar" \
|
||||
|| tar --sort=name --mtime='@0' --owner=0 --group=0 --numeric-owner \
|
||||
--exclude=.git --exclude=build --exclude=.vbs \
|
||||
-czf "dist/vbs-${tag}-source.tar.gz" .
|
||||
cp ctest-release.log dist/
|
||||
sha256sum dist/* > dist/SHA256SUMS
|
||||
ls -l dist/
|
||||
- name: Upload release artifacts
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: vbs-release-${{ github.ref_name }}
|
||||
path: dist/
|
||||
retention-days: 30
|
||||
- name: Publish the Gitea release
|
||||
if: success()
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")"
|
||||
payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \
|
||||
"${tag}" "${tag}" "${body}")"
|
||||
release_id="$(curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" -d "${payload}" \
|
||||
"${api}/releases" | sed -nE 's/.*"id":([0-9]+).*/\1/p' | head -1)"
|
||||
if [ -z "${release_id}" ]; then
|
||||
release_id="$(curl -fsS -H "Authorization: token ${TOKEN}" \
|
||||
"${api}/releases/tags/${tag}" | sed -nE 's/.*"id":([0-9]+).*/\1/p' | head -1)"
|
||||
fi
|
||||
test -n "${release_id}"
|
||||
for file in dist/*; do
|
||||
name="$(basename "${file}")"
|
||||
curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
|
||||
-F "attachment=@${file}" "${api}/releases/${release_id}/assets?name=${name}" >/dev/null
|
||||
echo "uploaded ${name}"
|
||||
done
|
||||
@@ -22,3 +22,6 @@ CMakeUserPresets.json
|
||||
*.swp
|
||||
*~
|
||||
.DS_Store
|
||||
|
||||
# Release artifacts (built locally or by the release workflow)
|
||||
dist/
|
||||
+30
-10
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidBuildSystem VERSION 0.1.0 LANGUAGES CXX)
|
||||
project(VoidBuildSystem VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
|
||||
message(FATAL_ERROR
|
||||
@@ -18,7 +18,12 @@ endif()
|
||||
option(VBS_BUILD_TESTS "Build declaration SDK and native engine test suites" ON)
|
||||
option(VBS_BUILD_BENCHMARKS "Build reproducible VBS benchmark harness" ON)
|
||||
set(VBS_VOID_SOURCE_DIR "" CACHE PATH "Development-only VoidLibrary source override (bypasses pin)")
|
||||
set(VBS_VOID_REVISION "0002e74a7da94a756f55a4a5574d20b77736c185")
|
||||
set(VBS_VOID_REVISION "1b1947340f8080dbf457d4218cbbee1743f8438d")
|
||||
if(WIN32)
|
||||
# Target Windows 10 APIs: MinGW headers only declare e.g. DUPLICATE_EXTENTS_DATA
|
||||
# (used by VoidLibrary's reflink copy) at a modern _WIN32_WINNT/NTDDI_VERSION.
|
||||
add_compile_definitions(_WIN32_WINNT=0x0A00 NTDDI_VERSION=0x0A000000)
|
||||
endif()
|
||||
include(cmake/VoidDependency.cmake)
|
||||
vbs_add_void_dependency()
|
||||
|
||||
@@ -51,6 +56,7 @@ add_library(VoidBuild_Core STATIC
|
||||
src/Config/Scaffold.cpp
|
||||
src/Daemon/Daemon.cpp
|
||||
src/Report/Cdash.cpp
|
||||
src/Report/Coverage.cpp
|
||||
src/Editor/CompDb.cpp
|
||||
src/Watch/Linux/Watcher.cpp
|
||||
src/Package/Toml.cpp
|
||||
@@ -89,6 +95,10 @@ target_link_libraries(VoidBuild_Core PUBLIC
|
||||
Void::Archive
|
||||
Void::Log)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_CRYPTO=1 VBS_HAS_VOID_ARCHIVE=1)
|
||||
if(WIN32)
|
||||
# Winsock for the registry client and the native Windows HTTP fallbacks.
|
||||
target_link_libraries(VoidBuild_Core PUBLIC ws2_32)
|
||||
endif()
|
||||
if(VBS_HAS_VOID_SQLITE)
|
||||
target_link_libraries(VoidBuild_Core PUBLIC Void::Sqlite)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_SQLITE=1)
|
||||
@@ -98,12 +108,16 @@ if(VBS_HAS_VOID_NET)
|
||||
target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_NET=1)
|
||||
endif()
|
||||
|
||||
add_library(VoidBuild_Registry STATIC
|
||||
if(NOT WIN32)
|
||||
# The registry service uses a POSIX socket loop; its Windows port (named pipes
|
||||
# or Winsock) is Track C3 work.
|
||||
add_library(VoidBuild_Registry STATIC
|
||||
registry/service/HttpServer.cpp
|
||||
registry/service/RegistryService.cpp)
|
||||
add_library(Void::BuildRegistry ALIAS VoidBuild_Registry)
|
||||
target_include_directories(VoidBuild_Registry PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/registry/include")
|
||||
target_link_libraries(VoidBuild_Registry PUBLIC Void::BuildCore)
|
||||
add_library(Void::BuildRegistry ALIAS VoidBuild_Registry)
|
||||
target_include_directories(VoidBuild_Registry PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/registry/include")
|
||||
target_link_libraries(VoidBuild_Registry PUBLIC Void::BuildCore)
|
||||
endif()
|
||||
|
||||
configure_file(cmake/BootstrapConfig.hpp.in generated/Void/Build/BootstrapConfig.hpp @ONLY)
|
||||
|
||||
@@ -111,9 +125,11 @@ add_executable(vbs src/Main.cpp)
|
||||
target_include_directories(vbs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs PRIVATE Void::BuildCore)
|
||||
|
||||
add_executable(vbs-registry registry/cli/Main.cpp)
|
||||
target_include_directories(vbs-registry PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs-registry PRIVATE Void::BuildRegistry)
|
||||
if(NOT WIN32)
|
||||
add_executable(vbs-registry registry/cli/Main.cpp)
|
||||
target_include_directories(vbs-registry PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs-registry PRIVATE Void::BuildRegistry)
|
||||
endif()
|
||||
|
||||
add_library(VoidBuild_ExampleDescription STATIC
|
||||
build.cpp
|
||||
@@ -126,8 +142,12 @@ add_executable(vbs_describe src/Describe.cpp)
|
||||
target_include_directories(vbs_describe PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_describe PRIVATE VoidBuild_ExampleDescription Void::Configuration)
|
||||
|
||||
set_target_properties(vbs vbs-registry vbs_describe PROPERTIES
|
||||
set_target_properties(vbs vbs_describe PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
if(TARGET vbs-registry)
|
||||
set_target_properties(vbs-registry PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
endif()
|
||||
|
||||
if(VBS_BUILD_BENCHMARKS)
|
||||
add_executable(vbs_benchmarks benchmarks/EngineBenchmarks.cpp)
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
#include "build-support/Defaults.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
|
||||
// The profile context carries the target OS as written on the command line
|
||||
// ("windows") or as the host name ("Windows"): compare case-insensitively.
|
||||
bool targets_windows(const Void::Build::ProfileContext &ctx) {
|
||||
std::string os = ctx.os;
|
||||
std::ranges::transform(os, os.begin(),
|
||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
return os == "windows";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void build(Void::Build::Project &project) {
|
||||
const auto &ctx = project.context();
|
||||
|
||||
auto library = project.dependency("VoidLibrary");
|
||||
library
|
||||
.git("https://git.faumaray.com/Void/VoidLibrary.git",
|
||||
Void::Build::Commit{"0002e74a7da94a756f55a4a5574d20b77736c185"})
|
||||
Void::Build::Commit{"1b1947340f8080dbf457d4218cbbee1743f8438d"})
|
||||
.native_builder({{"VOID_ENABLED_MODULES",
|
||||
"Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing;Log"},
|
||||
// Only the Testing library is needed, not VoidLibrary's own test
|
||||
// executables (the CMake path sets VOID_ENABLE_TESTING=OFF too).
|
||||
{"VOID_ENABLE_TESTING", "0"},
|
||||
{"BUILD_SHARED_LIBS", false}});
|
||||
|
||||
// Source membership comes from conventions and globs, not explicit file lists:
|
||||
@@ -24,8 +44,12 @@ void build(Void::Build::Project &project) {
|
||||
}
|
||||
|
||||
auto core = project.static_library("VoidBuildCore");
|
||||
// The entry points (src/Main.cpp, src/Describe.cpp) are not part of the core
|
||||
// library: they define main() and Describe.cpp references the example
|
||||
// description's build()/profiles(). Glob only the subdirectories.
|
||||
core.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources(project.glob("src/**/*.cpp"))
|
||||
.sources(project.glob("src/*/*.cpp"))
|
||||
.sources(project.glob("src/*/*/*.cpp"))
|
||||
.sources(project.glob("recipes/**/*.cpp"))
|
||||
.include_directory("include", Void::Build::Visibility::Public)
|
||||
.include_directory("recipes", Void::Build::Visibility::Public)
|
||||
@@ -41,6 +65,11 @@ void build(Void::Build::Project &project) {
|
||||
.link(library.target("Void::Crypto"), Void::Build::Visibility::Public)
|
||||
.link(library.target("Void::Archive"), Void::Build::Visibility::Public)
|
||||
.link(library.target("Void::Log"), Void::Build::Visibility::Public);
|
||||
if (targets_windows(ctx)) {
|
||||
// Winsock for the registry client and the native Windows HTTP fallbacks.
|
||||
// Public: link options of a static library do not reach the final link otherwise.
|
||||
core.link_option("-lws2_32", Void::Build::Visibility::Public);
|
||||
}
|
||||
BuildSupport::compiler_warnings(core, ctx);
|
||||
|
||||
// Generate profile-isolated BootstrapConfig.hpp inside $GEN/include/Void/Build/.
|
||||
@@ -51,7 +80,7 @@ void build(Void::Build::Project &project) {
|
||||
"#pragma once\n"
|
||||
"#include <string_view>\n"
|
||||
"namespace Void::Build::Bootstrap {\n"
|
||||
"inline constexpr std::string_view version = \"0.1.0\";\n"
|
||||
"inline constexpr std::string_view version = \"1.0.0\";\n"
|
||||
"inline constexpr std::string_view os = \"" +
|
||||
ctx.os +
|
||||
"\";\n"
|
||||
@@ -80,6 +109,8 @@ void build(Void::Build::Project &project) {
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(cli, ctx);
|
||||
|
||||
// The registry service is POSIX-only until its Track C3 Windows port lands.
|
||||
if (!targets_windows(ctx)) {
|
||||
auto registry_lib = project.static_library("VoidBuildRegistry");
|
||||
registry_lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources(project.glob("registry/service/*.cpp"))
|
||||
@@ -96,6 +127,17 @@ void build(Void::Build::Project &project) {
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(registry_cli, ctx);
|
||||
|
||||
auto reg_tests = project.test("vbs_registry_tests");
|
||||
reg_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/RegistryTests.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.depends_on(cli)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(reg_tests, ctx);
|
||||
}
|
||||
|
||||
auto smoke_test = project.test("vbs_self_smoke");
|
||||
smoke_test.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/SelfBuildSmoke.cpp"})
|
||||
@@ -139,16 +181,6 @@ void build(Void::Build::Project &project) {
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(v1_tests, ctx);
|
||||
|
||||
auto reg_tests = project.test("vbs_registry_tests");
|
||||
reg_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/RegistryTests.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.depends_on(cli)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.link(library.target("Void::Testing"));
|
||||
BuildSupport::compiler_warnings(reg_tests, ctx);
|
||||
|
||||
auto selfhost_tests = project.test("vbs_selfhost_tests");
|
||||
selfhost_tests.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/SelfHostTests.cpp"})
|
||||
|
||||
@@ -11,15 +11,11 @@ function(vbs_add_void_dependency)
|
||||
list(APPEND VOID_ENABLED_MODULES Testing)
|
||||
endif()
|
||||
|
||||
# Crypto (VL-007) and Archive (VL-006) now work with zero external dependencies in VoidLibrary;
|
||||
# Sqlite remains opportunistic when system SQLite3 is installed.
|
||||
find_package(SQLite3 QUIET)
|
||||
if(SQLite3_FOUND)
|
||||
# Crypto (VL-007) and Archive (VL-006) work with zero external dependencies.
|
||||
# Sqlite: Void resolves its own backend (system SQLite3, the vendored
|
||||
# amalgamation, or its FetchContent fallback), so it is always available.
|
||||
list(APPEND VOID_ENABLED_MODULES Sqlite)
|
||||
set(VBS_HAS_VOID_SQLITE ON PARENT_SCOPE)
|
||||
else()
|
||||
set(VBS_HAS_VOID_SQLITE OFF PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# Void::Net (Track E4) needs Boost url/beast/asio and OpenSSL; enable it only when the
|
||||
# environment actually provides both, so minimal shells keep the pure-POSIX transport.
|
||||
|
||||
@@ -377,6 +377,12 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
|
||||
- **Wave 142 (Gitea CI with Artifacts & Release Workflow)**: CI moved from the unused GitHub location to `.gitea/workflows/ci.yml`, targeting the real dev toolchain (`dev cpp-gcc`) and uploading build binaries, the compile database and the CTest log as artifacts (plus sanitizer logs and the fuzz corpus). `.gitea/workflows/release.yml` builds Release on `v*` tags, verifies the tag against the CMake project version, runs the full suite, packages the binaries/SDK, a `vbs pack` source archive and `SHA256SUMS`, uploads them, and creates the Gitea release with the assets attached via the API. Both workflows pass `yamllint`; they remain unexecuted without a runner.
|
||||
|
||||
- **Wave 143 (First Release v0.1.0)**: the Release build (Ninja, GCC 16.2) passed the full suite (8/8, 271.91 s) and the release packaging produced `dist/vbs-v0.1.0-linux-x86_64.tar.gz` (binaries + SDK + headers), `dist/vbs-v0.1.0-source.tar` (`vbs pack`) and `SHA256SUMS`. Tag `v0.1.0` and the [first Gitea release](https://git.faumaray.com/Void/Build-System/releases/tag/v0.1.0) were created; the workflows now target the available Gitea runners (`linux` host). Binary assets cannot be uploaded through the available tooling - the release workflow attaches them when it runs.
|
||||
|
||||
- **Wave 144 (NuGet Package Generator)**: `vbs install --archive FILE --archive-format nuget` writes a `.nupkg` - an OPC ZIP with the `<id>.nuspec` manifest, `[Content_Types].xml`, `_rels/.rels` and the installed files mapped to `runtimes/<rid>/native/**` (headers under `build/native/include`). The RID comes from the profile (e.g. `linux-x64`). Python `zipfile` + ElementTree validate the generated package (id/version/authors parse, CRCs clean); the install test asserts the manifest, layout and native asset paths.
|
||||
|
||||
- **Wave 145 (Coverage Reporting)**: `vbs test --coverage DIR` instruments every compile and link with `--coverage`, runs the tests, and converts the gcov JSON data into `DIR/coverage.info` (lcov) and `DIR/summary.txt`. System headers outside the project root are filtered out. `FullV1Tests.test_coverage_writes_lcov_and_summary` builds a library with a covered and an uncovered function and asserts `DA:1,1`, `DA:2,0` and the summary. A fresh-tree bug (a transient filesystem error aborting the .gcda walk) was found and fixed.
|
||||
|
||||
## Remaining future scope
|
||||
|
||||
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
|
||||
|
||||
@@ -143,4 +143,6 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 140 (pkg-config discovery) | `.pkgconfig(spec)` dependency, `.pc` parser with variables/Requires/version compare, lock entries | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; E2E builds/runs and checks version errors, full CTest 8/8) | `include/Void/Build.hpp`, `sdk/Build.cpp`, `src/Provider/PkgConfig.cpp`, `src/Graph/Graph.cpp`, `src/Package/Resolver.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 141 (ASM + shader languages) | `.s`/`.S` assembly; `shader_bundle`/`.shader()` lowered to SPIR-V (glslang/slangc/dxc) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; both E2Es pass, GLSL/Slang/HLSL produce SPIR-V, full CTest 8/8) | `src/Graph/Graph.cpp`, `src/Toolchain/Driver.cpp`, `include/Void/Build.hpp`, `sdk/Build.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 142 (Gitea CI + release workflow) | Gitea-hosted CI with artifacts; tag-driven release workflow with asset upload | COMPLETE (YAML-validated; unexecuted without a runner) | `.gitea/workflows/ci.yml`, `.gitea/workflows/release.yml`, docs |
|
||||
| Wave 144 (NuGet generator) | `--archive-format nuget`: `.nupkg` with nuspec, OPC parts and `runtimes/<rid>/native` assets | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Python validates the package, install test passes, full CTest 8/8) | `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Wave 145 (Coverage reporting) | `vbs test --coverage DIR`; gcov JSON -> lcov + summary | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; E2E passes, full CTest 8/8) | `include/Void/Build/Report/Coverage.hpp`, `src/Report/Coverage.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs |
|
||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
||||
@@ -1850,6 +1850,25 @@ VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30
|
||||
manually to valid SPIR-V in this environment.
|
||||
- Full CTest: **8 / 8 passed** in 314.56 s.
|
||||
|
||||
## NuGet Package Generation (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- `vbs install --archive cli_hi.nupkg --archive-format nuget` produced a 7-entry ZIP whose
|
||||
nuspec, `[Content_Types].xml` and `_rels/.rels` all parse with ElementTree, every CRC is
|
||||
clean (`zipfile.testzip()` is None), and native assets live under
|
||||
`runtimes/linux-x64/native/`.
|
||||
- `FullV1Tests.foreign_cmake_meson_providers_bridge_and_relocatable_install` asserts the ZIP
|
||||
magic, the nuspec id/version, the OPC parts and the runtime asset paths (**passed**, 6.36 s).
|
||||
- Full CTest: **8 / 8 passed** in 337.44 s.
|
||||
|
||||
## Coverage Reporting (GCC 16.2, pin `0002e74`)
|
||||
|
||||
- `vbs test --coverage DIR` adds `--coverage` to the profile compile and link options, runs the
|
||||
tests, and writes `DIR/coverage.info` (lcov) plus `DIR/summary.txt` from gcov's JSON output.
|
||||
- `FullV1Tests.test_coverage_writes_lcov_and_summary` **passed** (2.66 s): the report contains
|
||||
`SF:` records for both sources, `DA:1,1` (executed function) and `DA:2,0` (uncovered
|
||||
function), `end_of_record`, and a summary starting with `Coverage: ` and containing `%`.
|
||||
- Full CTest: **8 / 8 passed** in 352.77 s.
|
||||
|
||||
## Limits and Unrun Checks
|
||||
|
||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||
|
||||
@@ -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.
|
||||
@@ -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).
|
||||
@@ -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)
|
||||
@@ -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).
|
||||
@@ -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).
|
||||
@@ -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).
|
||||
@@ -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).
|
||||
@@ -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).
|
||||
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: Architecture and Control Flow
|
||||
description: The layers, libraries and invariants behind VoidBuildSystem's configuration, execution, packaging and registry paths
|
||||
section: Architecture
|
||||
badge: design
|
||||
order: 1
|
||||
tags: [architecture, layers, components, invariants, control-flow, source-map]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Architecture and Control Flow
|
||||
|
||||
VoidBuildSystem is one binary (`vbs`) plus two support binaries (`vbs-registry`, `vbs_describe`) and a static SDK (`libVoidBuildSdk.a`). It is built on VoidLibrary for configuration, text, Unicode, concurrency, crypto, archives, logging, filesystem and process primitives. The project has two build front ends for its own source: a CMake bootstrap and a zero-CMake `build.cpp` that builds the same targets.
|
||||
|
||||
## End-to-end flow
|
||||
|
||||
:::flow
|
||||
CLI → host descriptor → profiles → dependency resolution → immutable snapshot → graph lowering → scheduler → CAS publication → editor/daemon projections
|
||||
:::
|
||||
|
||||
1. **Select roots and profiles.** The CLI resolves absolute project and build roots, loads the lockfile, discovers profiles, and pins a target OS/architecture and compiler family.
|
||||
2. **Compile the description.** `build.cpp`, optional `build.profiles.cpp`, `build-support/**/*.cpp` and explicit `--build-source` files are compiled into a cached host executable against the fixed SDK. Configuration helpers are found by filesystem membership, not Git or a package graph.
|
||||
3. **Evaluate out of process.** For each resolved `ProfileContext`, the descriptor writes one versioned JSON `ProjectDescription` to a private result file. stdout/stderr cannot corrupt the protocol.
|
||||
4. **Resolve dependencies.** Inline C++ and TOML declarations merge, registry constraints solve, sources materialize and providers return typed `ImportedTargetInterface` values. The lock context is validated or republished.
|
||||
5. **Capture a snapshot.** Declared source/include/search roots are captured into an immutable snapshot with content hashes, resolved symlinks, absence/lookup guards and isolated materialized bytes.
|
||||
6. **Lower the graph.** Targets are validated, usage requirements are resolved transitively, modules are scanned/collated, and every target becomes typed actions: compile, PCH, header unit, module scan, BMI, archive, link or custom.
|
||||
7. **Execute.** The scheduler runs the selected action closure with bounded parallelism, process-group supervision, depfile discovery, CAS lookup/publication and cancellation.
|
||||
8. **Project metadata.** The same graph drives `compile_commands.json`, CMake File API replies, editor presets, IDE query JSON and daemon responses.
|
||||
|
||||
## Component map
|
||||
|
||||
| Area | Primary code | Responsibility |
|
||||
| --- | --- | --- |
|
||||
| Declaration SDK | `include/Void/Build.hpp`, `sdk/Build.cpp`, `sdk/Json.cpp` | Targets, profiles, dependencies, workspaces, deterministic JSON |
|
||||
| Configuration frontend | `src/Config/Frontend.cpp`, `Presets.cpp`, `CmakeImport.cpp`, `Scaffold.cpp`, `BuildTree.cpp` | Descriptor compilation, profile discovery/evaluation, presets, `vbs init`, `vbs migrate`, clean |
|
||||
| Graph | `src/Graph/Graph.cpp` | Target validation, usage propagation, source expansion, action lowering, output layout |
|
||||
| Toolchain | `src/Toolchain/Driver.cpp` | Compiler discovery, capability probes, C/C++/ASM commands, modules, PCH, LTO, sanitizers |
|
||||
| Snapshot | `src/Snapshot/Snapshot.cpp` | Namespace capture, hashing, reflink/copy isolation, lookup guards |
|
||||
| Execution | `src/Execution/Scheduler.cpp` | DAG scheduling, parallelism, cache lookup, depfiles, cancellation |
|
||||
| State | `src/State/StateStore.cpp`, `RemoteCache.cpp` | Local CAS, action records, generations, leases, GC, remote CAS |
|
||||
| Editor | `src/Editor/CompDb.cpp` | Compilation databases, selection tickets, editor presets, File API shim, plugin assets |
|
||||
| Modules | `src/Modules/ModuleScanner.cpp` | P1689 scan, BMI collation, header units, unity exclusions |
|
||||
| Packages | `src/Package/{Toml,Solver,Lockfile,Archive,Fetch,Resolver,RegistryClient}.cpp` | Manifest model, solver, lock CAS, verification, providers' inputs |
|
||||
| Providers | `src/Provider/{Provider,Translator,PkgConfig}.cpp` | Native, CMake, Meson, Conan, pkg-config; bounded native translation |
|
||||
| Install / provenance | `src/Install/Installer.cpp`, `src/Provenance/*` | Prefix staging, exports, eight archives, SBOM, Ed25519, trusted keys |
|
||||
| Reports | `src/Report/{Cdash,Coverage}.cpp` | JUnit-adjacent CDash XML and gcov/lcov |
|
||||
| Daemon | `src/Daemon/Daemon.cpp` | Warm state/watcher, Unix-socket request protocol |
|
||||
| Registry | `registry/service/*`, `registry/cli/Main.cpp`, `registry/web/*` | HTTP API, RBAC, CAS, workers, admin UI |
|
||||
| Native recipes | `recipes/VoidLibrary/*`, `recipes/SelfHost/*` | Built-in VoidLibrary closure and the Stage 0→1 self-host recipe |
|
||||
| CLI | `src/Main.cpp` | Argument parsing, orchestration, output; a thin adapter over libraries |
|
||||
| Platform | `src/Platform/Linux/*`, `src/Watch/Linux/*`, `include/Void/Build/Platform/*` | Atomic files, process supervision, inotify/DirectoryWatcher, host detection |
|
||||
|
||||
Public libraries:
|
||||
|
||||
| CMake target | Alias | Contents |
|
||||
| --- | --- | --- |
|
||||
| `VoidBuild_Sdk` | `Void::BuildSdk` | Declaration SDK and JSON serialization |
|
||||
| `VoidBuild_Core` | `Void::BuildCore` | Configuration, graph, execution, packages, providers, install, daemon, reports |
|
||||
| `VoidBuild_Registry` | `Void::BuildRegistry` | Registry service (POSIX only) |
|
||||
| `VoidBuild_Options` | — | C++26, `-freflection`, warnings interface |
|
||||
|
||||
## Invariants
|
||||
|
||||
:::callout{type="contract" title="Non-negotiable design rules"}
|
||||
1. **Descriptions are host programs, not engine callbacks.** The engine never links a project's `build.cpp` into the CLI process.
|
||||
2. **Profiles are isolated.** Objects, BMIs, PCHs, response files and generated headers are never shared between incompatible contexts.
|
||||
3. **Inputs are immutable.** Successful actions run against captured inputs, not a mutable working tree in place.
|
||||
4. **Outputs publish before references.** A CAS blob exists and verifies before an action success record refers to it.
|
||||
5. **Determinism is the default.** Reproducibility epochs, canonical snapshot metadata, `-frandom-seed`, `SOURCE_DATE_EPOCH`, `TZ=UTC` and `LC_ALL=C` are applied unless the action is explicitly nondeterministic.
|
||||
6. **Errors are explicit.** Missing tools, unsupported constructs, unresolved imported targets, stale locks and output collisions fail; they are not guessed or silently skipped.
|
||||
7. **One owner per interface.** The shared schema (`schema_version: 1`) and lock format are versioned contracts between components.
|
||||
:::
|
||||
|
||||
## Two execution identities
|
||||
|
||||
The build has three distinct tool identities:
|
||||
|
||||
| Identity | Used for | Not used for |
|
||||
| --- | --- | --- |
|
||||
| Host compiler | Compiling `build.cpp` and helper sources | Project targets |
|
||||
| Target compiler | Compiling project sources | Evaluating the description |
|
||||
| Build-machine tools | CMake, Meson, Conan, Git, shader compilers | Being assumed present in a target profile |
|
||||
|
||||
`build_dependency(true)` marks a dependency as a host/build-machine tool. In 1.0.0 the resolver records one target context (`machine_role = "target"`); the flag is carried in the model and lock entry, but a distinct build-machine solve is not implemented yet.
|
||||
|
||||
## What the graph owns
|
||||
|
||||
`BuildGraph` is the single execution contract:
|
||||
|
||||
- `profile` and `toolchain` identities;
|
||||
- `snapshot_id` and the materialized root;
|
||||
- `targets` with expanded sources, primary outputs, runtime libraries, labels, resources, fixtures and exported BMIs;
|
||||
- topologically ordered `actions` with argv, environment, cwd, response files, declared inputs/outputs, depfile, logical/physical paths, compile metadata, cacheability and an action key.
|
||||
|
||||
Everything downstream — scheduler, compilation database, daemon responses, install staging, SBOMs — consumes this graph rather than re-deriving commands.
|
||||
|
||||
## Boundaries and ownership
|
||||
|
||||
- The **SDK** declares, the **frontend** compiles/evaluates, the **graph** validates and lowers, the **scheduler** executes.
|
||||
- The **provider** returns complete usage requirements or an explicit gap; it never invents a library interface from a filename.
|
||||
- The **registry** stores immutable bytes and policy metadata; it never executes recipes or verifies signatures on the server.
|
||||
- The **daemon** is a transport and warm-state owner; it calls the same resolver/scheduler as the CLI and adds no alternate build algorithm.
|
||||
- The **editor projection** rewrites typed operands onto logical sources; it never string-replaces arbitrary flags or defines.
|
||||
|
||||
The next page follows configuration and graph lowering in detail. See [Configuration and graphs](/build-system/developer/configuration-and-graph).
|
||||
@@ -0,0 +1,195 @@
|
||||
---
|
||||
title: Configuration and Graph Lowering
|
||||
description: How build.cpp is discovered, compiled and evaluated, how profiles resolve, and how targets become validated actions
|
||||
section: Configuration & Execution
|
||||
badge: internals
|
||||
order: 1
|
||||
tags: [internals, frontend, descriptor, profiles, graph, actions, modules, unity, pch]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Configuration and Graph Lowering
|
||||
|
||||
The frontend turns ordinary C++ into one immutable JSON description per profile; the graph layer turns that description plus a toolchain and snapshot into one immutable action graph. Neither step executes project targets.
|
||||
|
||||
## Description discovery
|
||||
|
||||
`discover_config_sources()` is filesystem-only:
|
||||
|
||||
- requires `build.cpp` **or** `workspace.cpp` at the project root;
|
||||
- adds both if present (a workspace root takes precedence for orchestration);
|
||||
- adds optional `build.profiles.cpp`;
|
||||
- recursively globs `build-support/**/*.cpp|.cc|.cxx`, sorted;
|
||||
- adds explicit `--build-source` files, resolved against the project root;
|
||||
- de-duplicates by normalized path;
|
||||
- never consults Git.
|
||||
|
||||
Headers are not enumerated up front. The compile step uses `-MMD` depfiles, and the discovered headers are recorded beside the descriptor for cache validation.
|
||||
|
||||
## Descriptor compilation
|
||||
|
||||
The descriptor is a host executable built against the fixed SDK:
|
||||
|
||||
```text
|
||||
<build>/.vbs/config/
|
||||
├── Driver.cpp
|
||||
├── descriptor_<seed16>
|
||||
├── descriptor_<seed16>.headers.json
|
||||
├── obj_<seed16>/
|
||||
├── identity_cache.json
|
||||
└── seed.lock
|
||||
```
|
||||
|
||||
`seed_identity_hash` covers:
|
||||
|
||||
- the host compiler path and its SHA-256;
|
||||
- the generated driver source;
|
||||
- `<sdk>/Void/Build.hpp` and the SDK library (or SDK sources);
|
||||
- every configuration source's path and SHA-256.
|
||||
|
||||
Large files are hashed once and memoized by size + mtime in `identity_cache.json`. A cache hit also revalidates every previously discovered header (content hash; stat fingerprint short-circuit). If `build.profiles.cpp` is absent, the generated driver supplies `default_profiles()`. If `build.cpp` or `workspace.cpp` is absent, the driver supplies a throwing stub so the corresponding mode fails clearly.
|
||||
|
||||
Each translation unit is compiled with roughly:
|
||||
|
||||
```text
|
||||
g++ -std=c++26 -O1 -I <project> -I <sdk> -MMD -MF <dep> -c <source> -o <object>
|
||||
```
|
||||
|
||||
and linked into the descriptor. The host compiler defaults to `g++`; `--compiler gcc|clang` selects the **target** compiler and does not change the host compiler.
|
||||
|
||||
## Evaluation protocol
|
||||
|
||||
The descriptor runs out of process in `profiles`, `describe` or `workspace` mode. It writes a versioned JSON result to a private per-request file under `<build>/.vbs/config/eval/`. The parent enforces:
|
||||
|
||||
- bounded reads (16 MiB for profiles/workspace, 64 MiB for a project description);
|
||||
- protocol version, request id and context hash checks;
|
||||
- UTF-8 validation;
|
||||
- a default 30 s evaluation timeout.
|
||||
|
||||
stdout and stderr are logs, not protocol. A `build.cpp` that prints arbitrary text cannot corrupt the result.
|
||||
|
||||
## Profile resolution
|
||||
|
||||
`Profiles::resolve(name, compiler_override, os, architecture)` walks the parent chain:
|
||||
|
||||
- unknown names, unknown parents, self-inheritance and cycles throw;
|
||||
- ancestor fields apply first, then child fields;
|
||||
- scalar fields are last-writer-wins;
|
||||
- compile options, link options and defines are appended;
|
||||
- sanitizers are de-duplicated;
|
||||
- the compiler override applies last.
|
||||
|
||||
`default_profiles()` contains only:
|
||||
|
||||
| Profile | Compile options |
|
||||
| --- | --- |
|
||||
| `debug` | `-O0 -g` |
|
||||
| `release` | `-O3 -DNDEBUG` |
|
||||
|
||||
No `-std`, PIC, LTO or sanitizer flag is added by default. `CStandard::Default` and `CxxStandard::Default` mean **no standard flag** unless a target or profile sets one, except module translation units, which force C++20 when the profile is Default.
|
||||
|
||||
The build root defaults to `<project>/build`, but a relative `--build-dir` is resolved against the current working directory, not the project root. A typical CI invocation passes an absolute path.
|
||||
|
||||
When multiple profiles are requested, `--editor-profile` must name one of them; this is checked before descriptor work.
|
||||
|
||||
## From description to graph
|
||||
|
||||
The pipeline after evaluation is:
|
||||
|
||||
```text
|
||||
merge C++/TOML dependencies → validate/publish lock → materialize → import providers
|
||||
→ capture snapshot → lower targets to actions → execute selected closure
|
||||
```
|
||||
|
||||
`lower_project_graph()` receives the description, toolchain capabilities, project/build roots, an optional snapshot and imported targets. It produces `BuildGraph` with topologically ordered actions and no filesystem mutation except module scanning.
|
||||
|
||||
### Target validation
|
||||
|
||||
- duplicate target names;
|
||||
- unknown prerequisite or local link targets;
|
||||
- target-level cycles, reported as a chain;
|
||||
- incompatible sanitizer combinations;
|
||||
- missing explicit sources, header units or shader sources;
|
||||
- custom actions without a command or output;
|
||||
- duplicate output paths and outputs overlapping editable source files outside the profile build tree;
|
||||
- Windows reserved device names and case-insensitive output collisions.
|
||||
|
||||
`enabled(false)` excludes a target from default selection, but its actions are still lowered and can be pulled in as prerequisites. Unknown `--target` names are errors.
|
||||
|
||||
### Usage propagation
|
||||
|
||||
For each local link:
|
||||
|
||||
- compile usage from the dependency is applied when the link visibility is `Public` or `Private` (not `Interface`);
|
||||
- it is re-exported when the link visibility is `Public` or `Interface` (not `Private`);
|
||||
- link inputs are always added in declaration order, dependency first, then transitive libraries;
|
||||
- private dependencies of static libraries, header-only libraries and object libraries still propagate their link closure to final consumers; private dependencies of executables and shared libraries do not.
|
||||
|
||||
Imported targets follow the same compile-usage rules, with a link closure supplied by the provider. A missing imported target is an error.
|
||||
|
||||
### Actions
|
||||
|
||||
`ActionKind` values are `Compile`, `PrecompiledHeader`, `HeaderUnit`, `ModuleScan`, `ModuleBmi`, `Archive`, `Link` and `Custom`. `ModuleScan` exists in the enum but scanning currently runs synchronously during graph lowering, not as a scheduled action.
|
||||
|
||||
Action IDs are deterministic:
|
||||
|
||||
```text
|
||||
compile:<target>:<sha12(source path)> pch:<target>
|
||||
headerunit:<target>:<sha12> bmi:<target>:<sha12>
|
||||
archive:<target> link:<target>
|
||||
custom:<target> shader:<target>:<src>:<stage>
|
||||
```
|
||||
|
||||
Each action carries argv, environment, working directory, optional response file, declared inputs/outputs, depfile, logical/physical source/output paths, include dirs, defines, options, standard/LTO/sanitizer/PIC/PCH metadata, dependency action ids, nondeterminism and an action key.
|
||||
|
||||
### Output layout
|
||||
|
||||
```text
|
||||
<build>/profiles/<profile>/
|
||||
├── .profile.lock
|
||||
├── gen/ # custom action outputs and $GEN
|
||||
├── obj/<target>/<file>_<sha12>.o + .d
|
||||
├── obj/<target>/pch/<header>.gch
|
||||
├── bmi/<target>/... # .gcm/.pcm, module mappers
|
||||
├── modscan/<target>/
|
||||
├── unity/<target>/
|
||||
├── rsp/
|
||||
├── shaders/<target>/
|
||||
└── out/
|
||||
├── lib<name>.a
|
||||
├── lib<name>.so # POSIX shared library
|
||||
├── <name>.dll # Windows shared library, directly in out/
|
||||
└── bin/<name>[.exe]
|
||||
```
|
||||
|
||||
A relative custom-action output goes under `gen/`; an absolute output must stay inside the profile build tree. The scheduler deletes a pre-existing static archive before `ar`, so removed objects do not linger in archive membership.
|
||||
|
||||
### Modules, header units, unity and PCH
|
||||
|
||||
- The P1689 scanner runs during lowering. GCC uses `-fdeps-format=p1689r5`; Clang uses `clang-scan-deps` with probed system include directories.
|
||||
- Module collation rejects duplicate providers, self-imports, missing providers and cycles.
|
||||
- BMIs are stored per target and profile identity. GCC uses a module mapper; Clang emits `.pcm` through a separate BMI action and compiles the `.pcm` to an object.
|
||||
- Header units are lowered explicitly. Their default standard is C++20 when the profile standard is Default.
|
||||
- Unity batches default to 8 and exclude `.c`, assembly, module sources and any source with a per-file option.
|
||||
- PCH lowering exists, but capability probing and end-to-end coverage are weak in 1.0.0; treat PCH as experimental and verify it for your toolchain.
|
||||
|
||||
### Determinism inputs
|
||||
|
||||
The graph applies a reproducibility epoch and canonical path prefixes:
|
||||
|
||||
- `SOURCE_DATE_EPOCH=<epoch>`, `TZ=UTC`, `LC_ALL=C` on compile/custom/shader actions;
|
||||
- snapshot root → project root and profile build dir → `/vbs-build` prefix maps;
|
||||
- GCC `-frandom-seed=<object filename>` when deterministic;
|
||||
- deterministic archive mode (`ar rcsD`).
|
||||
|
||||
Prefix maps are capability-checked. A compiler that supports none of the required mapping flags fails compilation instead of silently emitting non-reproducible objects. Link actions get `TZ`/`LC_ALL`, but no canonical output mtime in 1.0.0.
|
||||
|
||||
## Current limits
|
||||
|
||||
- Action keys include the whole-project `snapshot_id`, so a source edit re-keys every action; only a true no-op is fully cached. Single-file incremental reuse is not implemented.
|
||||
- Snapshot lookup guards and `is_snapshot_fresh()` exist but are not populated/used by the CLI build path.
|
||||
- `ModuleScan` is not a DAG action; scans are serial during lowering.
|
||||
- PCH is unprobed; MemorySanitizer and LeakSanitizer requests are not capability-checked.
|
||||
- Daemon builds lower without a snapshot, so their action keys differ from CLI builds.
|
||||
|
||||
Next: [trace snapshots, scheduling and state](/build-system/developer/snapshots-and-execution).
|
||||
@@ -0,0 +1,275 @@
|
||||
---
|
||||
title: Packages, Solvers and Providers
|
||||
description: The normalized dependency model, lockfile schema, fetch/cache layout, provider contracts and bounded foreign translation
|
||||
section: Packages & Providers
|
||||
badge: internals
|
||||
order: 1
|
||||
tags: [internals, solver, lockfile, fetch, providers, cmake, meson, conan, pkg-config, bridge]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Packages, Solvers and Providers
|
||||
|
||||
Package management is split into four stages with explicit boundaries:
|
||||
|
||||
:::flow
|
||||
normalize → solve → lock/materialize → provide typed targets
|
||||
:::
|
||||
|
||||
The C++ and TOML front ends produce the same `DependencyRecord`, the solver works only on registry packages, materialization produces a `MaterializedSource`, and a provider turns that source into `ImportedTargetInterface` values consumed by graph lowering.
|
||||
|
||||
## Normalized model
|
||||
|
||||
`DependencyRecord` (`include/Void/Build.hpp`) is the shared representation:
|
||||
|
||||
```text
|
||||
name, source_kind, location, revision, package, version, builder,
|
||||
options (string|bool|int64), registry_authority, sha256, features,
|
||||
build_dependency
|
||||
```
|
||||
|
||||
`DependencySourceKind` is `Git`, `Path`, `Archive`, `Package`, `Conan` or `PkgConfig`. Validation is immediate:
|
||||
|
||||
- exactly one source;
|
||||
- Git requires a 40-hex commit; archive requires a 64-hex SHA-256;
|
||||
- `.cmake()`/`.meson()` cannot be combined with a registry package source in C++;
|
||||
- a builder cannot be reassigned;
|
||||
- duplicate aliases are rejected.
|
||||
|
||||
C++ and TOML declarations merge by alias. Identical records merge; different records fail and report both origins. `build_dependencies` entries force `build_dependency = true`; the flag is recorded, but 1.0.0 resolves a single target context (`machine_role = "target"`).
|
||||
|
||||
### TOML loader details
|
||||
|
||||
The loader is intentionally strict:
|
||||
|
||||
- top-level tables: `dependencies`, `build_dependencies`, plus an accepted-but-unused `registries` placeholder;
|
||||
- fields: `git`, `rev`, `path`, `archive`, `sha256`, `package`, `version`, `conan`, `builder`, `options`, `registry`, `features`, `build_dependency`;
|
||||
- options are typed: string, bool or signed integer; floats, arrays and tables are rejected;
|
||||
- `builder` must be `cmake`, `meson`, `conan` or `native`;
|
||||
- a registry package may only use an explicit `native` builder; if the builder is omitted, `vbs build` inspects the extracted source for `build.cpp`, `CMakeLists.txt` or `meson.build`;
|
||||
- diagnostics carry exact `file:line:column` origins;
|
||||
- unknown keys and duplicate keys are never ignored.
|
||||
|
||||
## Solver
|
||||
|
||||
Registry identities are `{registry_authority, package_name}`. There is no cross-registry fallback: the same name from two authorities is two packages.
|
||||
|
||||
The solver is deterministic chronological backtracking with:
|
||||
|
||||
- fewest-candidates-first selection;
|
||||
- fail-fast propagation and a bounded step count (`50,000`);
|
||||
- pinned-version preference when not upgrading;
|
||||
- highest compatible SemVer otherwise;
|
||||
- yanked versions skipped unless they are the pinned version (configurable);
|
||||
- up to eight `no version of <pkg> satisfies <range> (from <origin>)` explanations on failure.
|
||||
|
||||
:::callout{type="info" title="Naming vs implementation"}
|
||||
The codebase and tests describe the solver as “PubGrub-style”. The current implementation does not use PubGrub incompatibility clauses or clause learning; it is a deterministic backtracking solver with pinned-version preference. Treat “PubGrub-style” as design lineage, not an algorithmic guarantee.
|
||||
:::
|
||||
|
||||
Features are carried in constraints and lock entries, but do not affect acquisition or target export in 1.0.0. They are metadata for a future feature-aware solve.
|
||||
|
||||
The resolver always solves with `machine_role = "target"`. The API and lock schema allow a build role; a distinct build-machine solve is not implemented yet.
|
||||
|
||||
## Lockfile format
|
||||
|
||||
`vbs.lock` is JSON with `schema_version: 1`:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": 1,
|
||||
"revision_hash": "sha256 over the canonical contexts payload",
|
||||
"contexts": {
|
||||
"debug:gcc:Linux:x86_64:target": {
|
||||
"context_key": "debug:gcc:Linux:x86_64:target",
|
||||
"profile_name": "debug",
|
||||
"compiler": "gcc",
|
||||
"os": "Linux",
|
||||
"architecture": "x86_64",
|
||||
"machine_role": "target",
|
||||
"declaration_fingerprint": "…",
|
||||
"entries": [
|
||||
{
|
||||
"alias": "fmt",
|
||||
"source_kind": "package",
|
||||
"registry_authority": "https://packages.example.com",
|
||||
"package_name": "fmt",
|
||||
"version": "11.0.2",
|
||||
"location": "",
|
||||
"revision": "",
|
||||
"sha256": "…",
|
||||
"builder": "native",
|
||||
"features": ["header-only"],
|
||||
"build_dependency": false,
|
||||
"signature": "…",
|
||||
"public_key": "…"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `revision_hash` is re-computed and validated on read; a hand-edited hash is rejected.
|
||||
- URLs are written without embedded credentials; bearer tokens never enter the lock.
|
||||
- Optional signature fields are omitted when absent, preserving byte compatibility with unsigned locks.
|
||||
- One immutable lock revision is pinned at build start.
|
||||
|
||||
`declaration_fingerprint` covers the profile name, compiler, OS, architecture, role, and every non-build dependency's normalized fields with typed options. Build-dependency declarations are written to lock entries but are excluded from the fingerprint in 1.0.0, so changing only a build dependency does not by itself force a lock republish.
|
||||
|
||||
Lock publication is compare-and-swap:
|
||||
|
||||
- `--locked` refuses creation or modification;
|
||||
- a changed context is re-solved and republished by a normal build;
|
||||
- a competing update to the same context with a different fingerprint returns busy;
|
||||
- other profiles' contexts are preserved;
|
||||
- multi-profile builds merge contexts instead of replacing the file.
|
||||
|
||||
## Materialization and cache
|
||||
|
||||
All dependency data lives under `<build>/.vbs/cache`:
|
||||
|
||||
| Content | Path |
|
||||
| --- | --- |
|
||||
| Registry tarball | `packages/<sha256>.tar` |
|
||||
| Registry extracted source | `packages/<sha256>/src/` |
|
||||
| Git checkout | `git/<alias>_<rev>/` with `.vbs_verified_rev` |
|
||||
| Archive extraction | `archives/<sha256>/` with `.vbs_verified` |
|
||||
| Archive download staging | `downloads/<sha256>.tar` |
|
||||
| Fetch locks | `locks/<sha256>.lock`, `locks/git_<rev>.lock` |
|
||||
| Path snapshot | `path-snapshots/` |
|
||||
| Binary variant cache | `binaries/<sha256>` |
|
||||
|
||||
Materialization properties:
|
||||
|
||||
- **Path** dependencies are canonicalized, snapshotted for content identity, and never modified; `compile_commands.json` is excluded from the snapshot.
|
||||
- **Archives** are verified before extraction. Local and `file://` sources are copied; remote sources use `curl` with HTTPS/HTTP only and a 120 s timeout. A digest mismatch deletes the download.
|
||||
- **Git** uses `git clone --no-checkout` + detached checkout, then verifies `HEAD` equals the pinned commit. `GIT_TERMINAL_PROMPT=0` prevents interactive hangs. The checkout is published by atomic directory rename.
|
||||
- **Registry packages** download with SHA-256 verification, extract safely, and reuse a cached extraction only while the expected directory exists.
|
||||
- **Safe extraction** rejects absolute paths, `..`, symlinks, hardlinks, special files and duplicate entries, with entry/size/total quotas. Extraction is staged and published only on full success.
|
||||
- **Integrity is checked before use**, and a cached extraction marker is not a substitute for an explicit re-verification when the source digest changes (the digest is part of the path).
|
||||
|
||||
Environment overrides: `VBS_VOID_SOURCE_DIR` (VoidLibrary only, Git source), `VBS_REGISTRY_URL`, `VBS_REGISTRY_TOKEN`, `VBS_TRUSTED_PUBLIC_KEYS`.
|
||||
|
||||
## Provider contract
|
||||
|
||||
A provider receives the materialized source, profile, toolchain and options, and returns `ImportedTargetInterface`:
|
||||
|
||||
```text
|
||||
include_dirs (path, is_system), defines, compile_options, link_options,
|
||||
static_libraries, shared_libraries, runtime_files, generated_prerequisites,
|
||||
module_bmis
|
||||
```
|
||||
|
||||
The graph then applies the same visibility and ordering rules as local targets. Missing imported targets are hard errors; a provider cannot return a partial interface and have it guessed.
|
||||
|
||||
### Native
|
||||
|
||||
`builder == "native"` requires a `build.cpp` or a recognized VoidLibrary tree (which uses the built-in recipe). The provider:
|
||||
|
||||
- sets `VBS_DEP_NAME`, `VBS_DEP_OPTION_<KEY>` and the plain option name (for VoidLibrary's `VOID_ENABLED_MODULES`-style options);
|
||||
- evaluates/builds the dependency's graph through VBS itself;
|
||||
- exports compile usage, reverse-post-order static link closure, runtime shared libraries, module BMIs and `Void_<Module>` → `Void::<Module>` aliases;
|
||||
- supports static/shared/object/custom targets, plus executables for build dependencies;
|
||||
- rejects nested dependencies inside a native subproject in 1.0.0.
|
||||
|
||||
No CMake is invoked on this path.
|
||||
|
||||
### CMake
|
||||
|
||||
Full-build mode writes a File API `codemodel-v2` query, configures CMake (Ninja if available), builds with `cmake --build`, and imports compile groups. It preserves only a small set of system link fragments (`-pthread`, `-lpthread`, `-ldl`, `-lm`, `-lrt`) and reconstructs static link order from dependencies.
|
||||
|
||||
Provider outputs are cached at `<build>/.vbs/providers/<dep>/<identity16>/provider-export.json`. The identity includes builder, source content hash, profile, toolchain identity and options. Metadata-only mode never executes CMake; an unbuilt provider returns `stale_needs_build` instead of fabricated targets.
|
||||
|
||||
### Meson
|
||||
|
||||
`meson setup` only, then `meson compile -C`, then reads `meson-info/intro-targets.json`. Static/shared targets, `-I` flags and `<src>/include` are imported. Defines and richer introspection are not imported in 1.0.0.
|
||||
|
||||
### Conan
|
||||
|
||||
The adapter checks for `conan` in `PATH`, writes host/build profiles, and runs `conan install --format json`. The current adapter imports no package targets beyond explicit overrides. A standalone `.conan(...)` source dependency also fails at materialization (`requires package/registry resolution before source fetch`), so it is not yet usable as a `vbs build` dependency.
|
||||
|
||||
### pkg-config
|
||||
|
||||
`.pc` files are parsed directly (no executable):
|
||||
|
||||
- recursive `${var}` expansion, including `${pcfiledir}`;
|
||||
- comma-separated module specs with `=`, `==`, `!=`, `<`, `<=`, `>`, `>=` and RPM-style comparison;
|
||||
- `Requires`, `Cflags`, `Libs` merged across the chain;
|
||||
- `PKG_CONFIG_PATH`, then `PKG_CONFIG_LIBDIR` (which suppresses fallbacks), then conventional prefixes;
|
||||
- `-I`/`-isystem<dir>` → include dirs (currently marked system), `-D` → defines, other cflags → compile options, `-l/-L/-Wl,/-pthread/-ldl` → link options, `.a`/`.so` → library inputs;
|
||||
- lock entry as `pkgconfig`, never fetched.
|
||||
|
||||
Current gaps: `Requires.private`/`Libs.private` are ignored, a two-token `-isystem <dir>` is not parsed, and all include dirs are marked system.
|
||||
|
||||
### CMake bridge
|
||||
|
||||
`cmake/bridge/VbsDeps.cmake` lets a CMake project ask VBS for dependencies:
|
||||
|
||||
```cmake
|
||||
include(VbsDeps.cmake)
|
||||
vbs_declare_dependency(fmt PACKAGE fmt VERSION "^11.0" REGISTRY "https://...")
|
||||
vbs_make_available(fmt)
|
||||
```
|
||||
|
||||
The bridge writes a request JSON and calls `vbs bridge`, which materializes the source and imports provider targets as `IMPORTED` CMake targets. In 1.0.0 it cannot resolve registry `package` sources (the same materialization gap as Conan) and ignores `FEATURES`/`LOCKED`; use Git/path/archive sources in bridge mode.
|
||||
|
||||
## Bounded native translation
|
||||
|
||||
`--native-foreign` attempts to translate a foreign CMake/Meson graph into native VBS actions instead of delegating the build.
|
||||
|
||||
- **Policy**: `FallbackToForeignBuild` is the default and the only policy the CLI selects. `RequireNative` is available to library callers and fails on unsupported constructs.
|
||||
- **CMake**: configure-only, audit `codemodel-v2`, lower compile/link groups and custom commands into a `BuildGraph`, execute with VBS's scheduler and CAS.
|
||||
- **Meson**: `meson setup` only, audit `intro-targets.json`, recover link edges from `build.ninja`, lower custom targets.
|
||||
- **Unsupported**: console pools, out-of-tree working directories/outputs, non-hermetic utility rules, build-system regeneration, unbounded shell custom commands, non-C/C++ languages, PCH, `run` targets, and untranslated dependency edges. Each is a named diagnostic, never a silent drop.
|
||||
- **Caching**: translated provider graphs are not yet written as `provider-export.json`, so metadata-only readers such as `vbs ide` cannot see them until that is fixed.
|
||||
|
||||
## Signing and trust
|
||||
|
||||
Package signing uses Ed25519 over:
|
||||
|
||||
```text
|
||||
vbs-package-v1
|
||||
<name>@<version>
|
||||
sha256:<archive-digest>
|
||||
```
|
||||
|
||||
The trust policy is:
|
||||
|
||||
| Situation | Decision |
|
||||
| --- | --- |
|
||||
| No trusted keys configured | `Unsigned` (legacy behavior) |
|
||||
| Missing signature/public key | `Unsigned` |
|
||||
| Signer key not trusted | `UntrustedKey` (no crypto invoked) |
|
||||
| Trusted key, valid signature | `Verified` |
|
||||
| Trusted key, invalid signature | `InvalidSignature` |
|
||||
| Malformed hex or no crypto backend | explicit error |
|
||||
|
||||
Enforcement happens in `vbs build`/`vbs test` and the daemon before extraction. `vbs deps resolve|update` do not accept trusted keys yet, so run a build (or `vbs verify`) when enforcing signatures in automation. Keys come from `--trusted-public-key`, `--trusted-key-file`, `vbs.keys`, and `VBS_TRUSTED_PUBLIC_KEYS`.
|
||||
|
||||
Binary variants use `vbs-binary-v1\n<variant-id>\nsha256:<digest>\n`; installer archives use `vbs-installer-v1\n<digest>\n` and sign the archive digest, not the bytes.
|
||||
|
||||
## Install and SBOM internals
|
||||
|
||||
`install_project` stages privately, validates destinations, then publishes file-by-file and writes `.vbs-install-manifest.json`. It installs only targets with install rules plus declared files. Public headers require an explicit `install_directory`. CMake exports are relocatable and skip executables; native metadata lives under `share/vbs/<pkg>/package.json`.
|
||||
|
||||
Installer archives are generated from the installed file list, so the ownership manifest itself is **not** included in the archive. `--bundle-dependencies` bundles only local shared-library outputs in 1.0.0, not imported provider libraries.
|
||||
|
||||
SBOMs include lock entries with a concrete version (registry packages) and all lowered target primary outputs. Git/path/archive/pkgconfig entries without a version are omitted; the document is deterministic for identical inputs.
|
||||
|
||||
## Current limits
|
||||
|
||||
:::callout{type="warning" title="Known 1.0.0 gaps"}
|
||||
- Conan is not usable as a standalone `vbs build` dependency yet.
|
||||
- Features are recorded but do not affect acquisition.
|
||||
- Only the target machine role is solved.
|
||||
- Build-dependency declarations are excluded from the lock fingerprint.
|
||||
- `vbs deps update --offline` with registry packages always fails.
|
||||
- `vbs install` has no `--locked`, `--offline` or `--native-foreign`.
|
||||
- Downloads are buffered in memory rather than streamed.
|
||||
- Foreign translation results are not cached as provider exports.
|
||||
- Binary variants are verified but not selected by `vbs build`.
|
||||
- pkg-config private requirements and two-token `-isystem` are unsupported.
|
||||
:::
|
||||
|
||||
Next: [inspect the registry internals](/build-system/developer/registry-internals) or [trace execution and snapshots](/build-system/developer/snapshots-and-execution).
|
||||
@@ -0,0 +1,138 @@
|
||||
---
|
||||
title: Quality, Benchmarks and Known Limits
|
||||
description: Test suites, contract checks, fuzzing, benchmarks, platform status and the gaps to plan around in 1.0.0
|
||||
section: Quality & Status
|
||||
badge: status
|
||||
order: 1
|
||||
tags: [quality, testing, fuzzing, benchmarks, platforms, gaps, limitations, status]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Quality, Benchmarks and Known Limits
|
||||
|
||||
This page is deliberately conservative: it separates what is exercised from what is implemented, and records the gaps that matter when adopting or extending VBS 1.0.0.
|
||||
|
||||
## Test layers
|
||||
|
||||
| Layer | Entry point | What it proves |
|
||||
| --- | --- | --- |
|
||||
| Declaration SDK | `vbs_sdk_tests` | Target/profile records, visibility, handle lifetime, UTF-8 JSON |
|
||||
| Core engine | `vbs_core_tests` | SHA-256, process supervision, profiles, snapshots, state/CAS, end-to-end build |
|
||||
| v1 integration | `vbs_v1_tests` | CompDB, providers, packages, install, modules, daemon, signing, IDE, workspaces |
|
||||
| Registry | `vbs_registry_tests` | HTTP API, RBAC, CSRF, CAS, remote cache, workers, live CLI E2E |
|
||||
| Self-host | `vbs_selfhost_tests` | Native self-host, `VOID_TEST` generation, bit-identical rebuilds |
|
||||
| SDK registration | `vbs_sdk_registration` | Self-registering cases and named execution |
|
||||
| CLI contracts | `vbs_cli_contract` | Help, subcommands, repeatable flags, error contracts |
|
||||
| Description contracts | `vbs_description_contract` | Four profile/compiler contexts and describe errors |
|
||||
|
||||
The CMake bootstrap exposes these as eight CTest entries. The self-hosted description declares the same suite executables as `project.test(...)` targets, so `vbs test` runs them without CMake.
|
||||
|
||||
```sh
|
||||
dev cpp-gcc -c ctest --test-dir build --output-on-failure
|
||||
build/bin/vbs test --build-dir build/vbs-stage2 --profile release --jobs 8
|
||||
```
|
||||
|
||||
The integration suites create temporary projects, compile real binaries, start real registry servers on loopback, run CLI processes, and assert outputs and exit codes. A passing test run is the acceptance signal; a design document is not.
|
||||
|
||||
## What the suite exercises
|
||||
|
||||
- Native C/C++ builds, static/shared/object/header-only targets, custom actions, assembly, shaders.
|
||||
- Profiles, inheritance, cycles, sanitizer compatibility, LTO and unity lowering.
|
||||
- Snapshots, mutation detection, symlinks, header shadowing, state recovery and GC.
|
||||
- GCC 16 and Clang 23 modules, partitions, header units, cross-target BMIs.
|
||||
- CMake/Meson providers, bounded native translation, custom commands, mixed C/C++ and C++20 modules.
|
||||
- TOML parsing, solver oracle, lock CAS, archive safety, install/relocation, CMake bridge.
|
||||
- Registry RBAC, immutability, CSRF, XSS-safe UI, ETag/304, ranges, binary variants, yank.
|
||||
- Remote cache round trips, worker leases/queue/execution, parallel workers.
|
||||
- Daemon lifecycle and all request families.
|
||||
- Signing primitives, trusted-key policy, lockfile signature round trips.
|
||||
- Workspace member builds, shared lock/CAS, `--changed-since` selection.
|
||||
- IDE compdb projection, ticket races, editor presets, File API replies, plugin assets.
|
||||
- JUnit, CDash, coverage, test labels/resources/fixtures.
|
||||
|
||||
## What is not covered or not proven
|
||||
|
||||
:::callout{type="warning" title="Treat these as unverified until you reproduce them"}
|
||||
- **PCH**: lowering exists, but there is no capability probe and no end-to-end PCH test.
|
||||
- **MemorySanitizer / LeakSanitizer**: flags exist, but only ASan/UBSan/TSan are probed; MSan/LSan requests can fail at the compiler.
|
||||
- **Native Windows host**: partial `_WIN32` backends exist, but `host_supported()` reports Linux only, the daemon and registry are not built on Windows, and CI only cross-builds and runs under Wine.
|
||||
- **Wine-hosted suite**: SDK/core only, marked non-blocking; `vbs_v1_tests` and `vbs_selfhost_tests` do not run under Wine.
|
||||
- **Daemon metadata requests** for projects that link provider-imported targets: they lower without imports and can fail.
|
||||
- **Conan as a `vbs build` source dependency**: the adapter exists, but standalone `.conan(...)` materialization is not wired.
|
||||
- **Single-file incremental rebuilds**: action keys include the whole snapshot id; only a true no-op is fully cached.
|
||||
- **Streaming downloads**: package and registry responses are buffered in memory in 1.0.0.
|
||||
- **CMake bridge package deps**: registry package sources cannot be materialized through the bridge.
|
||||
- **Remote execution sandboxing**: none; action specs run with worker privileges.
|
||||
- **Registry backup completeness**: the C++ backup helper omits binary blobs and the action cache.
|
||||
:::
|
||||
|
||||
## Fuzzing
|
||||
|
||||
Two harnesses exist:
|
||||
|
||||
1. **Deterministic mutation harness** (`CoreEngineTests.fuzz_mutated_inputs_never_crash_parsers`): fixed-seed xorshift mutations, truncation, overwrite runs and junk insertion over TOML, JSON, lockfile and tar seeds; seed sanity checks prevent a vacuous run.
|
||||
2. **Clang/libFuzzer target** (`fuzz/fuzz_parsers.cpp`, `fuzz/run.sh`): JSON, SemVer range and strict SemVer entry points, with a seeded corpus and ASan/UBSan.
|
||||
|
||||
The fuzz target covers header-only parsers. TOML, lockfile and tar stay in the deterministic mutation harness because their implementations are not header-only. Run:
|
||||
|
||||
```sh
|
||||
dev cpp -c fuzz/run.sh
|
||||
```
|
||||
|
||||
A clean fuzz run is evidence for crash resistance, not a proof of correctness.
|
||||
|
||||
## Benchmarks
|
||||
|
||||
`vbs_benchmarks --files N` measures engine operations. `benchmarks/compare.sh` generates a project and times VBS against CMake/Ninja and Meson for cold and warm builds.
|
||||
|
||||
```sh
|
||||
build/bin/vbs_benchmarks --files 15
|
||||
benchmarks/compare.sh 20
|
||||
```
|
||||
|
||||
Benchmark numbers are environment-specific and have moved with optimization waves; measure on your own hardware and toolchain. The documented performance target is warm-build latency (descriptor identity caching, parallel snapshot hashing, stat-validated state), not a cross-tool marketing claim. Large-repo scaling and per-file incremental reuse remain open.
|
||||
|
||||
## Platform status
|
||||
|
||||
| Host / target | Status |
|
||||
| --- | --- |
|
||||
| Linux x86_64 host | Supported and exercised |
|
||||
| Linux aarch64 host | Architecture-aware probes exist; not exercised in CI |
|
||||
| Windows x86_64/aarch64 target from Linux | Supported via MinGW-w64; tests require Wine |
|
||||
| Native Windows host | Partial port; not a supported host in 1.0.0 |
|
||||
| macOS host/target | Deferred; backends are not implemented |
|
||||
| Registry service | POSIX only |
|
||||
| Daemon | POSIX only |
|
||||
|
||||
Cross-target builds emit PE artifacts (`.exe`, `.dll`). Static archives keep the `lib<name>.a` convention. Wine tests resolve the literal `wine` executable; `wine64` is not tried.
|
||||
|
||||
## Security and trust boundaries
|
||||
|
||||
- `build.cpp` is compiled native code with user privileges. Snapshots and process isolation are not a sandbox.
|
||||
- Remote cache records and worker action specs are trusted input. A worker executes arbitrary commands from the registry.
|
||||
- Registry private packages are hidden from anonymous access but readable by any authenticated `read` principal.
|
||||
- Registry sessions, workers, leases and queues are in-memory and lost on restart.
|
||||
- Bearer tokens are runtime-only and never written to locks or action records.
|
||||
- Package signatures are verified by consumers, not by the registry. Installer signatures cover a canonical digest message.
|
||||
- The registry has no built-in TLS, rate limiting or login throttling; deploy it behind a trusted proxy.
|
||||
|
||||
## Documentation status
|
||||
|
||||
This handbook documents **VoidBuildSystem 1.0.0** at the `v1.0.0` tag. The repository's `docs/roadmap/` contains historical design plans and some statements that lag the implementation (for example, features listed as planned that are now implemented, or pin hashes from earlier waves). When the handbook and a roadmap page disagree, prefer the code and the current tests, then update the page.
|
||||
|
||||
## Adoption checklist
|
||||
|
||||
:::steps
|
||||
@@step[Verify the toolchain]
|
||||
Run `vbs doctor` on every host and target combination you depend on.
|
||||
@@step[Pin and lock]
|
||||
Commit `vbs.lock`; use `--locked` in CI; decide whether to require trusted keys.
|
||||
@@step[Prove the round trip]
|
||||
Build, test, install, unpack the archive, and run the installed product from a clean prefix.
|
||||
@@step[Check the edges]
|
||||
Exercise the specific feature you rely on: PCH, Conan, daemon metadata, Wine tests or registry backup.
|
||||
@@step[Measure]
|
||||
Run the benchmark on your project before making performance claims.
|
||||
:::
|
||||
|
||||
If a limitation above blocks adoption, treat it as a tracked gap rather than a configuration mistake. The design intentionally fails explicitly instead of approximating behavior.
|
||||
@@ -0,0 +1,200 @@
|
||||
---
|
||||
title: Registry Service Internals
|
||||
description: HTTP routes, authentication, storage layout, package and binary endpoints, remote cache and worker protocol
|
||||
section: Registry & Remote
|
||||
badge: registry
|
||||
order: 1
|
||||
tags: [internals, registry, http, rbac, csrf, storage, cas, workers, leases]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Registry Service Internals
|
||||
|
||||
`RegistryService` is a POSIX-only HTTP/1.1 service built on a small socket loop (or `Void::Net::HttpServer` when linked). It serializes API mutations on one mutex, stores package blobs and action-cache blobs on disk, and keeps users, tokens, packages, releases and audit records in one JSON metadata file.
|
||||
|
||||
## Startup and storage
|
||||
|
||||
`RegistryService::open(RegistryConfig)` creates:
|
||||
|
||||
```text
|
||||
<data-dir>/
|
||||
├── metadata.v1.json # users, tokens, packages, releases, audit
|
||||
├── registry.lock # per-save advisory lock
|
||||
├── cas/blobs/<2>/<sha256> # package + binary blobs, 0444
|
||||
└── action-cache/
|
||||
├── blobs/<2>/<sha256> # remote-cache outputs
|
||||
└── actions/<2>/<sha256>.json # action records
|
||||
```
|
||||
|
||||
`metadata.v1.json` is rewritten synchronously on every mutation under `registry.lock`. Package blobs are published before the metadata commit that references them. Sessions, workers, leases and the action queue are **in-memory only** and disappear on restart.
|
||||
|
||||
Configuration defaults:
|
||||
|
||||
| Setting | Default |
|
||||
| --- | --- |
|
||||
| `max_upload_bytes` | 32 MiB |
|
||||
| `max_storage_bytes` | 2 GiB (source-release digests only) |
|
||||
| `bootstrap_admin_user` | `admin` |
|
||||
| Audit cap | 2000 entries (oldest 500 trimmed) |
|
||||
|
||||
`--web-root` defaults to `<Bootstrap::source_dir>/registry/web`, which is a source-tree path. Packaged deployments must point it at the installed assets.
|
||||
|
||||
## Transport
|
||||
|
||||
- HTTP/1.1, one request per connection (`Connection: close`).
|
||||
- Header limit 64 KiB; body limit `max_upload_bytes`; 10 s socket timeouts.
|
||||
- `HEAD` is routed as `GET` with the body suppressed and `Content-Length` preserved.
|
||||
- Every response sets `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer` and a restrictive CSP.
|
||||
- Errors are `{"error":{"code":"…","message":"…"}}`.
|
||||
- `OPTIONS` is answered from route shape before authentication with `204` + `Allow`; no CORS `Access-Control-*` headers are emitted.
|
||||
- A single `Range: bytes=…` is supported (206 + `Content-Range`, 416 for unsatisfiable/multipart).
|
||||
|
||||
## Authentication and authorization
|
||||
|
||||
Roles are `reader`, `publisher`, `admin`. Principal resolution order:
|
||||
|
||||
1. `Authorization: Bearer …` (hash lookup, constant-time compare, revoked/expired/inactive checks);
|
||||
2. the `vbs_session` cookie.
|
||||
|
||||
Bearer requests are exempt from CSRF. Cookie-authenticated mutations require `X-CSRF-Token` matching the session token; if `Origin` is present it must be loopback HTTP or HTTPS.
|
||||
|
||||
Sessions:
|
||||
|
||||
- 24-byte session id and 24-byte CSRF token;
|
||||
- stored hashed, 24-hour expiry, in memory only;
|
||||
- cookie is `HttpOnly; SameSite=Strict; Path=/`, not `Secure` (fine on loopback, must be terminated by TLS behind a proxy).
|
||||
|
||||
Tokens:
|
||||
|
||||
- plaintext is `vbs_tok_` + 48 hex, returned once; only SHA-256 is stored;
|
||||
- scopes are free-form, but only `read`, `publish`, `admin` are consulted;
|
||||
- API-created tokens have no expiry; revocation is a soft flag;
|
||||
- a token can mint another token up to its user's role, not beyond the calling token's scope (scope intersection is not implemented).
|
||||
|
||||
Private packages:
|
||||
|
||||
- public listing excludes them;
|
||||
- anonymous access is `401`; an authenticated principal with `read` can read them;
|
||||
- this is team visibility, not a per-user ACL;
|
||||
- first publisher becomes sole owner; admin bypasses ownership; removing the last owner is `409 last_owner`.
|
||||
|
||||
## Routes
|
||||
|
||||
### Public/auth
|
||||
|
||||
| Method + path | Auth | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `GET /api/v1/health` | none | `{"status":"ok","schema_version":1}` |
|
||||
| `POST /api/v1/auth/login` | none | Session cookie + `csrf_token`; `401` on bad credentials |
|
||||
| `POST /api/v1/auth/logout` | principal (+CSRF for cookie) | Clear session |
|
||||
| `GET /api/v1/auth/me` | principal | Username, role, CSRF token |
|
||||
| `GET /api/v1/packages` | optional | Search `q` + `limit`/`offset` envelope |
|
||||
| `GET /api/v1/packages/<name>` | optional | Detail, owners, releases |
|
||||
| `PATCH /api/v1/packages/<name>` | publish + CSRF | Description/private metadata |
|
||||
| `GET /api/v1/packages/<name>/owners` | optional | Owner list |
|
||||
| `PUT/POST/DELETE .../owners/<user>` | publish + CSRF | Owner management |
|
||||
|
||||
Search `q` is a case-sensitive substring over name and description. `limit` defaults to 100 and is capped at 500; `offset` is capped at 1,000,000. The response is `{packages,total,limit,offset}`.
|
||||
|
||||
### Releases and binaries
|
||||
|
||||
| Method + path | Auth | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `GET .../packages/<name>/<version>` | optional | Release detail with digest, size, yank, publisher, signature, binary summaries |
|
||||
| `PUT .../packages/<name>/<version>` | publish + CSRF | Raw source tar upload |
|
||||
| `GET .../<version>/download` | optional | Tar download with `X-Content-SHA256` |
|
||||
| `PUT .../<version>/binaries/<variant>` | publish + CSRF | Upload a binary variant |
|
||||
| `GET .../<version>/binaries` | optional | List variants |
|
||||
| `GET .../<version>/binaries/<variant>` | optional | Variant detail + `download_url` |
|
||||
| `GET .../binaries/<variant>/download` | optional | Variant bytes |
|
||||
| `POST .../<version>/yank` | publish + CSRF | Yank/unyank a release |
|
||||
| `POST .../binaries/<variant>/yank` | publish + CSRF | Yank/unyank a variant |
|
||||
|
||||
Publish headers:
|
||||
|
||||
- `X-Content-SHA256`: must match the body (`400 digest_mismatch`);
|
||||
- `X-Package-Description`, `X-Package-Private`;
|
||||
- `X-Package-Signature` / `X-Package-Public-Key` (both-or-none, 128/64 hex);
|
||||
- binary variants use `X-Binary-Signature` / `X-Binary-Public-Key`.
|
||||
|
||||
Immutable release semantics:
|
||||
|
||||
- identical bytes for an existing version → `200 already_published`;
|
||||
- different bytes → `409 immutable_conflict`;
|
||||
- malformed archive (traversal, symlink, duplicate, quota) → `422 invalid_archive`;
|
||||
- storage quota → `413 quota_exceeded`.
|
||||
|
||||
Signature metadata is stored and served but never verified by the server. Trust belongs to the consumer.
|
||||
|
||||
Release and binary detail/listing responses carry a strong `ETag` and `Cache-Control: no-cache` and honour `If-None-Match` (weak prefixes, lists, `*`) with a bodyless `304`. Download `ETag`s are the artifact digest. Downloads support single ranges and `HEAD`.
|
||||
|
||||
Yanking only flips a flag; download routes still serve yanked bytes. Clients hide yanked variants from selection.
|
||||
|
||||
### Tokens, users, audit
|
||||
|
||||
| Method + path | Auth | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `GET /api/v1/tokens` | principal | Own tokens; admin sees all |
|
||||
| `POST /api/v1/tokens` | principal + CSRF | Create token, plaintext returned once |
|
||||
| `DELETE /api/v1/tokens/<id>` | principal + CSRF | Revoke |
|
||||
| `GET/POST /api/v1/users` | admin (+CSRF) | Paginated users / upsert |
|
||||
| `GET /api/v1/audit` | admin | Filters `actor`, `action` substring, `outcome`; paginated |
|
||||
| `GET /api/v1/admin/storage` | admin | Used/quota/package count |
|
||||
| `GET /api/v1/stats` | admin | Counts + ETag |
|
||||
|
||||
`POST /api/v1/users` is an upsert: it can overwrite a password and role. There is no deactivate/reactivate route in 1.0.0.
|
||||
|
||||
Audit entries record timestamp, actor, action, target, outcome and redacted detail. Logins, token operations, user changes, publish/update/yank, owner changes, binary operations, CAS writes, worker registration and queue/lease actions are audited. Most 401/403 denials are not.
|
||||
|
||||
## Remote cache endpoints
|
||||
|
||||
| Method + path | Auth | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `GET/PUT /api/v1/cas/blobs/<sha256>` | any principal | Raw blob store; `PUT` verifies the digest |
|
||||
| `GET/PUT /api/v1/cas/actions/<action-key>` | any principal | JSON action record |
|
||||
|
||||
`PUT` returns `200` when the object already exists and `201` when created. The client re-verifies downloaded blobs. The server does not enforce package ownership on CAS objects.
|
||||
|
||||
## Worker and lease endpoints
|
||||
|
||||
| Method + path | Auth | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `POST /api/v1/workers` | any principal | Register, returns `wrk_…` |
|
||||
| `POST /api/v1/workers/<id>/heartbeat` | owner/admin | Refresh liveness |
|
||||
| `GET /api/v1/workers` | owner/admin | List |
|
||||
| `POST /api/v1/queue` | publish/admin | Enqueue up to 64-hex action keys |
|
||||
| `GET /api/v1/queue` | any principal | Pending + leased keys |
|
||||
| `POST /api/v1/queue/lease` | any principal | FIFO lease, optional `worker_id`, `lease_seconds` 1–3600 |
|
||||
| `POST /api/v1/actions/lease` | any principal | Lease a specific key, returns the record |
|
||||
| `POST /api/v1/actions/<key>/renew` | lease token | Extend lease |
|
||||
| `POST /api/v1/actions/<key>/result` | lease token | Store result, require all output blobs, erase lease, dequeue |
|
||||
|
||||
Leases are pruned lazily. Results must reference an existing action record and every declared output blob must already be in the action-cache CAS; the endpoint then writes the record atomically. There is no per-tenant queue scoping, no worker affinity and no scheduling policy.
|
||||
|
||||
## Web UI
|
||||
|
||||
The static UI supports package search/detail, source release upload, release download/yank, token management, storage, user creation and the audit log. It renders with `textContent` and sends CSRF on mutations.
|
||||
|
||||
It does **not** implement binary-variant browsing/publishing, owner management, metadata editing or upload progress in 1.0.0. There is no automated headless-browser coverage of the UI.
|
||||
|
||||
## Backup and restore
|
||||
|
||||
`RegistryService::backup_to(dir)` and `restore_from(dir)` exist in the C++ API but have no CLI or HTTP route. They copy metadata and source-release blobs only; binary blobs and the entire action cache are excluded. Restore is additive and does not verify blob digests.
|
||||
|
||||
For a complete backup, stop the writer and copy the entire data directory. That is the only path that preserves binary variants, action-cache blobs and metadata together.
|
||||
|
||||
## Security model and limits
|
||||
|
||||
- Loopback default; TLS is expected from a reverse proxy.
|
||||
- No rate limiting, login throttling, automatic token expiry, user deactivation or per-user private-package ACL.
|
||||
- Private package existence is distinguishable: missing is `404`, private is `401` anonymous.
|
||||
- Path segments are not percent-decoded; clients URL-encode names and versions.
|
||||
- Upload bodies are buffered in memory (32 MiB cap), not streamed.
|
||||
- Metadata is one JSON file; there is no SQLite registry backend.
|
||||
- Sessions/queue/leases are lost on restart.
|
||||
- `OPTIONS` is not a real CORS preflight.
|
||||
- Reason phrases for some non-200 statuses are emitted as `OK`.
|
||||
|
||||
These are operational constraints to plan around, not hidden behavior; the implementation fails explicitly rather than pretending a stronger guarantee.
|
||||
|
||||
Next: [reproduce a self-hosted release](/build-system/developer/self-hosting).
|
||||
@@ -0,0 +1,150 @@
|
||||
---
|
||||
title: Self-Hosting, CI and Releases
|
||||
description: Bootstrap stages, the zero-CMake build description, bit-identical rebuilds, the CI matrix and release packaging
|
||||
section: Self-Hosting & Releases
|
||||
badge: zero-CMake
|
||||
order: 1
|
||||
tags: [self-host, bootstrap, reproducible, ci, gitea, release, installers, voidlibrary]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Self-Hosting, CI and Releases
|
||||
|
||||
VoidBuildSystem does not need CMake to build itself. The CMake bootstrap produces the first `vbs`; that binary then builds VoidLibrary through `.native_builder(...)`, declares all VBS targets in root [`build.cpp`](https://git.faumaray.com/Void/Build-System/src/branch/main/build.cpp), runs the native test suites, and packages its own installers.
|
||||
|
||||
## Stage model
|
||||
|
||||
:::flow
|
||||
CMake bootstrap → self-built vbs (stage 2) → rebuilt vbs (stage 3) → bit-identical comparison
|
||||
:::
|
||||
|
||||
| Stage | Producer | Purpose |
|
||||
| --- | --- | --- |
|
||||
| Bootstrap | CMake + GCC 16 | Build the first `vbs`, `vbs-registry`, `vbs_describe`, benchmarks and tests |
|
||||
| Stage 2 | Bootstrap `vbs` | Build VoidLibrary natively, then VBS, then run `VOID_TEST` suites with CMake trapped |
|
||||
| Stage 3 | Stage 2 `vbs` | Rebuild in a separate build directory without cache and compare artifacts |
|
||||
|
||||
The current root description pins VoidLibrary `de1fdcda72ddd6ac069fba433b13f643327efa3f` and requests the modules VBS needs:
|
||||
|
||||
```cpp
|
||||
library.git("https://git.faumaray.com/Void/VoidLibrary.git",
|
||||
Void::Build::Commit{"de1fdcda72ddd6ac069fba433b13f643327efa3f"})
|
||||
.native_builder({{"VOID_ENABLED_MODULES",
|
||||
"Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing;Log"},
|
||||
{"VOID_ENABLE_TESTING", "0"},
|
||||
{"BUILD_SHARED_LIBS", false}});
|
||||
```
|
||||
|
||||
The description declares 13 targets:
|
||||
|
||||
- `VoidBuildSdk`, `VoidBuildCore`, `GenerateBootstrapConfig`;
|
||||
- `vbs`, `VoidBuildRegistry`, `vbs-registry`;
|
||||
- `vbs_self_smoke`, `vbs_benchmarks`;
|
||||
- `vbs_sdk_tests`, `vbs_core_tests`, `vbs_v1_tests`, `vbs_registry_tests`, `vbs_selfhost_tests`.
|
||||
|
||||
Source membership is convention-based: `sdk/*.cpp`, `src/*/*.cpp`, `src/*/*/*.cpp`, `recipes/**/*.cpp` and `registry/service/*.cpp`. The entry points are excluded from the core library glob.
|
||||
|
||||
## Commands
|
||||
|
||||
```sh
|
||||
# Bootstrap
|
||||
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
|
||||
|
||||
# Stage 2: build and test the whole project without CMake
|
||||
VBS_VOID_SOURCE_DIR=/path/to/VoidLibrary \
|
||||
build/bin/vbs test --build-dir build/vbs-stage2 --profile release --jobs 8
|
||||
|
||||
# Stage 3: rebuild in a clean directory without cache
|
||||
build/vbs-stage2/profiles/release/out/bin/vbs build \
|
||||
--build-dir build/vbs-stage3 --profile release --target vbs --no-cache --jobs 8
|
||||
|
||||
# Reproducibility check
|
||||
sha256sum build/vbs-stage2/profiles/release/out/bin/vbs \
|
||||
build/vbs-stage3/profiles/release/out/bin/vbs
|
||||
```
|
||||
|
||||
`VBS_VOID_SOURCE_DIR` is a development override for the **VoidLibrary** Git dependency only. It never modifies the external checkout and does not change the pin in the description.
|
||||
|
||||
### What makes the rebuild reproducible
|
||||
|
||||
- `BootstrapConfig.hpp` is generated per profile; `binary_dir` is empty, so the binary resolves its SDK/binary directory relative to itself.
|
||||
- The snapshot materialized root maps to the project root and the profile build directory maps to `/vbs-build`.
|
||||
- GCC compiles get `-frandom-seed=<object filename>`.
|
||||
- Links set `TZ=UTC` and `LC_ALL=C`.
|
||||
- Static archives use deterministic mode.
|
||||
- Installer/source archives use canonical timestamps and sorted entries.
|
||||
|
||||
Bit-identical output is an observed property of the VBS-to-VBS stages, not a claim that every external tool is deterministic. Keep the same compiler, binutils and build flags when comparing.
|
||||
|
||||
## VoidLibrary recipe and migration
|
||||
|
||||
The native provider has two paths:
|
||||
|
||||
- **Generic `build.cpp` subproject**: evaluates the dependency's own description and imports its exported targets.
|
||||
- **Built-in VoidLibrary recipe** (`recipes/VoidLibrary/VoidLibraryRecipe.cpp`): builds VoidLibrary's module closure for projects that use the library directly.
|
||||
|
||||
`contrib/voidlibrary-migration/` contains the description used to migrate VoidLibrary itself: a native build with all modules, profiles and a smoke test. VoidLibrary upstream gained its own VBS description and CI workflow; the remaining upstream work is tracked in its own repository rather than being duplicated here.
|
||||
|
||||
The self-host recipe (`recipes/SelfHost/VbsSelfHostRecipe.cpp`) builds `vbs` itself without CMake and is exercised by `vbs_selfhost_tests`.
|
||||
|
||||
## CI matrix
|
||||
|
||||
The Gitea workflow at `.gitea/workflows/ci.yml` defines:
|
||||
|
||||
| Stage | Runner | What it does |
|
||||
| --- | --- | --- |
|
||||
| 1 · Requirements | `vulkan` | Verifies GCC 16, `-freflection`, CMake 4, Ninja and Git |
|
||||
| 2A · Linux build | `vulkan` | Debug, RelWithDebInfo and ASan+UBSan builds; uploads binaries, SDK library and compile database |
|
||||
| 3A · Linux test | `vulkan` | Full CTest for Debug/RelWithDebInfo; SDK + core suites under sanitizers; benchmark smoke on Debug |
|
||||
| 2B · Windows Wine build | `windows-gcc` | Cross-builds VBS with MinGW-w64 GCC 16; uploads binaries and SDK |
|
||||
| 3B · Windows Wine test | `windows-gcc` | Runs SDK/core executables under Wine; marked `continue-on-error` while the Wine-hosted suite matures |
|
||||
| 4A2 · VBS installers (Linux) | `vulkan` | Self-hosted `vbs install` produces tar, sh, zip, deb, rpm, wix, dmg and nuget archives |
|
||||
| 4A2 · VBS installers (Windows) | `windows-gcc` | Cross-installs Windows-target tar, zip, nuget and wix archives; non-blocking |
|
||||
| 5 · Release | `vulkan` | Verifies the tag against the project version, writes `SHA256SUMS`, creates the Gitea release and uploads assets |
|
||||
|
||||
The Linux installer job retries once in a fresh build directory before failing. The Windows lanes exist to exercise the target toolchain and packaging path; they are not a claim of native Windows-host support.
|
||||
|
||||
## Release packaging
|
||||
|
||||
`vbs install` builds the project, imports dependencies, stages the prefix and writes the archive:
|
||||
|
||||
```sh
|
||||
vbs install --project . --build-dir build/release --profile release --jobs 4 \
|
||||
--prefix /tmp/vbs-prefix \
|
||||
--package-name VoidBuildSystem --package-version 1.0.0 \
|
||||
--archive dist/vbs-v1.0.0-linux-x86_64.tar \
|
||||
--archive-format tar
|
||||
```
|
||||
|
||||
The installer job repeats this for all eight formats. The release job:
|
||||
|
||||
1. checks that a `v*` tag matches `project(VoidBuildSystem VERSION ...)`;
|
||||
2. computes `SHA256SUMS` over every artifact;
|
||||
3. creates (or reuses) the Gitea release for the tag;
|
||||
4. uploads each installer and the checksum file as release assets.
|
||||
|
||||
The release body names the commit and points readers at `SHA256SUMS`. Windows artifacts are attached when the optional Windows installer job produced them.
|
||||
|
||||
## Installer contents
|
||||
|
||||
The current root description installs the CLI binaries (`vbs`, and `vbs-registry` on POSIX). It does **not** declare `VoidBuildSdk`, `VoidBuildCore` or the SDK headers as install targets, so the 1.0.0 release archive contains those binaries plus the generated export metadata, not a complete SDK. Consumers who need the SDK should build or install the libraries explicitly.
|
||||
|
||||
## Verification checklist for a self-host change
|
||||
|
||||
:::steps
|
||||
@@step[Bootstrap]
|
||||
Build and run CTest with GCC 16.
|
||||
@@step[Self-host test]
|
||||
Run `vbs test` with `cmake` trapped on `PATH`.
|
||||
@@step[Rebuild from a clean directory]
|
||||
Build again with `--no-cache` and a different build directory.
|
||||
@@step[Compare artifacts]
|
||||
Hash `vbs`, `libVoidBuildSdk.a` and `libVoidBuildCore.a` from both stages.
|
||||
@@step[Package]
|
||||
Run `vbs install` for at least tar and one native format; unpack and run the binary.
|
||||
:::
|
||||
|
||||
Next: [check the quality record and known limits](/build-system/developer/quality-and-status).
|
||||
@@ -0,0 +1,174 @@
|
||||
---
|
||||
title: Snapshots, Scheduling and State
|
||||
description: Immutable inputs, process supervision, action keys, the local CAS and remote cache, garbage collection and editor generations
|
||||
section: Configuration & Execution
|
||||
badge: execution
|
||||
order: 2
|
||||
tags: [internals, snapshots, scheduler, cas, cache, state, depfiles, watcher, editor]
|
||||
updated: 2026-12-06
|
||||
---
|
||||
|
||||
# Snapshots, Scheduling and State
|
||||
|
||||
This layer owns correctness for everything after graph lowering: freeze the admitted inputs, run actions against them, validate outputs, publish immutable artifacts, and record only verified success.
|
||||
|
||||
## Snapshot capture
|
||||
|
||||
A snapshot is captured after dependency resolution and before graph lowering:
|
||||
|
||||
- roots: conventional `src`, `source`, `include`, `tests`, `sdk`; declared include dirs inside the project; parent directories of explicit sources; prefixes of globs; custom-action and PCH inputs;
|
||||
- `$GEN/` and `gen/` references are excluded from capture and validated by action dependencies instead;
|
||||
- default exclusions: `.git`, `.vbs`, `build`, `.serena`, `.cache`, `.env*` (except `.env.example`), `*.pem`, `*.key`, `keys`, `WG.conf`.
|
||||
|
||||
Storage:
|
||||
|
||||
```text
|
||||
<build>/.vbs/snapshots/
|
||||
├── blobs/<2>/<sha256> # content-addressed file bytes, 0444
|
||||
├── trees/<snapshot-id>/<logical> # materialized private tree + .sealed
|
||||
├── manifests/<snapshot-id>.json
|
||||
└── generated/<2>/<sha256> # sealed generated artifacts
|
||||
```
|
||||
|
||||
### Isolation and validation
|
||||
|
||||
- Files are copied with `Void::FileSystem::reflink_copy_file` when the filesystem supports reflinks, otherwise a real copy. Hardlinks are never used.
|
||||
- Symlinked regular files materialize as copies of the resolved target; the target path and bytes both participate in identity.
|
||||
- Capture retries the whole snapshot up to five times when the tree changes concurrently. Every file is re-hashed (parallel hashing for 32+ files) and every directory membership is re-read before sealing.
|
||||
- Materialization is verified; a missing tree is rebuilt up to three times.
|
||||
- A failure reports `source tree remained unstable across N revalidation retries`.
|
||||
|
||||
`snapshot_id` is SHA-256 over the version tag, reproducibility epoch, every entry (path, mode, size, digest, symlink target), every directory membership and any lookup guards.
|
||||
|
||||
:::callout{type="warning" title="Lookup guards are dormant"}
|
||||
The schema and `is_snapshot_fresh()` support absence/shadowing guards, but production callers do not populate queries in 1.0.0, and `is_snapshot_fresh()` is used only by tests. Treat the snapshot as a content/membership freeze, not as a fully exercised include-shadowing oracle.
|
||||
:::
|
||||
|
||||
### Determinism
|
||||
|
||||
- Snapshot blobs and materialized tree files get canonical mtimes (epoch, atime 0).
|
||||
- Compile/custom/shader actions receive `SOURCE_DATE_EPOCH=<profile epoch>`, `TZ=UTC`, `LC_ALL=C`.
|
||||
- GCC deterministic compiles add `-frandom-seed=<object filename>`.
|
||||
- Path maps rewrite the snapshot root to the project root and the profile build directory to `/vbs-build`.
|
||||
- Deterministic archives use `ar rcsD`.
|
||||
- Link actions receive `TZ`/`LC_ALL`; there is no canonical output mtime on linked artifacts.
|
||||
|
||||
## Toolchain identity
|
||||
|
||||
`discover_and_probe()` records:
|
||||
|
||||
- compiler and C/archiver paths, SHA-256 and version banner;
|
||||
- target triple and sysroot;
|
||||
- capability probes for C/C++ standards, reflection, prefix maps, LTO and sanitizers;
|
||||
- module scanning support (GCC P1689 or Clang + `clang-scan-deps`);
|
||||
- default system include dirs for Clang scanning;
|
||||
- shader tools (`glslangValidator`, `slangc`, `dxc`), which are intentionally **not** part of the toolchain identity because each shader action's key includes its command line.
|
||||
|
||||
Probe results are cached under `<build>/.vbs/probes/` keyed by compiler identity, archiver, sysroot, OS/arch and relevant environment variables (`CPATH`, `C_INCLUDE_PATH`, `CPLUS_INCLUDE_PATH`, `LIBRARY_PATH`, `COMPILER_PATH`, `GCC_EXEC_PREFIX`, `NIX_*`). `toolchain.identity_hash` combines the probe key, version banner and target triple; `profile_identity` adds profile name, family, OS/arch, standards, LTO, sysroot, epoch, nondeterminism, options, defines and sanitizers.
|
||||
|
||||
Command lowering is explicit:
|
||||
|
||||
- `.c` uses the C driver; `.s`/`.S` use the C driver without C/C++ standard, LTO or sanitizer flags; everything else uses C++.
|
||||
- Shared-library compiles add `-fPIC`.
|
||||
- Each requested unsupported capability is an error, not a silent downgrade.
|
||||
- Response files are emitted when the summed argv exceeds 32 KiB; the file name includes a content hash and actions reference `@file`.
|
||||
|
||||
## Scheduler
|
||||
|
||||
`execute_graph()`:
|
||||
|
||||
- selects the action closure of the requested enabled targets, preserving graph order;
|
||||
- uses `min(selected actions, --jobs or hardware concurrency)` workers;
|
||||
- takes an exclusive per-profile lock and a CAS lease for the run;
|
||||
- runs each action in a new process group;
|
||||
- captures bounded stdout/stderr (8 MiB each) and supports timeout/cancellation with group `SIGTERM` → grace → `SIGKILL`;
|
||||
- enables child subreaper mode so escaped grandchildren are reaped;
|
||||
- stops scheduling new actions after the first failure;
|
||||
- requires every declared output to exist as a regular file after exit 0;
|
||||
- parses depfiles and records discovered inputs with hashes;
|
||||
- rejects a depfile entry whose generated producer is not an ancestor.
|
||||
|
||||
Different profiles can run concurrently; the CLI itself loops over requested profiles sequentially. `fail_fast` is not exposed on the CLI.
|
||||
|
||||
:::callout{type="warning" title="Ctrl+C is not a graceful build cancel"}
|
||||
The scheduler supports stop tokens, but `vbs build` and `vbs test` do not install a `SignalWatcher` in 1.0.0. Only `vbs watch`, `vbs compdb watch` and the daemon do. An interactive Ctrl+C can kill the parent without group cleanup; use the daemon or a supervising process when clean cancellation matters.
|
||||
:::
|
||||
|
||||
## Action keys and cache lookup
|
||||
|
||||
There are two keys:
|
||||
|
||||
1. **Graph-time key** over `vbs-action-v1`, profile identity, toolchain identity, kind, target, executable, argv, response-file content, environment, declared input paths, declared output paths, the whole snapshot id and the nondeterministic flag.
|
||||
2. **Execution-time key** that additionally hashes every declared input file's bytes, so a changed upstream artifact invalidates its consumers.
|
||||
|
||||
A cache hit must also:
|
||||
|
||||
- re-verify every discovered depfile input;
|
||||
- re-verify recorded output digests;
|
||||
- restore missing outputs from the CAS.
|
||||
|
||||
Every declared output is copied to the CAS before the success record is committed. A missing or corrupt blob drops the record.
|
||||
|
||||
Because the key includes the whole-project snapshot id, any source edit re-keys all actions. Only a true no-op is fully cached; this is a known incrementality limit.
|
||||
|
||||
## State store and CAS
|
||||
|
||||
`StateStore::open(<build>/.vbs)` owns:
|
||||
|
||||
```text
|
||||
.vbs/
|
||||
├── cas/blobs/<2>/<sha256> # immutable, 0444
|
||||
├── staging/ # transient; cleaned by recover()
|
||||
├── leases/ # pid/profile/pinned blobs
|
||||
├── state/state.v1.json # JSON fallback
|
||||
├── state/state.v2.sqlite # Void::Sqlite backend when linked
|
||||
└── state/state.lock
|
||||
```
|
||||
|
||||
- The CMake bootstrap links `Void::Sqlite` and uses `state.v2.sqlite`; a self-hosted `vbs` built by the current `build.cpp` does not link SQLite and uses the JSON store.
|
||||
- An existing JSON database is imported once into an empty SQLite store.
|
||||
- Writes use the state lock; an in-memory snapshot is reused while the database stat fingerprint is unchanged.
|
||||
- `recover()` removes uncommitted staging, dead leases, and action records whose blobs fail verification. It never invents success.
|
||||
- `gc()` removes blobs not pinned by a record or live lease. `--max-bytes` is a **quota check**: if pinned data exceeds it, GC fails; there is no LRU eviction.
|
||||
|
||||
## Remote cache
|
||||
|
||||
The remote CAS protocol is described in [Remote cache and workers](/build-system/consumer/remote-ci). Internally:
|
||||
|
||||
- only local misses consult the remote cache;
|
||||
- only cacheable, deterministic actions participate;
|
||||
- remote keys normalize `${SNAPSHOT}`, `${PROFILE}`, `${BUILD}` and `${PROJECT}` prefixes and reduce external executables to basenames;
|
||||
- downloaded blobs are SHA-256 verified before entering the local CAS;
|
||||
- uploads happen after local commit and are best-effort;
|
||||
- `--no-cache` disables reads but not writes;
|
||||
- `--offline` does not disable remote-cache traffic.
|
||||
|
||||
## Watchers and editor generations
|
||||
|
||||
`InotifyWatcher` (Linux inotify, Windows backend) coalesces bursts with a 40 ms debounce. `run_watch_loop` reconciles on events, a periodic tick, overflow/rescan, or a changed editor selection.
|
||||
|
||||
Two modes:
|
||||
|
||||
| Mode | Behavior |
|
||||
| --- | --- |
|
||||
| `MetadataOnly` | Compiles/evaluates the descriptor, probes the toolchain, lowers the graph, publishes the compilation database and stops. No builds, no providers, no fetch/lock writes, snapshot without materialization. |
|
||||
| `FullBuild` | Additionally executes the selected action closure. Foreign provider metadata is read-only; stale providers are reported, not rebuilt. |
|
||||
|
||||
Editor selection is governed by a project-level ticket in `<project>/.vbs/editor_selection.json`:
|
||||
|
||||
- a ticket is reserved before descriptor compilation;
|
||||
- a build publishes its generation before executing actions, so a compile failure does not hide fresh flags;
|
||||
- a later ticket wins; a late completion with an older ticket cannot overwrite it;
|
||||
- each generation is immutable under `profiles/<p>/editor/generations/<id>/`;
|
||||
- the profile pointer is swapped atomically; the project-root alias is only touched when absent or VBS-owned;
|
||||
- stale/invalid status keeps the last valid database identifiable.
|
||||
|
||||
## Known execution limits
|
||||
|
||||
- No snapshot in the daemon build path; daemon keys differ from CLI keys.
|
||||
- No graceful `SIGINT` handling for `vbs build`/`vbs test`.
|
||||
- Whole-snapshot action keys prevent single-file incremental reuse.
|
||||
- Lookup guards and freshness checks are not exercised by production builds.
|
||||
- `ModuleScan` is not scheduled as a DAG action.
|
||||
- PCH and MSan/LSan lack capability probes.
|
||||
- Remote downloads are buffered in memory rather than streamed.
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"slug": "build-system",
|
||||
"name": "VoidBuildSystem",
|
||||
"tagline": "A native C++26 build system and package manager for Void projects",
|
||||
"description": "Declare builds in ordinary build.cpp C++26, execute hermetic content-verified actions, and ship with a built-in solver, lockfile, package registry, remote cache, daemon, editor protocol and installers.",
|
||||
"version": "1.0.0",
|
||||
"status": "active",
|
||||
"accent": "#F97316",
|
||||
"icon": "layers",
|
||||
"repo_url": "https://git.faumaray.com/Void/Build-System",
|
||||
"order": 3,
|
||||
"badges": ["C++26", "GCC 16", "Zero-CMake self-host", "Built-in registry", "Linux + Wine"],
|
||||
"sections": [
|
||||
{"id": "getting-started", "title": "Getting Started", "track": "consumer", "order": 1},
|
||||
{"id": "descriptions", "title": "Build Descriptions", "track": "consumer", "order": 2},
|
||||
{"id": "dependencies", "title": "Dependencies & Packages", "track": "consumer", "order": 3},
|
||||
{"id": "workspaces", "title": "Workspaces", "track": "consumer", "order": 4},
|
||||
{"id": "workflows", "title": "Daily Workflows", "track": "consumer", "order": 5},
|
||||
{"id": "editors", "title": "Editors & Daemon", "track": "consumer", "order": 6},
|
||||
{"id": "testing", "title": "Testing & Reports", "track": "consumer", "order": 7},
|
||||
{"id": "remote", "title": "Remote & CI", "track": "consumer", "order": 8},
|
||||
{"id": "shipping", "title": "Shipping & Publishing", "track": "consumer", "order": 9},
|
||||
{"id": "architecture", "title": "Architecture", "track": "developer", "order": 1},
|
||||
{"id": "internals", "title": "Configuration & Execution", "track": "developer", "order": 2},
|
||||
{"id": "packages", "title": "Packages & Providers", "track": "developer", "order": 3},
|
||||
{"id": "registry", "title": "Registry & Remote", "track": "developer", "order": 4},
|
||||
{"id": "selfhost", "title": "Self-Hosting & Releases", "track": "developer", "order": 5},
|
||||
{"id": "quality", "title": "Quality & Status", "track": "developer", "order": 6}
|
||||
],
|
||||
"learning_paths": [
|
||||
{
|
||||
"id": "adopt-vbs",
|
||||
"title": "Build and ship a project with VoidBuildSystem",
|
||||
"audience": "consumer",
|
||||
"description": "Bootstrap the tool, declare a project in C++26, add dependencies and workspaces, wire an editor, run the test matrix, and publish verifiable artifacts.",
|
||||
"steps": [
|
||||
{"title": "Install and build your first project", "description": "Requirements, bootstrap, vbs init, build, test and output layout.", "track": "consumer", "slug": "getting-started"},
|
||||
{"title": "Declare targets and profiles", "description": "build.cpp, usage requirements, custom actions, shaders and profile contexts.", "track": "consumer", "slug": "build-descriptions"},
|
||||
{"title": "Add dependencies", "description": "C++ and TOML declarations, lockfile, providers, registry packages and signing.", "track": "consumer", "slug": "dependencies"},
|
||||
{"title": "Use the everyday CLI", "description": "Build, test, clean, doctor, graph, describe, watch and compdb commands.", "track": "consumer", "slug": "command-reference"},
|
||||
{"title": "Connect an editor", "description": "Compilation databases, editor configs, presets and the local daemon.", "track": "consumer", "slug": "editors"},
|
||||
{"title": "Run the test matrix", "description": "VOID_TEST targets, labels, resources, fixtures, JUnit, CDash and coverage.", "track": "consumer", "slug": "testing"},
|
||||
{"title": "Ship and publish", "description": "Install trees, installer archives, SBOMs, signatures, releases and binary variants.", "track": "consumer", "slug": "shipping"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "work-on-vbs",
|
||||
"title": "Take a change through the VBS engine",
|
||||
"audience": "developer",
|
||||
"description": "Follow a build from the C++ descriptor through graph lowering, snapshots, execution and caching, then through packaging, the registry and the release pipeline.",
|
||||
"steps": [
|
||||
{"title": "Map the architecture", "description": "Layers, ownership boundaries and the end-to-end control flow.", "track": "developer", "slug": "architecture"},
|
||||
{"title": "Understand configuration and graphs", "description": "Descriptor compilation, profile evaluation, target lowering and validation.", "track": "developer", "slug": "configuration-and-graph"},
|
||||
{"title": "Trace snapshots and execution", "description": "Immutable inputs, toolchain probes, scheduler, CAS and determinism guarantees.", "track": "developer", "slug": "snapshots-and-execution"},
|
||||
{"title": "Work on packages and providers", "description": "TOML model, solver, lockfile, fetch, native/CMake/Meson/Conan translation.", "track": "developer", "slug": "packages-and-providers"},
|
||||
{"title": "Inspect the registry and remote paths", "description": "HTTP API, RBAC, CAS, worker protocol and the daemon.", "track": "developer", "slug": "registry-internals"},
|
||||
{"title": "Reproduce a self-hosted release", "description": "Bootstrap stages, bit-identical rebuilds and the CI packaging matrix.", "track": "developer", "slug": "self-hosting"},
|
||||
{"title": "Check quality and status", "description": "Test suites, fuzzing, benchmarks, platform limits and known gaps.", "track": "developer", "slug": "quality-and-status"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -122,12 +122,12 @@ first, then what makes VBS *better* rather than merely equal.
|
||||
3. **Platform breadth - deferred.** Native MSVC and Apple Clang/macOS stay deferred by
|
||||
decision; MinGW cross + Wine is the current Windows story.
|
||||
4. **Package-generator parity.** CPack also ships NuGet, PKG/productbuild, APK and IFW
|
||||
installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX and UDIF. NuGet and PKG are the next
|
||||
useful ones.
|
||||
installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX, UDIF and NuGet (Wave 144). PKG is
|
||||
the next useful one.
|
||||
|
||||
### 8.2 Developer experience and IDE integration
|
||||
|
||||
6. **Coverage reporting.** `vbs test --coverage` producing lcov XML (gcov for GCC,
|
||||
6. **Coverage reporting - done (Wave 145).** `vbs test --coverage` produces lcov (gcov for GCC,
|
||||
llvm-cov for Clang) alongside JUnit. CMake has `CTestCoverageCollectGCOV`; Meson has the
|
||||
`b_coverage` option.
|
||||
7. **Test repetition controls.** CTest offers `--repeat until-fail|after-timeout|until-pass`,
|
||||
|
||||
+15
-1
@@ -16,7 +16,21 @@ if [ -d "$root/fuzz/seeds" ]; then
|
||||
cp -n "$root/fuzz/seeds/"* "$corpus/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
clang++ -std=c++26 -O1 -g -fsanitize=fuzzer,address,undefined \
|
||||
# Use the newest C++ standard the installed Clang accepts (older distributions stop at
|
||||
# C++23, spelled c++2b there).
|
||||
std_flag="${VBS_FUZZ_STD:-}"
|
||||
if [ -z "$std_flag" ]; then
|
||||
for candidate in c++26 c++2b c++23; do
|
||||
if clang++ "-std=$candidate" -fsyntax-only -x c++ /dev/null >/dev/null 2>&1; then
|
||||
std_flag="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
: "${std_flag:?clang++ accepts none of c++26/c++2b/c++23}"
|
||||
echo "fuzzing with -std=$std_flag"
|
||||
|
||||
clang++ "-std=$std_flag" -O1 -g -fsanitize=fuzzer,address,undefined \
|
||||
-fno-omit-frame-pointer \
|
||||
-I"$root/include" -I"$root/recipes" -I"$VOID_INCLUDE_DIR" \
|
||||
"$root/fuzz/fuzz_parsers.cpp" -o "$out/fuzz_parsers"
|
||||
|
||||
@@ -33,8 +33,11 @@ enum class HostOs { Linux, MacOS, Windows, Unknown };
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
// macOS/Windows ports are planned (Track C2/C3); the process and file backends
|
||||
// currently support Linux hosts only.
|
||||
[[nodiscard]] constexpr bool host_supported() noexcept { return host_os() == HostOs::Linux; }
|
||||
// Linux (including WSL) and Windows (MinGW-w64 / MSYS2) hosts are supported;
|
||||
// the macOS port is planned (Track C2). On Windows the daemon transport and the
|
||||
// registry service are not available yet (Track C3).
|
||||
[[nodiscard]] constexpr bool host_supported() noexcept {
|
||||
return host_os() == HostOs::Linux || host_os() == HostOs::Windows;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Platform
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Build::Report {
|
||||
|
||||
struct CoverageSummary {
|
||||
std::size_t files{0};
|
||||
std::size_t lines_found{0};
|
||||
std::size_t lines_hit{0};
|
||||
};
|
||||
|
||||
// Every `.gcda` profile data file under `root` (e.g. a profile build directory).
|
||||
[[nodiscard]] std::vector<std::filesystem::path>
|
||||
collect_gcda_files(const std::filesystem::path &root);
|
||||
|
||||
// Converts gcov data into `output_dir/coverage.info` (lcov) and `output_dir/summary.txt`.
|
||||
// Requires the `gcov` executable (part of the GCC/Clang toolchain); when `source_root` is
|
||||
// non-empty only sources below it are reported (system headers are dropped).
|
||||
[[nodiscard]] Void::Result::Result<CoverageSummary, Void::Result::Error>
|
||||
write_coverage_report(const std::vector<std::filesystem::path> &gcda_files,
|
||||
const std::filesystem::path &output_dir,
|
||||
const std::filesystem::path &source_root = {},
|
||||
const std::string &gcov_executable = "gcov");
|
||||
|
||||
} // namespace Void::Build::Report
|
||||
@@ -227,17 +227,14 @@ Void::Result::Result<void, Void::Result::Error> HttpServer::start(const HttpServ
|
||||
}
|
||||
bridged.body = request.body;
|
||||
|
||||
// HEAD is routed exactly like GET; the body is dropped but Content-Length is preserved.
|
||||
// HEAD is routed exactly like GET; the body stays so the transport can
|
||||
// derive the GET Content-Length, and Void::Net suppresses the body itself.
|
||||
const bool head_only = request.method == Void::Net::Method::Head;
|
||||
if (head_only) {
|
||||
bridged.method = "GET";
|
||||
}
|
||||
HttpResponse response = handler(bridged);
|
||||
apply_default_security_headers(response);
|
||||
if (head_only) {
|
||||
response.headers["Content-Length"] = std::to_string(response.body.size());
|
||||
response.body.clear();
|
||||
}
|
||||
Void::Net::ServerResponse net_response;
|
||||
net_response.status = response.status;
|
||||
for (const auto &[name, value] : response.headers) {
|
||||
|
||||
+59
-10
@@ -40,25 +40,25 @@
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <poll.h>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <system_error>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
// The daemon control socket is a POSIX Unix-domain socket (Linux/macOS). Windows support is
|
||||
// planned (Track C3) and would need a named-pipe transport instead.
|
||||
#if defined(_WIN32)
|
||||
#error \
|
||||
"The vbs daemon Unix-socket transport requires a POSIX host (Track C3 Windows port is planned)."
|
||||
#endif
|
||||
// The daemon control socket is a POSIX Unix-domain socket (Linux/macOS); the
|
||||
// Windows named-pipe transport is planned for Track C3.
|
||||
#include <vector>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32)
|
||||
namespace Void::Build::Daemon {
|
||||
namespace {
|
||||
|
||||
@@ -795,6 +795,9 @@ Void::Result::Result<BuildOutcome, std::string> execute_project_build(
|
||||
failure.emplace("target", JsonValue{result.target_name});
|
||||
failure.emplace("error", JsonValue{result.error_message});
|
||||
outcome.failed_actions.emplace_back(std::move(failure));
|
||||
} else if (!result.from_cache && !result.stderr_data.empty()) {
|
||||
// Do not drop compiler warnings from successful actions.
|
||||
Void::Log::warn("Daemon", "{}", result.stderr_data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3099,3 +3102,49 @@ request(const std::filesystem::path &socket_path, std::string_view request_json,
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Daemon
|
||||
|
||||
#else
|
||||
namespace Void::Build::Daemon {
|
||||
|
||||
struct DaemonServer::Impl {};
|
||||
|
||||
DaemonServer::~DaemonServer() = default;
|
||||
DaemonServer::DaemonServer(DaemonServer &&) noexcept = default;
|
||||
DaemonServer &DaemonServer::operator=(DaemonServer &&) noexcept = default;
|
||||
DaemonServer::DaemonServer(std::unique_ptr<Impl> impl) noexcept : impl_{std::move(impl)} {}
|
||||
|
||||
Void::Result::Result<DaemonServer, Void::Result::Error>
|
||||
DaemonServer::create(DaemonOptions options) {
|
||||
(void)options;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> DaemonServer::run(std::stop_token stop) {
|
||||
(void)stop;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
const std::filesystem::path &DaemonServer::socket_path() const noexcept {
|
||||
static const std::filesystem::path empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
DaemonStatus DaemonServer::status() const { return {}; }
|
||||
|
||||
Void::Result::Result<std::string, Void::Result::Error>
|
||||
request(const std::filesystem::path &socket_path, std::string_view request_json,
|
||||
std::chrono::milliseconds timeout) {
|
||||
(void)socket_path;
|
||||
(void)request_json;
|
||||
(void)timeout;
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::unsupported,
|
||||
"vbs daemon: the Windows named-pipe transport is not implemented (Track C3)")};
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Daemon
|
||||
#endif
|
||||
@@ -705,6 +705,14 @@ execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||
Platform::ProcessRequest preq;
|
||||
preq.executable = act.executable;
|
||||
preq.arguments = act.arguments;
|
||||
{
|
||||
std::string command_line = act.executable.string();
|
||||
for (const auto &arg : act.arguments) {
|
||||
command_line += ' ';
|
||||
command_line += arg;
|
||||
}
|
||||
Void::Log::debug("Build", "Exec {}", command_line);
|
||||
}
|
||||
if (!act.working_directory.empty()) {
|
||||
preq.working_directory = act.working_directory;
|
||||
}
|
||||
|
||||
+1
-1
@@ -530,7 +530,7 @@ expand_glob(const std::filesystem::path &project_root, std::string_view pattern)
|
||||
const std::filesystem::path raw_pattern{std::string{pattern}};
|
||||
if (raw_pattern.is_absolute()) {
|
||||
const auto rel_pattern = raw_pattern.lexically_relative(canonical_root);
|
||||
if (!rel_pattern.empty() && rel_pattern.native().starts_with("..")) {
|
||||
if (!rel_pattern.empty() && rel_pattern.generic_string().starts_with("..")) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("expand_glob: pattern '{}' escapes project root '{}'",
|
||||
pattern, canonical_root.string()))};
|
||||
|
||||
@@ -635,6 +635,131 @@ write_dmg_archive(const std::filesystem::path &output, const std::filesystem::pa
|
||||
return {};
|
||||
}
|
||||
|
||||
// ── NuGet package (.nupkg) ─────────────────────────────────────────────────────────────────
|
||||
// A .nupkg is an OPC ZIP (a nuspec manifest plus content parts). Native assets follow the
|
||||
// `runtimes/<rid>/native` convention; public headers go to `build/native/include`.
|
||||
std::string nuget_rid(std::string_view os, std::string_view architecture) {
|
||||
const std::string arch = architecture == "aarch64" || architecture == "arm64" ? "arm64"
|
||||
: architecture == "x86" || architecture == "i686" ? "x86"
|
||||
: "x64";
|
||||
const auto lower_os = Void::Str::to_lower_ascii(os);
|
||||
if (lower_os == "windows" || lower_os == "win32") {
|
||||
return "win-" + arch;
|
||||
}
|
||||
if (lower_os == "darwin" || lower_os == "macos") {
|
||||
return "osx-" + arch;
|
||||
}
|
||||
return "linux-" + arch;
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
write_nuget_package(const std::filesystem::path &output, const InstallOptions &options,
|
||||
const Graph::BuildGraph &graph,
|
||||
const std::vector<Package::ArchiveEntrySpec> &entries) {
|
||||
const std::string id = options.package_name;
|
||||
const std::string version =
|
||||
options.package_version.empty() ? std::string{"1.0.0"} : options.package_version;
|
||||
const std::string rid = nuget_rid(graph.profile.os, graph.profile.architecture);
|
||||
const std::string authors =
|
||||
options.maintainer.empty() ? std::string{"Void"} : options.maintainer;
|
||||
const std::string description = options.package_description.empty()
|
||||
? options.package_name
|
||||
: options.package_description;
|
||||
|
||||
// Map the installed tree onto the NuGet layout.
|
||||
std::vector<std::pair<std::string, std::filesystem::path>> mapped;
|
||||
std::set<std::string> extensions;
|
||||
for (const auto &entry : entries) {
|
||||
const auto rel = entry.archive_path;
|
||||
std::string dest;
|
||||
if (rel.starts_with("include/")) {
|
||||
dest = "build/native/include/" + rel.substr(std::string{"include/"}.size());
|
||||
} else {
|
||||
dest = "runtimes/" + rid + "/native/" + rel;
|
||||
}
|
||||
mapped.emplace_back(dest, entry.source_file);
|
||||
const auto dot = dest.rfind('.');
|
||||
if (dot != std::string::npos && dot > dest.rfind('/')) {
|
||||
extensions.insert(dest.substr(dot + 1));
|
||||
}
|
||||
}
|
||||
|
||||
const std::string nuspec =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
"<package xmlns=\"http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd\">\n"
|
||||
" <metadata>\n"
|
||||
" <id>" +
|
||||
wix_xml_escape(id) + "</id>\n"
|
||||
" <version>" + wix_xml_escape(version) + "</version>\n"
|
||||
" <authors>" + wix_xml_escape(authors) + "</authors>\n"
|
||||
" <description>" + wix_xml_escape(description) + "</description>\n"
|
||||
" <tags>native;c++;vbs</tags>\n"
|
||||
" </metadata>\n"
|
||||
"</package>\n";
|
||||
|
||||
std::string content_types =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
"<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n"
|
||||
" <Default Extension=\"rels\" "
|
||||
"ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\n"
|
||||
" <Default Extension=\"nuspec\" ContentType=\"application/octet\" />\n";
|
||||
for (const auto &ext : extensions) {
|
||||
content_types += " <Default Extension=\"" + wix_xml_escape(ext) +
|
||||
"\" ContentType=\"application/octet\" />\n";
|
||||
}
|
||||
content_types += "</Types>\n";
|
||||
|
||||
const std::string rels =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
||||
"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n"
|
||||
" <Relationship Type=\"http://schemas.microsoft.com/packaging/2010/07/manifest\" "
|
||||
"Target=\"/" +
|
||||
wix_xml_escape(id) +
|
||||
".nuspec\" Id=\"Re0\" />\n"
|
||||
"</Relationships>\n";
|
||||
|
||||
const auto staging = output.parent_path() / (output.filename().string() + ".stage");
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(staging, ec);
|
||||
std::filesystem::create_directories(staging, ec);
|
||||
if (ec) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::map_errno_to_system_code(ec.value()),
|
||||
std::format("cannot create NuGet staging directory '{}'", staging.string()),
|
||||
ec.value())};
|
||||
}
|
||||
auto cleanup = Void::Scope::on_exit([&] {
|
||||
std::error_code cleanup_ec;
|
||||
std::filesystem::remove_all(staging, cleanup_ec);
|
||||
});
|
||||
|
||||
std::vector<Package::ArchiveEntrySpec> zip_entries;
|
||||
const auto stage_file = [&](std::string_view name,
|
||||
std::string_view content) -> std::optional<std::filesystem::path> {
|
||||
const auto path = staging / std::filesystem::path{name};
|
||||
std::error_code file_ec;
|
||||
std::filesystem::create_directories(path.parent_path(), file_ec);
|
||||
if (auto written = Platform::atomic_write_file(path, content, true); !written) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
const auto nuspec_path = stage_file(id + ".nuspec", nuspec);
|
||||
const auto types_path = stage_file("[Content_Types].xml", content_types);
|
||||
const auto rels_path = stage_file("_rels/.rels", rels);
|
||||
if (!nuspec_path || !types_path || !rels_path) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::io_error, "cannot stage NuGet metadata")};
|
||||
}
|
||||
zip_entries.push_back({"[Content_Types].xml", *types_path, 0644u});
|
||||
zip_entries.push_back({"_rels/.rels", *rels_path, 0644u});
|
||||
zip_entries.push_back({id + ".nuspec", *nuspec_path, 0644u});
|
||||
for (const auto &[name, source] : mapped) {
|
||||
zip_entries.push_back({name, source, 0644u});
|
||||
}
|
||||
return Package::create_stored_zip(output, zip_entries);
|
||||
}
|
||||
|
||||
// Debian package: ar container with debian-binary, control.tar and data.tar (uncompressed).
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
write_deb_package(const std::filesystem::path &output, const InstallOptions &options,
|
||||
@@ -1090,6 +1215,12 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
if (auto packed = write_dmg_archive(*options.archive_path, payload); !packed) {
|
||||
return std::unexpected{packed.error()};
|
||||
}
|
||||
} else if (options.archive_format == "nuget") {
|
||||
if (auto packed =
|
||||
write_nuget_package(*options.archive_path, options, graph, archive_entries);
|
||||
!packed) {
|
||||
return std::unexpected{packed.error()};
|
||||
}
|
||||
} else {
|
||||
const bool archive_as_script = options.archive_format == "sh";
|
||||
const auto archive_target = archive_as_script
|
||||
|
||||
+221
-17
@@ -29,6 +29,7 @@
|
||||
#include <Void/Build/Provider/Provider.hpp>
|
||||
#include <Void/Build/Provider/Translator.hpp>
|
||||
#include <Void/Build/Report/Cdash.hpp>
|
||||
#include <Void/Build/Report/Coverage.hpp>
|
||||
#include <Void/Build/SelfHost/TestRegistryGen.hpp>
|
||||
#include <Void/Build/Snapshot/Snapshot.hpp>
|
||||
#include <Void/Build/State/StateStore.hpp>
|
||||
@@ -80,6 +81,19 @@ namespace {
|
||||
|
||||
using namespace Void::Build;
|
||||
|
||||
// Prints the compiler warnings/notes captured from actions that succeeded.
|
||||
// Only failures used to print their stderr, hiding warnings entirely.
|
||||
void print_action_warnings(const Execution::ExecutionReport &report) {
|
||||
for (const auto &result : report.results) {
|
||||
if (result.succeeded && !result.from_cache && !result.stderr_data.empty()) {
|
||||
std::cerr << result.stderr_data;
|
||||
if (result.stderr_data.back() != '\n') {
|
||||
std::cerr << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ANSI colors are enabled only for a terminal and are disabled by NO_COLOR or --no-color.
|
||||
bool g_no_color = false;
|
||||
|
||||
@@ -395,6 +409,7 @@ struct BuildCmdOptions {
|
||||
std::optional<std::string> target_os_arg;
|
||||
std::optional<std::string> target_arch_arg;
|
||||
std::optional<std::string> junit_arg;
|
||||
std::optional<std::string> coverage_arg;
|
||||
std::optional<std::string> cdash_arg;
|
||||
std::optional<std::string> cdash_project_arg;
|
||||
std::optional<std::string> cdash_build_arg;
|
||||
@@ -438,9 +453,26 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
jobs = static_cast<std::size_t>(parsed_jobs);
|
||||
}
|
||||
|
||||
const std::filesystem::path project_root{opts.project_arg};
|
||||
// Absolute roots: actions run with their own working directory, so relative
|
||||
// paths baked into the graph (e.g. a dependency's snapshot sources) would not
|
||||
// resolve.
|
||||
std::error_code root_ec;
|
||||
const std::filesystem::path project_root =
|
||||
std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal();
|
||||
if (root_ec) {
|
||||
std::cerr << cmd_name << ": cannot resolve project directory '"
|
||||
<< opts.project_arg << "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
const std::filesystem::path build_root =
|
||||
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
|
||||
opts.build_arg
|
||||
? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal()
|
||||
: (project_root / "build");
|
||||
if (root_ec) {
|
||||
std::cerr << cmd_name << ": cannot resolve build directory '" << *opts.build_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto trusted_keys =
|
||||
combine_trusted_keys(opts.trusted_public_keys, opts.trusted_key_files, project_root);
|
||||
if (!trusted_keys) {
|
||||
@@ -543,6 +575,12 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
std::cerr << "vbs: " << ex.what() << '\n';
|
||||
return 2;
|
||||
}
|
||||
if (opts.coverage_arg) {
|
||||
// Instrument every compile and link so gcov data is produced when tests run.
|
||||
// (GCC and Clang both accept --coverage.)
|
||||
ctx.compile_options.push_back("--coverage");
|
||||
ctx.link_options.push_back("--coverage");
|
||||
}
|
||||
|
||||
auto tc = Toolchain::discover_and_probe(ctx, build_root / ".vbs" / "probes");
|
||||
if (!tc) {
|
||||
@@ -781,6 +819,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
all_ok = false;
|
||||
continue;
|
||||
}
|
||||
print_action_warnings(*rep);
|
||||
Void::Log::info("Build", "[{}] Finished in {:.2f}s ({} executed, {} cached)", prof_name,
|
||||
prof_sw.elapsed_ms() / 1000.0, rep->executed_count, rep->cached_count);
|
||||
std::cout << "vbs: [" << prof_name << "] built (" << rep->executed_count << " executed, "
|
||||
@@ -1102,6 +1141,27 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
}
|
||||
}
|
||||
|
||||
// lcov coverage report from the gcov data produced by the instrumented test binaries.
|
||||
if (run_tests && opts.coverage_arg) {
|
||||
const auto gcda = Report::collect_gcda_files(build_root);
|
||||
std::error_code cov_ec;
|
||||
const auto source_root = std::filesystem::weakly_canonical(project_root, cov_ec);
|
||||
auto cov = Report::write_coverage_report(gcda, *opts.coverage_arg, source_root);
|
||||
if (!cov) {
|
||||
std::cerr << "vbs test: " << cov.error().message() << '\n';
|
||||
all_ok = false;
|
||||
} else {
|
||||
const double percent =
|
||||
cov->lines_found == 0
|
||||
? 0.0
|
||||
: 100.0 * static_cast<double>(cov->lines_hit) /
|
||||
static_cast<double>(cov->lines_found);
|
||||
Void::Log::info("Test", "Coverage {:.1f}% ({}/{} lines) across {} file(s) -> {}", percent,
|
||||
cov->lines_hit, cov->lines_found, cov->files,
|
||||
(std::filesystem::path{*opts.coverage_arg} / "coverage.info").string());
|
||||
}
|
||||
}
|
||||
|
||||
// JUnit XML report for CI systems (aggregated across selected profiles).
|
||||
if (opts.junit_arg && !opts.junit_arg->empty() && !test_records.empty()) {
|
||||
const auto xml_escape = [](std::string_view text) {
|
||||
@@ -1196,7 +1256,11 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
||||
const std::time_t now =
|
||||
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &now);
|
||||
#else
|
||||
::gmtime_r(&now, &tm);
|
||||
#endif
|
||||
cdash.build_stamp =
|
||||
std::format("{:04d}{:02d}{:02d}-{:02d}{:02d}-Experimental", tm.tm_year + 1900,
|
||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min);
|
||||
@@ -1272,7 +1336,7 @@ int execute_workspace(BuildCmdOptions opts, bool run_tests) {
|
||||
member_dirs[member.name] = canonical;
|
||||
const std::string env_name = "VBS_WORKSPACE_MEMBER_" + member.name;
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s(env_name.c_str(), canonical.c_str());
|
||||
(void)_putenv_s(env_name.c_str(), canonical.string().c_str());
|
||||
#else
|
||||
(void)::setenv(env_name.c_str(), canonical.c_str(), 1);
|
||||
#endif
|
||||
@@ -2505,6 +2569,9 @@ struct InstallCmdOptions {
|
||||
std::optional<std::string> build_arg;
|
||||
std::string profile_name{"debug"};
|
||||
std::optional<std::string> compiler_arg;
|
||||
std::optional<std::string> target_os_arg;
|
||||
std::optional<std::string> target_arch_arg;
|
||||
std::optional<std::string> jobs_arg;
|
||||
std::optional<std::string> prefix_arg;
|
||||
std::optional<std::string> pkg_name_arg;
|
||||
std::string pkg_ver{"0.1.0"};
|
||||
@@ -2532,10 +2599,35 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
std::size_t jobs = 0;
|
||||
if (opts.jobs_arg) {
|
||||
int parsed_jobs = 0;
|
||||
if (!Void::Str::to_int(*opts.jobs_arg, parsed_jobs) || parsed_jobs < 0) {
|
||||
std::cerr << "vbs install: invalid --jobs value '" << *opts.jobs_arg << "'\n";
|
||||
return 2;
|
||||
}
|
||||
jobs = static_cast<std::size_t>(parsed_jobs);
|
||||
}
|
||||
|
||||
const std::filesystem::path project_root{opts.project_arg};
|
||||
// Absolute roots: the self-hosted dependency build runs actions with their
|
||||
// own working directory, so relative graph paths would not resolve.
|
||||
std::error_code root_ec;
|
||||
const std::filesystem::path project_root =
|
||||
std::filesystem::absolute(opts.project_arg, root_ec).lexically_normal();
|
||||
if (root_ec) {
|
||||
std::cerr << "vbs install: cannot resolve project directory '" << opts.project_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
const std::filesystem::path build_root =
|
||||
opts.build_arg ? std::filesystem::path{*opts.build_arg} : (project_root / "build");
|
||||
opts.build_arg
|
||||
? std::filesystem::absolute(*opts.build_arg, root_ec).lexically_normal()
|
||||
: (project_root / "build");
|
||||
if (root_ec) {
|
||||
std::cerr << "vbs install: cannot resolve build directory '" << *opts.build_arg
|
||||
<< "': " << root_ec.message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
Install::InstallOptions iopts;
|
||||
iopts.prefix = *opts.prefix_arg;
|
||||
@@ -2547,9 +2639,9 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh" &&
|
||||
opts.archive_format_arg != "zip" && opts.archive_format_arg != "deb" &&
|
||||
opts.archive_format_arg != "rpm" && opts.archive_format_arg != "wix" &&
|
||||
opts.archive_format_arg != "dmg") {
|
||||
opts.archive_format_arg != "dmg" && opts.archive_format_arg != "nuget") {
|
||||
std::cerr << "vbs install: unsupported --archive-format '" << opts.archive_format_arg
|
||||
<< "' (expected tar, sh, zip, deb, rpm, wix or dmg)\n";
|
||||
<< "' (expected tar, sh, zip, deb, rpm, wix, dmg or nuget)\n";
|
||||
return 2;
|
||||
}
|
||||
if (opts.archive_arg && !opts.archive_arg->empty()) {
|
||||
@@ -2589,8 +2681,9 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
}
|
||||
ProfileContext ctx;
|
||||
try {
|
||||
ctx = profs->resolve(opts.profile_name, compiler_override, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
ctx = profs->resolve(opts.profile_name, compiler_override,
|
||||
opts.target_os_arg.value_or(Toolchain::host_os_name()),
|
||||
opts.target_arch_arg.value_or(Toolchain::host_architecture_name()));
|
||||
} catch (const std::exception &ex) {
|
||||
std::cerr << "vbs install: " << ex.what() << '\n';
|
||||
return 2;
|
||||
@@ -2605,6 +2698,92 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
std::cerr << "vbs install: " << desc.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto state = State::StateStore::open(build_root / ".vbs");
|
||||
if (!state) {
|
||||
std::cerr << "vbs install: " << state.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Import declared dependencies like `vbs build`, so projects with external
|
||||
// dependencies (e.g. VoidLibrary) can be installed too.
|
||||
std::vector<Package::NormalizedDependency> toml_deps;
|
||||
for (const auto &dep_file : desc->dependency_files) {
|
||||
const auto dep_path = std::filesystem::path{dep_file}.is_absolute()
|
||||
? std::filesystem::path{dep_file}
|
||||
: (project_root / dep_file);
|
||||
auto loaded = Package::load_dependencies_toml(dep_path);
|
||||
if (!loaded) {
|
||||
std::cerr << "vbs install: " << loaded.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
toml_deps.insert(toml_deps.end(), loaded->begin(), loaded->end());
|
||||
}
|
||||
auto merged_deps = Package::merge_dependencies(desc->dependencies, toml_deps);
|
||||
if (!merged_deps) {
|
||||
std::cerr << "vbs install: " << merged_deps.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> imported_targets;
|
||||
if (!merged_deps->empty()) {
|
||||
auto pinned_lock = Package::load_pinned_lock(project_root / "vbs.lock");
|
||||
if (!pinned_lock) {
|
||||
std::cerr << "vbs install: " << pinned_lock.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto trusted_keys = combine_trusted_keys({}, {}, project_root);
|
||||
if (!trusted_keys) {
|
||||
std::cerr << "vbs install: " << trusted_keys.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto resolved =
|
||||
resolve_and_materialize_deps(ctx, *merged_deps, project_root, build_root,
|
||||
*pinned_lock, false, false, *trusted_keys);
|
||||
if (!resolved) {
|
||||
std::cerr << "vbs install: " << resolved.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
for (const auto &[dep_rec, mat] : resolved->materialized) {
|
||||
DependencyRecord effective_dep = dep_rec;
|
||||
if (effective_dep.builder.empty() &&
|
||||
effective_dep.source_kind == DependencySourceKind::Package) {
|
||||
std::error_code bec;
|
||||
if (std::filesystem::is_regular_file(mat.source_dir / "build.cpp", bec)) {
|
||||
effective_dep.builder = "native";
|
||||
} else if (std::filesystem::is_regular_file(mat.source_dir / "CMakeLists.txt",
|
||||
bec)) {
|
||||
effective_dep.builder = "cmake";
|
||||
} else if (std::filesystem::is_regular_file(mat.source_dir / "meson.build",
|
||||
bec)) {
|
||||
effective_dep.builder = "meson";
|
||||
}
|
||||
}
|
||||
if (effective_dep.builder == "cmake" || effective_dep.builder == "meson" ||
|
||||
effective_dep.builder == "conan" || effective_dep.builder == "native") {
|
||||
Provider::ProviderRequest preq{effective_dep,
|
||||
mat,
|
||||
ctx,
|
||||
*tc,
|
||||
build_root / ".vbs" / "providers",
|
||||
Provider::ProviderMode::FullBuild,
|
||||
{},
|
||||
fopts.sdk_include_dir,
|
||||
fopts.sdk_source_dir,
|
||||
fopts.sdk_library_path.empty()
|
||||
? std::nullopt
|
||||
: std::optional{fopts.sdk_library_path},
|
||||
&(*state),
|
||||
jobs};
|
||||
auto exported = Provider::resolve_foreign_provider(preq);
|
||||
if (!exported) {
|
||||
std::cerr << "vbs install: " << exported.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
for (const auto &[name, target] : exported->targets) {
|
||||
imported_targets[name] = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto snap_inputs = collect_snapshot_inputs(*desc, project_root);
|
||||
Snapshot::SnapshotOptions sopts;
|
||||
@@ -2617,25 +2796,43 @@ int execute_install_command(const InstallCmdOptions &opts) {
|
||||
std::cerr << "vbs install: " << snap.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto graph =
|
||||
Graph::lower_project_graph(*desc, *tc, {project_root, build_root, &(*snap), {}, 32768});
|
||||
auto graph = Graph::lower_project_graph(
|
||||
*desc, *tc,
|
||||
{project_root, build_root, &(*snap), std::move(imported_targets), 32768});
|
||||
if (!graph) {
|
||||
std::cerr << "vbs install: " << graph.error().message() << '\n';
|
||||
return 1;
|
||||
}
|
||||
auto state = State::StateStore::open(build_root / ".vbs");
|
||||
if (!state) {
|
||||
std::cerr << "vbs install: " << state.error().message() << '\n';
|
||||
return 1;
|
||||
// Only the targets that are actually installed (plus their dependencies)
|
||||
// need to be built: test executables and tools without install rules are
|
||||
// not part of the package.
|
||||
Execution::ExecutionOptions eopts;
|
||||
eopts.jobs = jobs;
|
||||
for (const auto &target : desc->targets) {
|
||||
if (target.install_rule) {
|
||||
eopts.selected_targets.push_back(target.name);
|
||||
}
|
||||
auto exec = Execution::execute_graph(*graph, *state);
|
||||
}
|
||||
auto exec = Execution::execute_graph(*graph, *state, eopts);
|
||||
if (!exec || !exec->succeeded) {
|
||||
std::cerr << "vbs install: build failed before staging\n";
|
||||
if (!exec) {
|
||||
std::cerr << exec.error().message() << '\n';
|
||||
} else {
|
||||
for (const auto &result : exec->results) {
|
||||
if (result.succeeded) {
|
||||
continue;
|
||||
}
|
||||
std::cerr << "vbs install: action '" << result.action_id
|
||||
<< "' failed: " << result.error_message << '\n';
|
||||
if (!result.stderr_data.empty()) {
|
||||
std::cerr << result.stderr_data << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
print_action_warnings(*exec);
|
||||
Void::Log::info("Install", "Staging and installing package '{}' ({}) to '{}'...",
|
||||
iopts.package_name, iopts.package_version, iopts.prefix.string());
|
||||
auto inst = Install::install_project(*desc, *graph, iopts);
|
||||
@@ -3636,6 +3833,8 @@ int main(int argc, char **argv) {
|
||||
.option_default("--test-timeout", "", "Per-test timeout in seconds (1..86400)",
|
||||
build_opts.test_timeout_arg, "300")
|
||||
.option("--junit", "", "Write a JUnit XML report of test results", build_opts.junit_arg)
|
||||
.option("--coverage", "", "Build with --coverage and write an lcov report to this directory",
|
||||
build_opts.coverage_arg)
|
||||
.option("--cdash", "", "Upload a CDash test report to this base URL",
|
||||
build_opts.cdash_arg)
|
||||
.option("--cdash-project", "", "CDash project name (default: project directory name)",
|
||||
@@ -3747,6 +3946,11 @@ int main(int argc, char **argv) {
|
||||
.option("--build-dir", "-B", "Build output directory", install_opts.build_arg)
|
||||
.option_default("--profile", "-p", "Profile name", install_opts.profile_name, "debug")
|
||||
.option("--compiler", "", "Override compiler family (gcc|clang)", install_opts.compiler_arg)
|
||||
.option("--target-os", "", "Target operating system (default: host, e.g. windows)",
|
||||
install_opts.target_os_arg)
|
||||
.option("--target-arch", "", "Target architecture (default: host, e.g. x86_64)",
|
||||
install_opts.target_arch_arg)
|
||||
.option("--jobs", "-j", "Parallel job count (0 = auto)", install_opts.jobs_arg)
|
||||
.option("--prefix", "", "Install destination prefix (required)", install_opts.prefix_arg)
|
||||
.option("--package-name", "", "Exported package name", install_opts.pkg_name_arg)
|
||||
.option_default("--package-version", "", "Exported package version", install_opts.pkg_ver,
|
||||
@@ -3762,7 +3966,7 @@ int main(int argc, char **argv) {
|
||||
.option("--archive", "", "Write a deterministic installer archive of the prefix",
|
||||
install_opts.archive_arg)
|
||||
.option_default("--archive-format", "",
|
||||
"Installer archive format: tar (default), sh, zip, deb, rpm, wix or dmg",
|
||||
"Installer archive format: tar (default), sh, zip, deb, rpm, wix, dmg or nuget",
|
||||
install_opts.archive_format_arg, "tar")
|
||||
.option("--signing-key", "",
|
||||
"Ed25519 seed file; signs the archive and writes .sha256/.sig/.pub",
|
||||
|
||||
@@ -18,16 +18,22 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <arpa/inet.h>
|
||||
#include <array>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Package {
|
||||
namespace {
|
||||
@@ -93,12 +99,49 @@ struct RawHttpReply {
|
||||
std::string body;
|
||||
};
|
||||
|
||||
bool send_all(int fd, std::string_view data) {
|
||||
#if defined(_WIN32)
|
||||
using SocketHandle = SOCKET;
|
||||
inline constexpr SocketHandle kInvalidSocket = INVALID_SOCKET;
|
||||
|
||||
void ensure_socket_runtime() {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
WSADATA data{};
|
||||
(void)::WSAStartup(MAKEWORD(2, 2), &data);
|
||||
});
|
||||
}
|
||||
|
||||
struct SocketGuard {
|
||||
SocketHandle handle{kInvalidSocket};
|
||||
~SocketGuard() {
|
||||
if (handle != kInvalidSocket) {
|
||||
::closesocket(handle);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool interrupted() { return ::WSAGetLastError() == WSAEINTR; }
|
||||
#else
|
||||
using SocketHandle = int;
|
||||
inline constexpr SocketHandle kInvalidSocket = -1;
|
||||
|
||||
void ensure_socket_runtime() {}
|
||||
|
||||
using SocketGuard = Void::System::OwnedFd;
|
||||
|
||||
bool interrupted() { return errno == EINTR; }
|
||||
#endif
|
||||
|
||||
bool send_all(SocketHandle fd, std::string_view data) {
|
||||
std::size_t off = 0;
|
||||
while (off < data.size()) {
|
||||
#if defined(_WIN32)
|
||||
const int n = ::send(fd, data.data() + off, static_cast<int>(data.size() - off), 0);
|
||||
#else
|
||||
const ssize_t n = ::send(fd, data.data() + off, data.size() - off, MSG_NOSIGNAL);
|
||||
#endif
|
||||
if (n < 0) {
|
||||
if (errno == EINTR) {
|
||||
if (interrupted()) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
@@ -154,6 +197,7 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
#else
|
||||
// Plain TCP HTTP/1.1 client for http:// (loopback/local registry without external deps).
|
||||
if (parsed.scheme == "http") {
|
||||
ensure_socket_runtime();
|
||||
struct addrinfo hints{};
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
@@ -166,18 +210,27 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
}
|
||||
auto free_ai = Void::Scope::on_exit([&] { ::freeaddrinfo(res); });
|
||||
|
||||
const int fd = ::socket(res->ai_family, res->ai_socktype | SOCK_CLOEXEC, res->ai_protocol);
|
||||
if (fd < 0) {
|
||||
const SocketHandle fd =
|
||||
::socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||
if (fd == kInvalidSocket) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry client: socket() failed")};
|
||||
}
|
||||
Void::System::OwnedFd guard{fd};
|
||||
SocketGuard guard{fd};
|
||||
|
||||
#if defined(_WIN32)
|
||||
DWORD timeout_ms = 30000;
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,
|
||||
reinterpret_cast<const char *>(&timeout_ms), sizeof(timeout_ms));
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO,
|
||||
reinterpret_cast<const char *>(&timeout_ms), sizeof(timeout_ms));
|
||||
#else
|
||||
struct timeval tv{30, 0};
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
(void)::setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||
#endif
|
||||
|
||||
if (::connect(fd, res->ai_addr, res->ai_addrlen) != 0) {
|
||||
if (::connect(fd, res->ai_addr, static_cast<int>(res->ai_addrlen)) != 0) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("registry client: connect to {}:{} failed", parsed.host, parsed.port))};
|
||||
@@ -204,7 +257,7 @@ send_http_request(const ParsedHttpUrl &parsed, std::string_view method, std::str
|
||||
raw.append(buf.data(), static_cast<std::size_t>(n));
|
||||
} else if (n == 0) {
|
||||
break;
|
||||
} else if (errno != EINTR) {
|
||||
} else if (!interrupted()) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::io_error,
|
||||
"registry client: recv() failed")};
|
||||
}
|
||||
|
||||
@@ -3,16 +3,23 @@
|
||||
#include <Void/System/Types.hpp>
|
||||
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <set>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(__linux__)
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__linux__) && !defined(_WIN32)
|
||||
#error \
|
||||
"VoidBuildSystem's process and file backends currently support Linux hosts only (Track C2/C3 ports are planned)"
|
||||
"VoidBuildSystem's process and file backends currently support Linux and Windows hosts only (Track C2/C3 ports are planned)"
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Platform {
|
||||
@@ -46,7 +53,7 @@ FileLock::acquire(const std::filesystem::path &lock_path, LockMode mode, bool no
|
||||
if (!res->has_value()) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::busy,
|
||||
std::format("FileLock: '{}' is already locked", lock_path.string()), EWOULDBLOCK)};
|
||||
std::format("FileLock: '{}' is already locked", lock_path.string()), EAGAIN)};
|
||||
}
|
||||
return FileLock{std::move(**res)};
|
||||
}
|
||||
@@ -59,6 +66,73 @@ FileLock::acquire(const std::filesystem::path &lock_path, LockMode mode, bool no
|
||||
|
||||
Void::Result::Result<FileMetadata, Void::Result::Error>
|
||||
stat_lstat(const std::filesystem::path &path) {
|
||||
#if defined(_WIN32)
|
||||
std::error_code ec;
|
||||
const auto status = std::filesystem::symlink_status(path, ec);
|
||||
if (ec) {
|
||||
if (ec == std::errc::no_such_file_or_directory || ec == std::errc::not_a_directory) {
|
||||
FileMetadata missing;
|
||||
return missing;
|
||||
}
|
||||
return std::unexpected{sys_err(
|
||||
ec.value(), std::format("stat_lstat: symlink_status failed for '{}': {}",
|
||||
path.string(), ec.message()))};
|
||||
}
|
||||
if (!std::filesystem::exists(status)) {
|
||||
FileMetadata missing;
|
||||
return missing;
|
||||
}
|
||||
|
||||
FileMetadata meta;
|
||||
meta.exists = true;
|
||||
meta.is_regular = std::filesystem::is_regular_file(status);
|
||||
meta.is_directory = std::filesystem::is_directory(status);
|
||||
meta.is_symlink = std::filesystem::is_symlink(status);
|
||||
if (meta.is_symlink) {
|
||||
std::error_code target_ec;
|
||||
const auto target = std::filesystem::read_symlink(path, target_ec);
|
||||
if (!target_ec) {
|
||||
meta.symlink_target = target.string();
|
||||
}
|
||||
}
|
||||
|
||||
const auto followed = std::filesystem::status(path, ec);
|
||||
if (!ec) {
|
||||
if (std::filesystem::is_regular_file(followed)) {
|
||||
const auto size = std::filesystem::file_size(path, ec);
|
||||
if (!ec) {
|
||||
meta.size = static_cast<std::uint64_t>(size);
|
||||
}
|
||||
ec.clear();
|
||||
}
|
||||
const auto mtime = std::filesystem::last_write_time(path, ec);
|
||||
if (!ec) {
|
||||
const auto sys = std::chrono::file_clock::to_sys(mtime);
|
||||
const auto secs = std::chrono::floor<std::chrono::seconds>(sys);
|
||||
meta.mtime_sec = static_cast<std::int64_t>(secs.time_since_epoch().count());
|
||||
meta.mtime_nsec = static_cast<std::int64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(sys - secs).count());
|
||||
}
|
||||
}
|
||||
|
||||
// Identity through a Win32 handle (volume serial, file index, link count).
|
||||
const HANDLE handle = ::CreateFileW(path.c_str(), FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS,
|
||||
nullptr);
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
BY_HANDLE_FILE_INFORMATION info{};
|
||||
if (::GetFileInformationByHandle(handle, &info) != 0) {
|
||||
meta.dev = info.dwVolumeSerialNumber;
|
||||
meta.ino = (static_cast<std::uint64_t>(info.nFileIndexHigh) << 32) |
|
||||
static_cast<std::uint64_t>(info.nFileIndexLow);
|
||||
meta.nlink = info.nNumberOfLinks;
|
||||
}
|
||||
::CloseHandle(handle);
|
||||
}
|
||||
meta.mode = meta.is_directory ? 0755u : 0644u;
|
||||
return meta;
|
||||
#else
|
||||
struct stat st{};
|
||||
if (::lstat(path.c_str(), &st) != 0) {
|
||||
const int err = errno;
|
||||
@@ -104,6 +178,7 @@ stat_lstat(const std::filesystem::path &path) {
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<bool, Void::Result::Error>
|
||||
@@ -127,9 +202,13 @@ copy_isolated(const std::filesystem::path &src, const std::filesystem::path &dst
|
||||
if (!res) {
|
||||
return std::unexpected{std::move(res.error())};
|
||||
}
|
||||
#if !defined(_WIN32)
|
||||
if (mode_override) {
|
||||
(void)::chmod(dst.c_str(), static_cast<mode_t>(*mode_override));
|
||||
}
|
||||
#else
|
||||
(void)mode_override;
|
||||
#endif
|
||||
return res->method == Void::FileSystem::CopyMethod::Reflink;
|
||||
}
|
||||
|
||||
@@ -172,6 +251,11 @@ Void::Result::Result<void, Void::Result::Error> atomic_write_file(const std::fil
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
fsync_directory(const std::filesystem::path &dir_path) {
|
||||
#if defined(_WIN32)
|
||||
// Windows has no directory fsync; MoveFileEx visibility is the durability guarantee.
|
||||
(void)dir_path;
|
||||
return {};
|
||||
#else
|
||||
const int fd = ::open(dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
const int err = errno;
|
||||
@@ -193,6 +277,7 @@ fsync_directory(const std::filesystem::path &dir_path) {
|
||||
return std::unexpected{
|
||||
sys_err(err, std::format("fsync_directory: fsync failed for '{}'", dir_path.string()))};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
@@ -316,6 +401,19 @@ resolve_confined_path(const std::filesystem::path &root, const std::filesystem::
|
||||
}
|
||||
|
||||
Void::Result::Result<std::filesystem::path, Void::Result::Error> current_executable_path() {
|
||||
#if defined(_WIN32)
|
||||
std::wstring buffer(32768, L'\0');
|
||||
const DWORD length =
|
||||
::GetModuleFileNameW(nullptr, buffer.data(), static_cast<DWORD>(buffer.size()));
|
||||
if (length == 0 || length >= buffer.size()) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("current_executable_path: GetModuleFileNameW failed ({})",
|
||||
::GetLastError()))};
|
||||
}
|
||||
buffer.resize(length);
|
||||
return std::filesystem::path{buffer};
|
||||
#else
|
||||
std::error_code ec;
|
||||
const auto path = std::filesystem::read_symlink("/proc/self/exe", ec);
|
||||
if (ec || path.empty()) {
|
||||
@@ -326,6 +424,7 @@ Void::Result::Result<std::filesystem::path, Void::Result::Error> current_executa
|
||||
ec.value())};
|
||||
}
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Platform
|
||||
@@ -4,32 +4,77 @@
|
||||
#include <Void/System/Process.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <cwctype>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__linux__)
|
||||
#if !defined(__linux__) && !defined(_WIN32)
|
||||
#error \
|
||||
"VoidBuildSystem's process and file backends currently support Linux hosts only (Track C2/C3 ports are planned)"
|
||||
"VoidBuildSystem's process and file backends currently support Linux and Windows hosts only (Track C2/C3 ports are planned)"
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Platform {
|
||||
namespace {
|
||||
|
||||
#if defined(_WIN32)
|
||||
constexpr char kPathSeparator = ';';
|
||||
#else
|
||||
constexpr char kPathSeparator = ':';
|
||||
#endif
|
||||
|
||||
bool is_executable_file(const std::filesystem::path &p) {
|
||||
#if defined(_WIN32)
|
||||
std::error_code ec;
|
||||
if (!std::filesystem::is_regular_file(p, ec)) {
|
||||
return false;
|
||||
}
|
||||
std::string ext = p.extension().string();
|
||||
std::ranges::transform(ext, ext.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
return ext.empty() || ext == ".exe" || ext == ".com" || ext == ".bat" || ext == ".cmd";
|
||||
#else
|
||||
struct stat st{};
|
||||
if (::stat(p.c_str(), &st) != 0) {
|
||||
return false;
|
||||
}
|
||||
return S_ISREG(st.st_mode) && ::access(p.c_str(), X_OK) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<std::filesystem::path> resolve_candidate(const std::filesystem::path &candidate) {
|
||||
std::vector<std::filesystem::path> names{candidate};
|
||||
#if defined(_WIN32)
|
||||
if (!candidate.has_extension()) {
|
||||
for (const char *ext : {".exe", ".cmd", ".bat", ".com"}) {
|
||||
names.push_back(candidate.string() + ext);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (const auto &name : names) {
|
||||
if (is_executable_file(name)) {
|
||||
std::error_code ec;
|
||||
auto abs = std::filesystem::absolute(name, ec);
|
||||
return ec ? name : abs.lexically_normal();
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void ensure_subreaper() noexcept {
|
||||
#if !defined(_WIN32)
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] { (void)Void::Process::enable_subreaper(); });
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -40,11 +85,14 @@ resolve_executable(const std::filesystem::path &executable,
|
||||
if (executable.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (executable.is_absolute() || executable.string().find('/') != std::string::npos) {
|
||||
if (executable.is_absolute() ||
|
||||
executable.string().find_first_of(std::string_view{"/\\"}) != std::string::npos) {
|
||||
std::error_code ec;
|
||||
const auto abs = std::filesystem::absolute(executable, ec);
|
||||
if (!ec && is_executable_file(abs)) {
|
||||
return abs.lexically_normal();
|
||||
if (!ec) {
|
||||
if (auto resolved = resolve_candidate(abs); resolved) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -58,21 +106,23 @@ resolve_executable(const std::filesystem::path &executable,
|
||||
}
|
||||
std::size_t start = 0;
|
||||
while (start <= path_env.size()) {
|
||||
const auto colon = path_env.find(':', start);
|
||||
const auto segment = path_env.substr(
|
||||
start, colon == std::string_view::npos ? std::string_view::npos : colon - start);
|
||||
const auto separator = path_env.find(kPathSeparator, start);
|
||||
auto segment = path_env.substr(
|
||||
start, separator == std::string_view::npos ? std::string_view::npos : separator - start);
|
||||
// Windows PATH entries may be quoted.
|
||||
if (segment.size() >= 2 && segment.front() == '"' && segment.back() == '"') {
|
||||
segment.remove_prefix(1);
|
||||
segment.remove_suffix(1);
|
||||
}
|
||||
const std::filesystem::path dir =
|
||||
segment.empty() ? std::filesystem::path{"."} : std::filesystem::path{segment};
|
||||
const auto candidate = dir / executable;
|
||||
if (is_executable_file(candidate)) {
|
||||
std::error_code ec;
|
||||
auto abs = std::filesystem::absolute(candidate, ec);
|
||||
return ec ? candidate : abs.lexically_normal();
|
||||
if (auto resolved = resolve_candidate(dir / executable); resolved) {
|
||||
return resolved;
|
||||
}
|
||||
if (colon == std::string_view::npos) {
|
||||
if (separator == std::string_view::npos) {
|
||||
break;
|
||||
}
|
||||
start = colon + 1;
|
||||
start = separator + 1;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -159,15 +209,19 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
|
||||
bool group_timed_out = comm->timed_out;
|
||||
bool group_cancelled = comm->cancelled;
|
||||
bool descendants_terminated = false;
|
||||
#if !defined(_WIN32)
|
||||
const pid_t pgid = static_cast<pid_t>(child->pgid());
|
||||
#endif
|
||||
if (!group_timed_out && !group_cancelled && !comm->overflowed) {
|
||||
const auto descendant_deadline =
|
||||
std::chrono::steady_clock::now() + request.descendant_grace;
|
||||
while (child->process_group_alive()) {
|
||||
#if !defined(_WIN32)
|
||||
// Reap any adopted descendants in this process group (subreaper) so zombies clear.
|
||||
int wstatus = 0;
|
||||
while (pgid > 0 && ::waitpid(-pgid, &wstatus, WNOHANG) > 0) {
|
||||
}
|
||||
#endif
|
||||
if (!child->process_group_alive()) {
|
||||
break;
|
||||
}
|
||||
@@ -192,6 +246,7 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
|
||||
if (group_cancelled || group_timed_out || descendants_terminated || comm->overflowed ||
|
||||
child->process_group_alive()) {
|
||||
(void)child->terminate(request.kill_grace);
|
||||
#if !defined(_WIN32)
|
||||
// Reap the whole group until it is really gone (bounded), so no zombie or orphan is
|
||||
// left behind after test supervision.
|
||||
const auto reap_deadline =
|
||||
@@ -210,6 +265,7 @@ run_supervised(const ProcessRequest &request, std::stop_token stop) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ProcessResult result;
|
||||
|
||||
@@ -18,7 +18,11 @@ using Util::json_quote;
|
||||
std::string iso8601(std::int64_t epoch) {
|
||||
const auto time = static_cast<std::time_t>(epoch);
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &time);
|
||||
#else
|
||||
::gmtime_r(&time, &tm);
|
||||
#endif
|
||||
char buffer[32];
|
||||
(void)std::strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", &tm);
|
||||
return buffer;
|
||||
|
||||
@@ -1037,7 +1037,10 @@ Void::Result::Result<ProviderExport, Void::Result::Error>
|
||||
run_native_provider(const ProviderRequest &request, const std::filesystem::path &build_dir,
|
||||
const std::string &input_hash, std::stop_token stop) {
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(build_dir, ec);
|
||||
// The directory is keyed by the provider input hash and backed by a
|
||||
// content-addressed state store, so stale objects are harmless. Do not wipe
|
||||
// it: another stage may still be compiling from its materialized snapshot
|
||||
// tree, and deleting it makes those sources disappear mid-build.
|
||||
std::filesystem::create_directories(build_dir, ec);
|
||||
|
||||
Graph::ProjectDescription desc;
|
||||
@@ -1069,6 +1072,9 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
||||
fopts.extra_environment["VBS_DEP_NAME"] = request.dependency.name;
|
||||
for (const auto &[key, value] : request.dependency.options) {
|
||||
fopts.extra_environment["VBS_DEP_OPTION_" + key] = cmake_option_value(value);
|
||||
// Dependencies may read their options from the plain environment
|
||||
// (VoidLibrary's build.cpp reads VOID_ENABLED_MODULES directly).
|
||||
fopts.extra_environment[key] = cmake_option_value(value);
|
||||
}
|
||||
auto compiled = Config::compile_descriptor(fopts);
|
||||
if (!compiled) {
|
||||
@@ -1165,6 +1171,28 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
||||
return std::unexpected{exec.error()};
|
||||
}
|
||||
if (!exec->succeeded) {
|
||||
// Void::Result::Error bounds its message, and a raw compiler stderr
|
||||
// starts with a long include chain: keep the error lines (or the tail)
|
||||
// so the actual diagnostic survives.
|
||||
const auto compact = [](std::string_view text) {
|
||||
std::string errors;
|
||||
std::size_t pos = 0;
|
||||
while (pos < text.size()) {
|
||||
const auto nl = text.find('\n', pos);
|
||||
const auto end = nl == std::string_view::npos ? text.size() : nl;
|
||||
const auto line = text.substr(pos, end - pos);
|
||||
if (line.find("error") != std::string_view::npos ||
|
||||
line.find("Error") != std::string_view::npos) {
|
||||
errors.append(line).push_back('\n');
|
||||
}
|
||||
pos = end + 1;
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
return errors;
|
||||
}
|
||||
constexpr std::size_t kTail = 900;
|
||||
return std::string{text.size() > kTail ? text.substr(text.size() - kTail) : text};
|
||||
};
|
||||
std::string detail;
|
||||
for (const auto &ar : exec->results) {
|
||||
if (!ar.succeeded) {
|
||||
@@ -1173,7 +1201,7 @@ run_native_provider(const ProviderRequest &request, const std::filesystem::path
|
||||
}
|
||||
detail += ar.action_id + ": " + ar.error_message;
|
||||
if (!ar.stderr_data.empty()) {
|
||||
detail += "\n" + ar.stderr_data;
|
||||
detail += "\n" + compact(ar.stderr_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Void/Build/Report/Cdash.hpp>
|
||||
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Core/Scope.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
@@ -11,9 +12,13 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <format>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(VBS_HAS_VOID_NET)
|
||||
#include <Void/Net/Http.hpp>
|
||||
@@ -61,17 +66,30 @@ std::string utc_timestamp() {
|
||||
const auto now = std::chrono::system_clock::now();
|
||||
const std::time_t seconds = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm tm{};
|
||||
#if defined(_WIN32)
|
||||
::gmtime_s(&tm, &seconds);
|
||||
#else
|
||||
::gmtime_r(&seconds, &tm);
|
||||
#endif
|
||||
return std::format("{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}", tm.tm_year + 1900,
|
||||
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
}
|
||||
|
||||
std::string host_name() {
|
||||
#if defined(_WIN32)
|
||||
char buffer[256]{};
|
||||
DWORD size = static_cast<DWORD>(sizeof(buffer) - 1);
|
||||
if (::GetComputerNameA(buffer, &size) != 0) {
|
||||
return buffer;
|
||||
}
|
||||
return "localhost";
|
||||
#else
|
||||
char buffer[256]{};
|
||||
if (::gethostname(buffer, sizeof(buffer) - 1) == 0) {
|
||||
return buffer;
|
||||
}
|
||||
return "localhost";
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -186,6 +204,44 @@ submit_cdash_report(std::string_view cdash_url, std::string_view project,
|
||||
response->body.substr(0, 200)))};
|
||||
}
|
||||
return {};
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
// Windows: curl performs the submission for http and https (Void::Net not linked).
|
||||
auto curl = Platform::resolve_executable("curl");
|
||||
if (!curl) {
|
||||
return std::unexpected{make_error(
|
||||
"CDash submission on Windows requires curl (Void::Net not linked)")};
|
||||
}
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = *curl;
|
||||
req.arguments = {"--silent",
|
||||
"--show-error",
|
||||
"-X",
|
||||
"POST",
|
||||
"-H",
|
||||
"Content-Type: " + submission.content_type,
|
||||
"--data-binary",
|
||||
"@-",
|
||||
"-w",
|
||||
"\n%{http_code}",
|
||||
std::format("{}://{}:{}{}", scheme, host, port, path)};
|
||||
req.stdin_data = submission.body;
|
||||
req.timeout = std::chrono::seconds{60};
|
||||
auto proc = Platform::run_supervised(req);
|
||||
if (!proc || !proc->succeeded()) {
|
||||
return std::unexpected{make_error(std::format(
|
||||
"CDash submission failed: {}",
|
||||
proc ? proc->stderr_data : proc.error().message()))};
|
||||
}
|
||||
int status = 0;
|
||||
if (const auto nl = proc->stdout_data.rfind('\n'); nl != std::string::npos) {
|
||||
(void)Void::Str::to_int(Void::Str::trim_ascii(proc->stdout_data.substr(nl + 1)), status);
|
||||
}
|
||||
if (status < 200 || status >= 300) {
|
||||
return std::unexpected{
|
||||
make_error(std::format("CDash submission rejected with HTTP {}", status))};
|
||||
}
|
||||
return {};
|
||||
#else
|
||||
// Plain TCP HTTP/1.1 POST for http:// (Void::Net server transport not linked).
|
||||
if (scheme != "http") {
|
||||
@@ -252,6 +308,7 @@ submit_cdash_report(std::string_view cdash_url, std::string_view project,
|
||||
}
|
||||
return {};
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Report
|
||||
@@ -0,0 +1,194 @@
|
||||
#include <Void/Build/Report/Coverage.hpp>
|
||||
|
||||
#include <Void/Build/Platform/FileOps.hpp>
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace Void::Build::Report {
|
||||
namespace {
|
||||
|
||||
using JsonVal = Void::Json::Strict::Value;
|
||||
|
||||
Void::Result::Error make_error(std::string msg) {
|
||||
return Void::System::make_system_error(Void::System::SystemErrorCode::invalid_argument,
|
||||
std::move(msg));
|
||||
}
|
||||
|
||||
const JsonVal *find_key(const JsonVal::Object &object, std::string_view key) {
|
||||
const auto it = object.find(std::string{key});
|
||||
return it == object.end() ? nullptr : &it->second;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::vector<std::filesystem::path> collect_gcda_files(const std::filesystem::path &root) {
|
||||
std::vector<std::filesystem::path> files;
|
||||
std::error_code ec;
|
||||
if (!std::filesystem::is_directory(root, ec)) {
|
||||
return files;
|
||||
}
|
||||
// Per-entry errors (dangling symlinks, unreadable dirs) must not abort the walk: a fresh
|
||||
// build tree can contain them while it is still being populated.
|
||||
try {
|
||||
for (const auto &entry : std::filesystem::recursive_directory_iterator(
|
||||
root, std::filesystem::directory_options::skip_permission_denied)) {
|
||||
std::error_code entry_ec;
|
||||
if (entry.is_regular_file(entry_ec) && !entry_ec &&
|
||||
entry.path().extension() == ".gcda") {
|
||||
files.push_back(entry.path());
|
||||
}
|
||||
}
|
||||
} catch (const std::filesystem::filesystem_error &) {
|
||||
// Keep whatever was collected before the unreadable subtree.
|
||||
}
|
||||
std::ranges::sort(files);
|
||||
return files;
|
||||
}
|
||||
|
||||
Void::Result::Result<CoverageSummary, Void::Result::Error>
|
||||
write_coverage_report(const std::vector<std::filesystem::path> &gcda_files,
|
||||
const std::filesystem::path &output_dir,
|
||||
const std::filesystem::path &source_root,
|
||||
const std::string &gcov_executable) {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(output_dir, ec);
|
||||
if (ec) {
|
||||
return std::unexpected{Void::System::make_system_error(
|
||||
Void::System::map_errno_to_system_code(ec.value()),
|
||||
std::format("cannot create coverage directory '{}': {}", output_dir.string(),
|
||||
ec.message()),
|
||||
ec.value())};
|
||||
}
|
||||
if (gcda_files.empty()) {
|
||||
return std::unexpected{make_error("no .gcda coverage data was produced")};
|
||||
}
|
||||
|
||||
// Source path -> line -> execution count (max across translation units that include it).
|
||||
std::map<std::string, std::map<std::int64_t, std::int64_t>, std::less<>> coverage;
|
||||
for (const auto &gcda : gcda_files) {
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = gcov_executable;
|
||||
req.arguments = {"--json-format", "--stdout", gcda.filename().string()};
|
||||
req.working_directory = gcda.parent_path();
|
||||
req.timeout = std::chrono::seconds{60};
|
||||
auto res = Platform::run_supervised(req);
|
||||
if (!res || !res->succeeded()) {
|
||||
return std::unexpected{make_error(std::format(
|
||||
"gcov failed for '{}': {}", gcda.string(),
|
||||
res ? res->stderr_data : res.error().message()))};
|
||||
}
|
||||
auto parsed = Void::Json::Strict::parse(res->stdout_data);
|
||||
if (!parsed) {
|
||||
return std::unexpected{make_error(
|
||||
std::format("gcov produced invalid JSON for '{}'", gcda.string()))};
|
||||
}
|
||||
const auto *root = std::get_if<JsonVal::Object>(&parsed->value);
|
||||
if (root == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::filesystem::path cwd;
|
||||
if (const auto *cwd_v = find_key(*root, "current_working_directory")) {
|
||||
if (const auto *text = std::get_if<std::string>(&cwd_v->value)) {
|
||||
cwd = *text;
|
||||
}
|
||||
}
|
||||
const auto *files_v = find_key(*root, "files");
|
||||
const auto *files = files_v ? std::get_if<JsonVal::Array>(&files_v->value) : nullptr;
|
||||
if (files == nullptr) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &file_entry : *files) {
|
||||
const auto *file_obj = std::get_if<JsonVal::Object>(&file_entry.value);
|
||||
if (file_obj == nullptr) {
|
||||
continue;
|
||||
}
|
||||
const auto *path_v = find_key(*file_obj, "file");
|
||||
const auto *path_text = path_v ? std::get_if<std::string>(&path_v->value) : nullptr;
|
||||
if (path_text == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::filesystem::path source{*path_text};
|
||||
if (source.is_relative()) {
|
||||
source = (cwd / source).lexically_normal();
|
||||
}
|
||||
if (!source_root.empty() && !Platform::path_is_within(source_root, source)) {
|
||||
continue;
|
||||
}
|
||||
const auto *lines_v = find_key(*file_obj, "lines");
|
||||
const auto *lines = lines_v ? std::get_if<JsonVal::Array>(&lines_v->value) : nullptr;
|
||||
if (lines == nullptr) {
|
||||
continue;
|
||||
}
|
||||
auto &entry = coverage[source.string()];
|
||||
for (const auto &line_entry : *lines) {
|
||||
const auto *line_obj = std::get_if<JsonVal::Object>(&line_entry.value);
|
||||
if (line_obj == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::int64_t number = 0;
|
||||
std::int64_t count = 0;
|
||||
if (const auto *number_v = find_key(*line_obj, "line_number")) {
|
||||
if (const auto *value = std::get_if<std::int64_t>(&number_v->value)) {
|
||||
number = *value;
|
||||
}
|
||||
}
|
||||
if (const auto *count_v = find_key(*line_obj, "count")) {
|
||||
if (const auto *value = std::get_if<std::int64_t>(&count_v->value)) {
|
||||
count = *value;
|
||||
}
|
||||
}
|
||||
if (number <= 0) {
|
||||
continue;
|
||||
}
|
||||
auto &slot = entry[number];
|
||||
slot = std::max(slot, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoverageSummary summary;
|
||||
std::string lcov;
|
||||
for (auto &[path, lines] : coverage) {
|
||||
if (lines.empty()) {
|
||||
continue;
|
||||
}
|
||||
++summary.files;
|
||||
std::size_t hit = 0;
|
||||
lcov += "TN:\nSF:" + path + '\n';
|
||||
for (const auto &[number, count] : lines) {
|
||||
lcov += std::format("DA:{},{}\n", number, count);
|
||||
if (count > 0) {
|
||||
++hit;
|
||||
}
|
||||
}
|
||||
lcov += std::format("LF:{}\nLH:{}\nend_of_record\n", lines.size(), hit);
|
||||
summary.lines_found += lines.size();
|
||||
summary.lines_hit += hit;
|
||||
}
|
||||
|
||||
if (auto written = Platform::atomic_write_file(output_dir / "coverage.info", lcov, true);
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
const double percent =
|
||||
summary.lines_found == 0
|
||||
? 0.0
|
||||
: 100.0 * static_cast<double>(summary.lines_hit) /
|
||||
static_cast<double>(summary.lines_found);
|
||||
const std::string summary_text =
|
||||
std::format("Coverage: {:.1f}% ({}/{} lines) across {} file(s)\n", percent,
|
||||
summary.lines_hit, summary.lines_found, summary.files);
|
||||
if (auto written = Platform::atomic_write_file(output_dir / "summary.txt", summary_text, true);
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Report
|
||||
+65
-16
@@ -76,6 +76,27 @@ bool path_has_excluded_component(const std::filesystem::path &rel_path,
|
||||
Void::Result::Result<std::vector<std::string>, Void::Result::Error>
|
||||
read_sorted_dir_entries(const std::filesystem::path &dir_path,
|
||||
const std::vector<std::string> &excluded) {
|
||||
#if defined(_WIN32)
|
||||
std::error_code ec;
|
||||
std::vector<std::string> names;
|
||||
for (std::filesystem::directory_iterator it{dir_path, ec}, end; !ec && it != end;
|
||||
it.increment(ec)) {
|
||||
const auto name = it->path().filename().string();
|
||||
if (is_excluded_name(name, excluded)) {
|
||||
continue;
|
||||
}
|
||||
names.push_back(name);
|
||||
}
|
||||
if (ec) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("snapshot: cannot read directory '{}': {}", dir_path.string(),
|
||||
ec.message()),
|
||||
ec.value())};
|
||||
}
|
||||
std::ranges::sort(names);
|
||||
return names;
|
||||
#else
|
||||
const int fd = ::open(dir_path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
const int err = errno;
|
||||
@@ -112,6 +133,7 @@ read_sorted_dir_entries(const std::filesystem::path &dir_path,
|
||||
}
|
||||
std::ranges::sort(names);
|
||||
return names;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string normalize_logical(const std::filesystem::path &rel) {
|
||||
@@ -469,57 +491,84 @@ Void::Result::Result<InputSnapshot, Void::Result::Error> capture_snapshot(
|
||||
if (options.materialize) {
|
||||
snap.materialized_root = options.snapshot_store_dir / "trees" / snap.snapshot_id;
|
||||
const auto seal_marker = snap.materialized_root / ".sealed";
|
||||
// A tree can be sealed while incomplete (interrupted concurrent capture),
|
||||
// and the seal marker would make that permanent: verify and repair.
|
||||
for (int materialize_attempt = 0; materialize_attempt < 3; ++materialize_attempt) {
|
||||
if (!std::filesystem::exists(seal_marker, ec)) {
|
||||
const auto tmp_tree = options.snapshot_store_dir / "trees" /
|
||||
// Unique per capture: concurrent captures in one process share the
|
||||
// pid, and a shared staging directory lets one capture remove files
|
||||
// another has already copied (sealing an incomplete tree).
|
||||
static std::atomic<std::uint64_t> staging_sequence{0};
|
||||
const auto tmp_tree =
|
||||
options.snapshot_store_dir / "trees" /
|
||||
(snap.snapshot_id + ".staging_" +
|
||||
std::to_string(static_cast<long long>(::getpid())));
|
||||
std::to_string(static_cast<long long>(::getpid())) + "_" +
|
||||
std::to_string(staging_sequence.fetch_add(1, std::memory_order_relaxed)));
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
std::filesystem::create_directories(tmp_tree, ec);
|
||||
|
||||
for (auto &[logical, entry] : snap.entries) {
|
||||
const auto dst = tmp_tree / logical;
|
||||
std::filesystem::create_directories(dst.parent_path(), ec);
|
||||
if (entry.kind == EntryKind::RegularFile && !entry.materialized_path.empty()) {
|
||||
if (entry.kind == EntryKind::RegularFile &&
|
||||
!entry.materialized_path.empty()) {
|
||||
auto copied =
|
||||
Platform::copy_isolated(entry.materialized_path, dst, entry.mode);
|
||||
if (!copied) {
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
return std::unexpected{copied.error()};
|
||||
}
|
||||
(void)Platform::set_canonical_mtime(dst, options.reproducibility_epoch);
|
||||
(void)Platform::set_canonical_mtime(dst,
|
||||
options.reproducibility_epoch);
|
||||
} else if (entry.kind == EntryKind::Symlink) {
|
||||
if (!entry.sha256.empty()) {
|
||||
// Materialize symlinked regular file target inside snapshot tree
|
||||
// safely.
|
||||
// Materialize symlinked regular file target inside snapshot
|
||||
// tree safely.
|
||||
const auto src_target = source_files_to_verify.find(logical);
|
||||
if (src_target != source_files_to_verify.end()) {
|
||||
auto copied =
|
||||
Platform::copy_isolated(src_target->second, dst, entry.mode);
|
||||
auto copied = Platform::copy_isolated(src_target->second, dst,
|
||||
entry.mode);
|
||||
if (!copied) {
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
return std::unexpected{copied.error()};
|
||||
}
|
||||
(void)Platform::set_canonical_mtime(dst,
|
||||
options.reproducibility_epoch);
|
||||
(void)Platform::set_canonical_mtime(
|
||||
dst, options.reproducibility_epoch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(void)Platform::atomic_write_file(tmp_tree / ".sealed", snap.snapshot_id + "\n",
|
||||
false);
|
||||
(void)Platform::atomic_write_file(tmp_tree / ".sealed",
|
||||
snap.snapshot_id + "\n", false);
|
||||
std::filesystem::rename(tmp_tree, snap.materialized_root, ec);
|
||||
if (ec) {
|
||||
// Another concurrent worker may have sealed the identical content-addressed
|
||||
// tree.
|
||||
// Another concurrent worker may have sealed the identical
|
||||
// content-addressed tree.
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
if (!std::filesystem::exists(seal_marker, ec)) {
|
||||
return std::unexpected{
|
||||
make_error(Void::System::SystemErrorCode::io_error,
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("snapshot: failed publishing tree '{}'",
|
||||
snap.materialized_root.string()))};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t missing = 0;
|
||||
for (const auto &[logical, entry] : snap.entries) {
|
||||
std::error_code check_ec;
|
||||
if (!std::filesystem::exists(snap.materialized_root / logical, check_ec)) {
|
||||
++missing;
|
||||
}
|
||||
}
|
||||
if (missing == 0) {
|
||||
break;
|
||||
}
|
||||
std::fprintf(stderr,
|
||||
"snapshot: materialized tree '%s' misses %zu file(s); rebuilding\n",
|
||||
snap.snapshot_id.c_str(), missing);
|
||||
std::filesystem::remove_all(snap.materialized_root, ec);
|
||||
}
|
||||
for (auto &[logical, entry] : snap.entries) {
|
||||
entry.materialized_path = snap.materialized_root / logical;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <map>
|
||||
#if !defined(_WIN32)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::State {
|
||||
namespace {
|
||||
@@ -87,6 +89,7 @@ struct HttpReply {
|
||||
std::string body;
|
||||
};
|
||||
|
||||
#if !defined(_WIN32)
|
||||
bool send_all(int fd, std::string_view data) {
|
||||
std::size_t off = 0;
|
||||
while (off < data.size()) {
|
||||
@@ -101,6 +104,7 @@ bool send_all(int fd, std::string_view data) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Void::Result::Result<HttpReply, Void::Result::Error>
|
||||
http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view path,
|
||||
@@ -139,6 +143,7 @@ http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view
|
||||
}
|
||||
return HttpReply{response->status, std::move(response->body)};
|
||||
#else
|
||||
#if !defined(_WIN32)
|
||||
if (parsed.scheme == "http") {
|
||||
struct addrinfo hints{};
|
||||
hints.ai_family = AF_INET;
|
||||
@@ -215,19 +220,20 @@ http_exchange(const ParsedUrl &parsed, std::string_view method, std::string_view
|
||||
reply.body = raw.substr(hdr_end + 4);
|
||||
return reply;
|
||||
}
|
||||
#endif
|
||||
|
||||
// HTTPS via curl preserves TLS certificate verification (never disables TLS).
|
||||
// http/https via curl preserve TLS certificate verification (never disable TLS).
|
||||
auto curl = Platform::resolve_executable("curl");
|
||||
if (!curl) {
|
||||
return std::unexpected{
|
||||
make_error(Void::System::SystemErrorCode::not_found,
|
||||
"HTTPS remote cache requires curl (Void::Net not linked)")};
|
||||
"remote cache requires curl (Void::Net not linked)")};
|
||||
}
|
||||
const std::string full_url =
|
||||
std::format("https://{}:{}{}", parsed.host, parsed.port, full_path);
|
||||
std::format("{}://{}:{}{}", parsed.scheme, parsed.host, parsed.port, full_path);
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = *curl;
|
||||
req.arguments = {"--silent", "--show-error", "--proto", "=https",
|
||||
req.arguments = {"--silent", "--show-error", "--proto", "=" + parsed.scheme,
|
||||
"-X", std::string{method}, "-w", "\n%{http_code}"};
|
||||
for (const auto &[k, v] : headers) {
|
||||
req.arguments.push_back("-H");
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::State {
|
||||
namespace {
|
||||
|
||||
@@ -39,10 +43,39 @@ bool pid_is_alive(pid_t pid) noexcept {
|
||||
if (pid <= 0) {
|
||||
return false;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
const HANDLE handle =
|
||||
::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, static_cast<DWORD>(pid));
|
||||
if (handle == nullptr) {
|
||||
return false;
|
||||
}
|
||||
DWORD exit_code = 0;
|
||||
const bool alive = ::GetExitCodeProcess(handle, &exit_code) != 0 && exit_code == STILL_ACTIVE;
|
||||
::CloseHandle(handle);
|
||||
return alive;
|
||||
#else
|
||||
if (::kill(pid, 0) == 0) {
|
||||
return true;
|
||||
}
|
||||
return errno != ESRCH;
|
||||
#endif
|
||||
}
|
||||
|
||||
void apply_posix_mode(const std::filesystem::path &p, unsigned mode) noexcept {
|
||||
#if defined(_WIN32)
|
||||
using Perms = std::filesystem::perms;
|
||||
Perms perms = Perms::owner_read | Perms::group_read | Perms::others_read;
|
||||
if ((mode & 0200u) != 0) {
|
||||
perms |= Perms::owner_write;
|
||||
}
|
||||
if ((mode & 0100u) != 0) {
|
||||
perms |= Perms::owner_exec;
|
||||
}
|
||||
std::error_code ec;
|
||||
std::filesystem::permissions(p, perms, std::filesystem::perm_options::replace, ec);
|
||||
#else
|
||||
(void)::chmod(p.c_str(), static_cast<mode_t>(mode));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string serialize_action(const ActionSuccessRecord &rec) {
|
||||
@@ -155,6 +188,16 @@ struct StateStore::CacheState {
|
||||
};
|
||||
|
||||
static std::optional<StatFingerprint> stat_file(const std::filesystem::path &p) noexcept {
|
||||
#if defined(_WIN32)
|
||||
struct _stat64 st{};
|
||||
if (::_wstat64(p.c_str(), &st) != 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return StatFingerprint{static_cast<std::uint64_t>(st.st_dev),
|
||||
static_cast<std::uint64_t>(st.st_ino),
|
||||
static_cast<std::uint64_t>(st.st_size),
|
||||
static_cast<std::int64_t>(st.st_mtime), 0};
|
||||
#else
|
||||
struct stat st{};
|
||||
if (::stat(p.c_str(), &st) != 0) {
|
||||
return std::nullopt;
|
||||
@@ -163,6 +206,7 @@ struct StateStore::CacheState {
|
||||
static_cast<std::uint64_t>(st.st_dev), static_cast<std::uint64_t>(st.st_ino),
|
||||
static_cast<std::uint64_t>(st.st_size), static_cast<std::int64_t>(st.st_mtim.tv_sec),
|
||||
static_cast<std::int64_t>(st.st_mtim.tv_nsec)};
|
||||
#endif
|
||||
}
|
||||
|
||||
std::mutex mutex;
|
||||
@@ -703,12 +747,12 @@ StateStore::store_blob_from_file(const std::filesystem::path &file_path) {
|
||||
if (existing_ok && *existing_ok) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
} else {
|
||||
(void)::chmod(final_path.c_str(), 0644);
|
||||
apply_posix_mode(final_path, 0644);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
(void)::chmod(final_path.c_str(), 0444);
|
||||
apply_posix_mode(final_path, 0444);
|
||||
}
|
||||
} else {
|
||||
(void)::chmod(stage_path.c_str(), 0444);
|
||||
apply_posix_mode(stage_path, 0444);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
if (ec) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
@@ -848,7 +892,7 @@ StateStore::ensure_remote_blob(std::string_view sha256) {
|
||||
if (!wrote) {
|
||||
return std::unexpected{wrote.error()};
|
||||
}
|
||||
(void)::chmod(stage_path.c_str(), 0444);
|
||||
apply_posix_mode(stage_path, 0444);
|
||||
std::filesystem::rename(stage_path, final_path, ec);
|
||||
if (ec) {
|
||||
std::filesystem::remove(stage_path, ec);
|
||||
@@ -1141,7 +1185,7 @@ Void::Result::Result<GcStats, Void::Result::Error> StateStore::gc(std::uint64_t
|
||||
const std::string sha = entry.path().filename().string();
|
||||
const auto fsize = entry.file_size(ec);
|
||||
if (!pinned.contains(sha)) {
|
||||
(void)::chmod(entry.path().c_str(), 0644);
|
||||
apply_posix_mode(entry.path(), 0644);
|
||||
std::filesystem::remove(entry.path(), ec);
|
||||
if (!ec) {
|
||||
++stats.removed_blobs;
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <format>
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Toolchain {
|
||||
namespace {
|
||||
@@ -260,19 +262,31 @@ void attach_shader_tools(ToolchainCapabilities &cap) {
|
||||
} // namespace
|
||||
|
||||
std::string host_os_name() {
|
||||
#if defined(_WIN32)
|
||||
return "Windows";
|
||||
#elif defined(__APPLE__)
|
||||
return "macOS";
|
||||
#else
|
||||
struct utsname u{};
|
||||
if (::uname(&u) == 0) {
|
||||
return std::string{u.sysname};
|
||||
}
|
||||
return "Linux";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string host_architecture_name() {
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
return "aarch64";
|
||||
#elif defined(_WIN32)
|
||||
return "x86_64";
|
||||
#else
|
||||
struct utsname u{};
|
||||
if (::uname(&u) == 0) {
|
||||
return std::string{u.machine};
|
||||
}
|
||||
return "x86_64";
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -452,7 +466,13 @@ discover_and_probe(const ProfileContext &context,
|
||||
if (cap.family == CompilerFamily::Clang) {
|
||||
cap.module_scanner = Platform::resolve_executable("clang-scan-deps");
|
||||
cap.supports_p1689_scan = cap.module_scanner.has_value();
|
||||
}
|
||||
|
||||
// Record the compiler's implicit include search list (GCC and Clang both
|
||||
// print it for `-E -v`): explicitly passing those directories, e.g. as
|
||||
// `-isystem /usr/include`, makes GCC drop its implicit entry and breaks the
|
||||
// `#include_next` chain in libstdc++.
|
||||
{
|
||||
Platform::ProcessRequest ireq;
|
||||
ireq.executable = cap.cxx_compiler;
|
||||
ireq.arguments = {"-x", "c++", "-E", "-v"};
|
||||
@@ -743,7 +763,22 @@ lower_compile_command(const ToolchainCapabilities &toolchain, const CompileReque
|
||||
if (toolchain.family == CompilerFamily::Gcc && !request.nondeterministic) {
|
||||
args.push_back("-frandom-seed=" + request.output_object.filename().string());
|
||||
}
|
||||
// Directories the compiler already searches implicitly are skipped: passing
|
||||
// them explicitly (especially as -isystem) makes GCC drop its own entry and
|
||||
// breaks #include_next in the standard library headers.
|
||||
const auto is_implicit_include = [&](const std::filesystem::path &dir) {
|
||||
const auto normalized = dir.lexically_normal();
|
||||
for (const auto &implicit : toolchain.default_include_dirs) {
|
||||
if (std::filesystem::path{implicit}.lexically_normal() == normalized) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
for (const auto &[inc, is_system] : request.include_dirs) {
|
||||
if (is_implicit_include(inc)) {
|
||||
continue;
|
||||
}
|
||||
args.push_back(is_system ? "-isystem" : "-I");
|
||||
args.push_back(inc.string());
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
#include <format>
|
||||
#include <set>
|
||||
|
||||
#if !defined(__linux__)
|
||||
// The watcher delegates to Void::FileSystem::DirectoryWatcher, which has Linux
|
||||
// (inotify) and Windows backends.
|
||||
#if !defined(__linux__) && !defined(_WIN32)
|
||||
#error \
|
||||
"VoidBuildSystem's inotify watcher currently supports Linux hosts only (Track C2/C3 ports are planned)"
|
||||
"VoidBuildSystem's watcher currently supports Linux and Windows hosts only (Track C2/C3 ports are planned)"
|
||||
#endif
|
||||
|
||||
namespace Void::Build::Watch {
|
||||
|
||||
+21
-8
@@ -12,19 +12,27 @@ set_target_properties(vbs_core_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_core_tests COMMAND "$<TARGET_FILE:vbs_core_tests>" --no-color)
|
||||
|
||||
add_executable(vbs_v1_tests FullV1Tests.cpp DaemonTests.cpp SigningTests.cpp SignatureEnforcementTests.cpp)
|
||||
set(VBS_V1_TEST_SOURCES FullV1Tests.cpp SigningTests.cpp SignatureEnforcementTests.cpp)
|
||||
if(NOT WIN32)
|
||||
# The daemon transport is POSIX-only until its Track C3 Windows port lands.
|
||||
list(APPEND VBS_V1_TEST_SOURCES DaemonTests.cpp)
|
||||
endif()
|
||||
add_executable(vbs_v1_tests ${VBS_V1_TEST_SOURCES})
|
||||
target_include_directories(vbs_v1_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_v1_tests PRIVATE Void::BuildCore Void::Testing)
|
||||
set_target_properties(vbs_v1_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_v1_tests COMMAND "$<TARGET_FILE:vbs_v1_tests>" --no-color)
|
||||
|
||||
add_executable(vbs_registry_tests RegistryTests.cpp)
|
||||
target_include_directories(vbs_registry_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_registry_tests PRIVATE Void::BuildRegistry Void::Testing)
|
||||
set_target_properties(vbs_registry_tests PROPERTIES
|
||||
if(NOT WIN32)
|
||||
# The registry service is POSIX-only until its Track C3 Windows port lands.
|
||||
add_executable(vbs_registry_tests RegistryTests.cpp)
|
||||
target_include_directories(vbs_registry_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
target_link_libraries(vbs_registry_tests PRIVATE Void::BuildRegistry Void::Testing)
|
||||
set_target_properties(vbs_registry_tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
|
||||
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
|
||||
endif()
|
||||
|
||||
add_executable(vbs_selfhost_tests SelfHostTests.cpp)
|
||||
target_include_directories(vbs_selfhost_tests PRIVATE "${PROJECT_BINARY_DIR}/generated")
|
||||
@@ -37,9 +45,14 @@ add_test(NAME vbs_selfhost_tests COMMAND "$<TARGET_FILE:vbs_selfhost_tests>" --n
|
||||
|
||||
add_test(NAME vbs_sdk_registration COMMAND "${CMAKE_COMMAND}"
|
||||
"-DSDK_TESTS=$<TARGET_FILE:vbs_sdk_tests>" -P "${CMAKE_CURRENT_SOURCE_DIR}/SdkRegistration.cmake")
|
||||
if(TARGET vbs-registry)
|
||||
set(VBS_REGISTRY_ARG "-DVBS_REGISTRY=$<TARGET_FILE:vbs-registry>")
|
||||
else()
|
||||
set(VBS_REGISTRY_ARG "")
|
||||
endif()
|
||||
add_test(NAME vbs_cli_contract COMMAND "${CMAKE_COMMAND}"
|
||||
"-DVBS=$<TARGET_FILE:vbs>" "-DVBS_REGISTRY=$<TARGET_FILE:vbs-registry>"
|
||||
"-DVBS_VERSION=${PROJECT_VERSION}"
|
||||
"-DVBS=$<TARGET_FILE:vbs>" "${VBS_REGISTRY_ARG}"
|
||||
"-DVBS_VERSION=${PROJECT_VERSION}" "-DVBS_WINDOWS=${WIN32}"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/CliContracts.cmake")
|
||||
add_test(NAME vbs_description_contract COMMAND "${CMAKE_COMMAND}"
|
||||
"-DDESCRIBE=$<TARGET_FILE:vbs_describe>"
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
# Captured output must be plain text: the CLI colorizes help when colors are allowed.
|
||||
set(ENV{NO_COLOR} "1")
|
||||
|
||||
function(check_process expected_code expected_out_regex expected_err_regex)
|
||||
execute_process(COMMAND "${VBS}" ${ARGN}
|
||||
RESULT_VARIABLE code OUTPUT_VARIABLE out ERROR_VARIABLE err TIMEOUT 15)
|
||||
@@ -28,7 +31,7 @@ check_process(2 "" "invalid --test-timeout" test --test-timeout 0)
|
||||
check_process(0 "Usage: vbs init " "" init --help)
|
||||
check_process(0 "Usage: vbs clean " "" clean --help)
|
||||
check_process(0 "Usage: vbs doctor " "" doctor --help)
|
||||
check_process(0 "host platform: Linux" "" doctor)
|
||||
check_process(0 "host platform: (Linux|Windows)" "" doctor)
|
||||
check_process(0 "Void::Sqlite: (enabled|disabled)" "" doctor)
|
||||
check_process(0 "Usage: vbs graph " "" graph --help)
|
||||
check_process(2 "" "unsupported --format" graph --format xml)
|
||||
@@ -91,7 +94,10 @@ check_process(0 "Usage: vbs daemon ide query .*--profile" "" daemon ide query --
|
||||
check_process(0 "Usage: vbs daemon compdb export .*--profile" "" daemon compdb export --help)
|
||||
check_process(0 "Usage: vbs daemon compdb use .*--profile" "" daemon compdb use --help)
|
||||
check_process(0 "Usage: vbs daemon compdb entries .*--file.*--limit" "" daemon compdb entries --help)
|
||||
check_process(0 "Usage: vbs daemon ide generate .*--profile.*--editor.*--force" "" daemon ide generate --help)
|
||||
check_process(0 "Usage: vbs daemon ide generate " "" daemon ide generate --help)
|
||||
check_process(0 "--force" "" daemon ide generate --help)
|
||||
check_process(0 "--profile" "" daemon ide generate --help)
|
||||
check_process(0 "--editor" "" daemon ide generate --help)
|
||||
check_process(0 "Usage: vbs daemon ide poll " "" daemon ide poll --help)
|
||||
check_process(0 "Usage: vbs daemon ide status " "" daemon ide status --help)
|
||||
check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help)
|
||||
@@ -106,15 +112,20 @@ check_process(0 "Usage: vbs daemon target info .*--name" "" daemon target info -
|
||||
check_process(0 "Usage: vbs daemon target flags .*--name.*--file" "" daemon target flags --help)
|
||||
check_process(0 "Usage: vbs daemon pack .*--output" "" daemon pack --help)
|
||||
check_process(0 "Usage: vbs daemon actions .*--limit" "" daemon actions --help)
|
||||
check_process(0 "Usage: vbs daemon install .*--prefix.*--component.*--no-cmake-export.*--no-native-export" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon install " "" daemon install --help)
|
||||
check_process(0 "--prefix" "" daemon install --help)
|
||||
check_process(0 "--component" "" daemon install --help)
|
||||
check_process(0 "--no-cmake-export" "" daemon install --help)
|
||||
check_process(0 "--no-native-export" "" daemon install --help)
|
||||
check_process(0 "Usage: vbs daemon uninstall .*--prefix" "" daemon uninstall --help)
|
||||
check_process(0 "Usage: vbs daemon gen-tests .*--input.*--output-dir" "" daemon gen-tests --help)
|
||||
check_process(0 "Usage: vbs daemon init .*--dir" "" daemon init --help)
|
||||
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
|
||||
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
|
||||
|
||||
if(NOT VBS_WINDOWS)
|
||||
# Daemon-backed describe contract: start `vbs daemon run`, query the bounded graph summary over
|
||||
# the Unix socket, then stop it. The daemon is Unix-only, matching the rest of this suite.
|
||||
# the Unix socket, then stop it (Unix-only; the Windows transport is Track C3).
|
||||
set(daemon_contract_root "${CMAKE_CURRENT_BINARY_DIR}/daemon_contract")
|
||||
file(REMOVE_RECURSE "${daemon_contract_root}")
|
||||
file(MAKE_DIRECTORY "${daemon_contract_root}/project")
|
||||
@@ -193,6 +204,7 @@ if(NOT daemon_describe_out MATCHES "\"ok\":true" OR
|
||||
message(FATAL_ERROR "vbs daemon describe: unexpected response [${daemon_describe_out}]")
|
||||
endif()
|
||||
message(STATUS "daemon describe response: ${daemon_describe_out}")
|
||||
endif()
|
||||
check_process(0 "Usage: vbs ide <command>.*Commands:.*generate.*query" "" ide --help)
|
||||
check_process(0 "Usage: vbs ide generate " "" ide generate --help)
|
||||
check_process(0 "Usage: vbs ide query " "" ide query --help)
|
||||
@@ -201,9 +213,11 @@ check_process(2 "" "--output is required" ide plugin)
|
||||
check_process(2 "" "missing subcommand for 'vbs ide'" ide)
|
||||
check_process(2 "" "unknown IDE kind" ide generate --editor invalid_ide)
|
||||
|
||||
execute_process(COMMAND "${VBS_REGISTRY}" --help
|
||||
if(VBS_REGISTRY)
|
||||
execute_process(COMMAND "${VBS_REGISTRY}" --help
|
||||
RESULT_VARIABLE reg_code OUTPUT_VARIABLE reg_out ERROR_VARIABLE reg_err TIMEOUT 15)
|
||||
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
||||
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
||||
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "CLI and auto-generated Argparse help contracts verified (including daemon describe round-trip)")
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <format>
|
||||
#include <filesystem>
|
||||
#include <stop_token>
|
||||
@@ -27,8 +28,29 @@
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <cstdlib>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace Void::Build;
|
||||
|
||||
namespace {
|
||||
// Compiler-spawning tests need a native host: under Wine a Windows process
|
||||
// cannot execute the Linux-hosted MinGW compiler.
|
||||
bool host_can_exec_compiler() {
|
||||
#if defined(_WIN32)
|
||||
if (std::getenv("WINEPREFIX") != nullptr) {
|
||||
return false;
|
||||
}
|
||||
const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
|
||||
return ntdll == nullptr || ::GetProcAddress(ntdll, "wine_get_version") == nullptr;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
void write_text_file(const std::filesystem::path &path, std::string_view content) {
|
||||
@@ -81,8 +103,13 @@ VOID_TEST(CoreEngineTests, process_supervisor_exec_failure_and_early_leader_gran
|
||||
// 2. Program explicitly exiting 127 is NOT exec_failed.
|
||||
{
|
||||
Platform::ProcessRequest req;
|
||||
#if defined(_WIN32)
|
||||
req.executable = "cmd.exe";
|
||||
req.arguments = {"/c", "exit 127"};
|
||||
#else
|
||||
req.executable = "/bin/sh";
|
||||
req.arguments = {"-c", "exit 127"};
|
||||
#endif
|
||||
auto res = Platform::run_supervised(req);
|
||||
Void::Testing::expect(res.has_value());
|
||||
if (res) {
|
||||
@@ -92,8 +119,11 @@ VOID_TEST(CoreEngineTests, process_supervisor_exec_failure_and_early_leader_gran
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
// 3. Adversarial VL-001 test: leader spawns stubborn grandchild ignoring SIGTERM and exits
|
||||
// immediately; timeout escalates to SIGKILL and prevents grandchild from writing sentinel file.
|
||||
// The POSIX process-group/signal semantics do not apply on Windows (job objects own the
|
||||
// descendants instead).
|
||||
{
|
||||
Void::FileSystem::TempDir tmp{"vbs_proc_"};
|
||||
const auto sentinel = tmp / "grandchild_escaped.txt";
|
||||
@@ -136,6 +166,7 @@ VOID_TEST(CoreEngineTests, process_supervisor_exec_failure_and_early_leader_gran
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{300});
|
||||
Void::Testing::expect(!std::filesystem::exists(sentinel));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID_TEST(CoreEngineTests, profile_inheritance_and_cycle_rejection) {
|
||||
@@ -225,7 +256,14 @@ VOID_TEST(CoreEngineTests, snapshot_content_mutations_symlinks_shadowing_and_iso
|
||||
Void::Testing::expect(fresh3.has_value() && !*fresh3);
|
||||
|
||||
// 4. Symlink escape outside project root must be rejected.
|
||||
std::filesystem::create_symlink(outside, proj / "src" / "escape.hpp");
|
||||
// Symlink creation needs a filesystem/host that supports it (Wine does not).
|
||||
std::error_code link_ec;
|
||||
std::filesystem::create_symlink(outside, proj / "src" / "escape.hpp", link_ec);
|
||||
if (link_ec) {
|
||||
std::printf("snapshot: symlinks unavailable (%s); skipping symlink checks\n",
|
||||
link_ec.message().c_str());
|
||||
return;
|
||||
}
|
||||
auto esc_snap = Snapshot::capture_snapshot(opts, {proj / "src" / "escape.hpp"}, {});
|
||||
Void::Testing::expect(!esc_snap.has_value());
|
||||
|
||||
@@ -292,7 +330,9 @@ VOID_TEST(CoreEngineTests, state_store_cas_corruption_recovery_and_gc) {
|
||||
|
||||
// Corrupt blob1 on disk and verify lookup detects corruption!
|
||||
const auto blob_path = store->cas_blob_path(blob1->sha256);
|
||||
(void)::chmod(blob_path.c_str(), 0644);
|
||||
std::error_code perm_ec;
|
||||
std::filesystem::permissions(blob_path, std::filesystem::perms::owner_write,
|
||||
std::filesystem::perm_options::add, perm_ec);
|
||||
write_text_file(blob_path, "CORRUPTED_BYTES!!");
|
||||
Void::Testing::expect(!store->verify_blob(blob1->sha256).value_or(true));
|
||||
auto lookup = store->lookup_action("good_key");
|
||||
@@ -300,6 +340,10 @@ VOID_TEST(CoreEngineTests, state_store_cas_corruption_recovery_and_gc) {
|
||||
}
|
||||
|
||||
VOID_TEST(CoreEngineTests, end_to_end_native_frontend_graph_execution_and_archive_member_removal) {
|
||||
if (!host_can_exec_compiler()) {
|
||||
std::printf("end-to-end compile skipped: the host cannot execute a native compiler\n");
|
||||
return;
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_e2e_"};
|
||||
const auto proj = tmp / "app_proj";
|
||||
const auto build_dir = tmp / "build";
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
# Captured output must be plain text: the CLI colorizes help when colors are allowed.
|
||||
set(ENV{NO_COLOR} "1")
|
||||
|
||||
function(expect_json expected)
|
||||
string(JSON actual GET "${graph}" ${ARGN})
|
||||
if(NOT "${actual}" STREQUAL "${expected}")
|
||||
@@ -51,17 +54,17 @@ foreach(profile IN ITEMS debug release)
|
||||
expect_json(static_library targets 4 kind)
|
||||
expect_json(vbs-registry targets 5 name)
|
||||
expect_json(executable targets 5 kind)
|
||||
expect_json(vbs_self_smoke targets 6 name)
|
||||
expect_json(vbs_registry_tests targets 6 name)
|
||||
expect_json(test targets 6 kind)
|
||||
expect_json(vbs_benchmarks targets 7 name)
|
||||
expect_json(executable targets 7 kind)
|
||||
expect_json(vbs_sdk_tests targets 8 name)
|
||||
expect_json(test targets 8 kind)
|
||||
expect_json(vbs_core_tests targets 9 name)
|
||||
expect_json(vbs_self_smoke targets 7 name)
|
||||
expect_json(test targets 7 kind)
|
||||
expect_json(vbs_benchmarks targets 8 name)
|
||||
expect_json(executable targets 8 kind)
|
||||
expect_json(vbs_sdk_tests targets 9 name)
|
||||
expect_json(test targets 9 kind)
|
||||
expect_json(vbs_v1_tests targets 10 name)
|
||||
expect_json(vbs_core_tests targets 10 name)
|
||||
expect_json(test targets 10 kind)
|
||||
expect_json(vbs_registry_tests targets 11 name)
|
||||
expect_json(vbs_v1_tests targets 11 name)
|
||||
expect_json(test targets 11 kind)
|
||||
expect_json(vbs_selfhost_tests targets 12 name)
|
||||
expect_json(test targets 12 kind)
|
||||
@@ -73,7 +76,7 @@ foreach(profile IN ITEMS debug release)
|
||||
endif()
|
||||
endforeach()
|
||||
expect_json(git dependencies 0 source kind)
|
||||
expect_json(0002e74a7da94a756f55a4a5574d20b77736c185 dependencies 0 source revision)
|
||||
expect_json(1b1947340f8080dbf457d4218cbbee1743f8438d dependencies 0 source revision)
|
||||
expect_json(native dependencies 0 builder)
|
||||
string(JSON option_type TYPE "${graph}" dependencies 0 options BUILD_SHARED_LIBS)
|
||||
if(NOT option_type STREQUAL "BOOLEAN")
|
||||
|
||||
@@ -66,16 +66,17 @@ VOID_TEST(ExampleContexts, example_records_sources_links_and_pin) {
|
||||
std::string{"VoidBuildCore"});
|
||||
Void::Testing::expect_eq(project.targets().at(4).name, std::string{"VoidBuildRegistry"});
|
||||
Void::Testing::expect_eq(project.targets().at(5).name, std::string{"vbs-registry"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).name, std::string{"vbs_self_smoke"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).name, std::string{"vbs_registry_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(6).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(7).name, std::string{"vbs_benchmarks"});
|
||||
Void::Testing::expect_eq(project.targets().at(8).name, std::string{"vbs_sdk_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(8).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(9).name, std::string{"vbs_core_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(10).name, std::string{"vbs_v1_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(11).name, std::string{"vbs_registry_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(7).name, std::string{"vbs_self_smoke"});
|
||||
Void::Testing::expect_eq(project.targets().at(7).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(8).name, std::string{"vbs_benchmarks"});
|
||||
Void::Testing::expect_eq(project.targets().at(9).name, std::string{"vbs_sdk_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(9).kind, Void::Build::TargetKind::Test);
|
||||
Void::Testing::expect_eq(project.targets().at(10).name, std::string{"vbs_core_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(11).name, std::string{"vbs_v1_tests"});
|
||||
Void::Testing::expect_eq(project.targets().at(12).name, std::string{"vbs_selfhost_tests"});
|
||||
Void::Testing::expect_eq(project.dependencies().at(0).revision,
|
||||
std::string{"0002e74a7da94a756f55a4a5574d20b77736c185"});
|
||||
std::string{"1b1947340f8080dbf457d4218cbbee1743f8438d"});
|
||||
Void::Testing::expect_eq(project.dependencies().at(0).builder, std::string{"native"});
|
||||
}
|
||||
+108
-8
@@ -94,14 +94,23 @@ void write_raw_tar(const std::filesystem::path &tar_path,
|
||||
|
||||
std::filesystem::path locate_vbs_binary() {
|
||||
std::error_code ec;
|
||||
// Windows executables carry the .exe suffix.
|
||||
const auto find_in = [&ec](const std::filesystem::path &dir) -> std::filesystem::path {
|
||||
for (const auto *name : {"vbs", "vbs.exe"}) {
|
||||
const auto candidate = dir / name;
|
||||
if (std::filesystem::exists(candidate, ec)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (const auto self_exe = Platform::current_executable_path(); self_exe) {
|
||||
const auto sibling = self_exe->parent_path() / "vbs";
|
||||
if (std::filesystem::exists(sibling, ec)) {
|
||||
return sibling;
|
||||
if (auto found = find_in(self_exe->parent_path()); !found.empty()) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
if (!Bootstrap::binary_dir.empty()) {
|
||||
return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
|
||||
return find_in(std::filesystem::path{Bootstrap::binary_dir} / "bin");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -1137,6 +1146,29 @@ void build(Void::Build::Project &p) {
|
||||
Void::Testing::expect_eq(read_be64(koly, 492), (data_fork_length + 511) / 512);
|
||||
Void::Testing::expect(dmg_bytes->substr(257, 5) == "ustar"); // tar payload
|
||||
|
||||
// NuGet package (.nupkg): OPC ZIP with the nuspec and native runtime assets.
|
||||
const auto nupkg_archive = tmp / "cli_hi.nupkg";
|
||||
auto nuget_req = inst_req;
|
||||
for (auto &arg : nuget_req.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = nupkg_archive.string();
|
||||
}
|
||||
}
|
||||
nuget_req.arguments.push_back("--archive-format");
|
||||
nuget_req.arguments.push_back("nuget");
|
||||
auto nuget_res = Platform::run_supervised(nuget_req);
|
||||
Void::Testing::expect(nuget_res.has_value() && nuget_res->succeeded());
|
||||
auto nupkg_bytes = Void::FileSystem::read_file(nupkg_archive);
|
||||
Void::Testing::require(nupkg_bytes.has_value());
|
||||
Void::Testing::expect(nupkg_bytes->starts_with(std::string("PK\x03\x04", 4)));
|
||||
Void::Testing::expect(nupkg_bytes->find("CliHiPkg.nuspec") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("<id>CliHiPkg</id>") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("<version>0.1.0</version>") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("[Content_Types].xml") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("_rels/.rels") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("runtimes/") != std::string::npos);
|
||||
Void::Testing::expect(nupkg_bytes->find("/native/bin/cli_hi") != std::string::npos);
|
||||
|
||||
// RPM package generator: lead + header magic + newc cpio payload.
|
||||
const auto rpm_archive = tmp / "cli_hi.rpm";
|
||||
auto rpm_req = inst_req;
|
||||
@@ -1429,8 +1461,10 @@ VOID_TEST(FullV1Tests, track_c_windows_target_cross_build_and_wine_test) {
|
||||
const auto proj = tmp / "win_proj";
|
||||
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
void build(Void::Build::Project &p) {
|
||||
p.executable("winapp").cxx_standard(Void::Build::CxxStandard::Cxx26).sources({"main.cpp"});
|
||||
p.test("win_test").cxx_standard(Void::Build::CxxStandard::Cxx26).sources({"test.cpp"});
|
||||
// C++20 keeps the Windows target buildable with older MinGW-w64 toolchains
|
||||
// (the CI runner ships GCC 10); the test exercises PE/Wine path handling.
|
||||
p.executable("winapp").cxx_standard(Void::Build::CxxStandard::Cxx20).sources({"main.cpp"});
|
||||
p.test("win_test").cxx_standard(Void::Build::CxxStandard::Cxx20).sources({"test.cpp"});
|
||||
}
|
||||
)cpp");
|
||||
write_file(proj / "main.cpp", "#include <cstdio>\nint main() { return 0; }\n");
|
||||
@@ -2696,6 +2730,61 @@ void build(Void::Build::Project &p) {
|
||||
}
|
||||
}
|
||||
|
||||
// === Coverage reporting (vbs test --coverage) ===
|
||||
VOID_TEST(FullV1Tests, test_coverage_writes_lcov_and_summary) {
|
||||
if (!Platform::resolve_executable("gcov")) {
|
||||
return; // gcov ships with GCC/Clang; skip if the toolchain lacks it.
|
||||
}
|
||||
const auto vbs_bin = locate_vbs_binary();
|
||||
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
|
||||
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
|
||||
return;
|
||||
}
|
||||
Void::FileSystem::TempDir tmp{"vbs_coverage_"};
|
||||
const auto proj = tmp / "proj";
|
||||
const auto bdir = tmp / "build";
|
||||
const auto report = tmp / "coverage";
|
||||
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
void build(Void::Build::Project &p) {
|
||||
auto lib = p.static_library("covlib");
|
||||
lib.cxx_standard(Void::Build::CxxStandard::Cxx26).sources({"src/calc.cpp"});
|
||||
p.test("cov_tests")
|
||||
.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/main.cpp"})
|
||||
.link(lib);
|
||||
}
|
||||
)cpp");
|
||||
write_file(proj / "src" / "calc.cpp",
|
||||
"int add(int a, int b) { return a + b; }\n"
|
||||
"int never_called(int a) { return a * 2; }\n");
|
||||
write_file(proj / "tests" / "main.cpp",
|
||||
"int add(int, int);\nint main() { return add(1, 2) == 3 ? 0 : 1; }\n");
|
||||
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = vbs_bin;
|
||||
req.arguments = {"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||
"--coverage", report.string()};
|
||||
req.timeout = std::chrono::seconds{300};
|
||||
auto res = Platform::run_supervised(req);
|
||||
Void::Testing::expect(res.has_value() && res->succeeded());
|
||||
if (res && !res->succeeded()) {
|
||||
std::fprintf(stderr, "%s\n", (res->stdout_data + res->stderr_data).c_str());
|
||||
}
|
||||
auto info = Void::FileSystem::read_file(report / "coverage.info");
|
||||
Void::Testing::require(info.has_value());
|
||||
Void::Testing::expect(info->find("SF:") != std::string::npos);
|
||||
Void::Testing::expect(info->find("calc.cpp") != std::string::npos);
|
||||
Void::Testing::expect(info->find("main.cpp") != std::string::npos);
|
||||
// add() is executed, never_called() is not.
|
||||
Void::Testing::expect(info->find("DA:1,1") != std::string::npos);
|
||||
Void::Testing::expect(info->find("DA:2,0") != std::string::npos);
|
||||
Void::Testing::expect(info->find("end_of_record") != std::string::npos);
|
||||
auto summary = Void::FileSystem::read_file(report / "summary.txt");
|
||||
Void::Testing::require(summary.has_value());
|
||||
Void::Testing::expect(summary->starts_with("Coverage: "));
|
||||
Void::Testing::expect(summary->find("%") != std::string::npos);
|
||||
}
|
||||
|
||||
// === Track A1: Native VBS subproject dependency (builder == "native", zero CMake!) ===
|
||||
VOID_TEST(FullV1Tests, native_vbs_subproject_dependency_builds_without_cmake) {
|
||||
const auto vbs_bin = locate_vbs_binary();
|
||||
@@ -3608,12 +3697,23 @@ VOID_TEST(FullV1Tests, track_b3_live_conan_provider_install) {
|
||||
const char *previous_home = std::getenv("CONAN_HOME");
|
||||
const std::string saved_home = previous_home == nullptr ? std::string{} : previous_home;
|
||||
const bool had_home = previous_home != nullptr;
|
||||
(void)::setenv("CONAN_HOME", conan_home.c_str(), 1);
|
||||
const auto set_env = [](const char *name, const char *value) {
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s(name, value);
|
||||
#else
|
||||
(void)::setenv(name, value, 1);
|
||||
#endif
|
||||
};
|
||||
set_env("CONAN_HOME", conan_home.string().c_str());
|
||||
const auto restore_home = Void::Scope::on_exit([&] {
|
||||
if (had_home) {
|
||||
(void)::setenv("CONAN_HOME", saved_home.c_str(), 1);
|
||||
set_env("CONAN_HOME", saved_home.c_str());
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
(void)_putenv_s("CONAN_HOME", "");
|
||||
#else
|
||||
(void)::unsetenv("CONAN_HOME");
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+25
-4
@@ -43,14 +43,23 @@ std::filesystem::path locate_void_source_dir() {
|
||||
|
||||
std::filesystem::path locate_vbs_binary() {
|
||||
std::error_code ec;
|
||||
// Windows executables carry the .exe suffix.
|
||||
const auto find_in = [&ec](const std::filesystem::path &dir) -> std::filesystem::path {
|
||||
for (const auto *name : {"vbs", "vbs.exe"}) {
|
||||
const auto candidate = dir / name;
|
||||
if (std::filesystem::exists(candidate, ec)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
};
|
||||
if (const auto self_exe = Platform::current_executable_path(); self_exe) {
|
||||
const auto sibling = self_exe->parent_path() / "vbs";
|
||||
if (std::filesystem::exists(sibling, ec)) {
|
||||
return sibling;
|
||||
if (auto found = find_in(self_exe->parent_path()); !found.empty()) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
if (!Bootstrap::binary_dir.empty()) {
|
||||
return std::filesystem::path{Bootstrap::binary_dir} / "bin" / "vbs";
|
||||
return find_in(std::filesystem::path{Bootstrap::binary_dir} / "bin");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -91,7 +100,11 @@ VOID_TEST(SelfHostTests, strict_native_selfhost_voidlibrary_and_sdk_without_cmak
|
||||
write_file(
|
||||
trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN STRICT NATIVE STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
@@ -267,7 +280,11 @@ VOID_TEST(SelfHostTests, strict_native_full_vbs_stage1_to_stage2_without_cmake)
|
||||
write_file(
|
||||
trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN STRICT SELF-HOST STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
|
||||
Toolchain::host_architecture_name());
|
||||
@@ -472,7 +489,11 @@ VOID_TEST(SelfHostTests, reproducible_stage2_equals_stage3_artifacts_across_buil
|
||||
const auto trap_bin = tmp / "trap_bin";
|
||||
write_file(trap_bin / "cmake",
|
||||
"#!/bin/sh\necho 'FORBIDDEN CMAKE INVOCATION IN REPRO STAGE' >&2\nexit 99\n");
|
||||
#if defined(_WIN32)
|
||||
return; // The cmake trap is a POSIX shell script.
|
||||
#else
|
||||
(void)::chmod((trap_bin / "cmake").c_str(), 0755);
|
||||
#endif
|
||||
|
||||
std::string trapped_path = trap_bin.string();
|
||||
if (const char *old_path = std::getenv("PATH")) {
|
||||
|
||||
@@ -84,7 +84,10 @@ VOID_TEST(Signing, seed_roundtrip_sign_verify_and_rejections) {
|
||||
const auto permissions = std::filesystem::status(seed_path).permissions();
|
||||
Void::Testing::expect((permissions & Perms::owner_read) != Perms::none);
|
||||
Void::Testing::expect((permissions & Perms::owner_write) != Perms::none);
|
||||
#if !defined(_WIN32)
|
||||
// Windows filesystem permissions are ACL-based and not exposed as POSIX bits.
|
||||
Void::Testing::expect((permissions & (Perms::group_all | Perms::others_all)) == Perms::none);
|
||||
#endif
|
||||
|
||||
auto public_key = Provenance::public_key_from_seed(seed_path);
|
||||
Void::Testing::require(public_key.has_value());
|
||||
|
||||
Reference in new issue
Block a user