Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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"
|
||||
+452
-105
@@ -1,143 +1,490 @@
|
||||
# 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
|
||||
env:
|
||||
ASAN_OPTIONS: detect_leaks=1
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
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
|
||||
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:
|
||||
WINEDEBUG: "-all"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Configure (Debug, Ninja)
|
||||
- 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: |
|
||||
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
|
||||
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
|
||||
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: |
|
||||
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: 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/
|
||||
+32
-12
@@ -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 "de1fdcda72ddd6ac069fba433b13f643327efa3f")
|
||||
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
|
||||
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)
|
||||
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)
|
||||
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{"de1fdcda72ddd6ac069fba433b13f643327efa3f"})
|
||||
.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,10 @@ 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.
|
||||
core.link_option("-lws2_32");
|
||||
}
|
||||
BuildSupport::compiler_warnings(core, ctx);
|
||||
|
||||
// Generate profile-isolated BootstrapConfig.hpp inside $GEN/include/Void/Build/.
|
||||
@@ -51,7 +79,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,21 +108,34 @@ void build(Void::Build::Project &project) {
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(cli, ctx);
|
||||
|
||||
auto registry_lib = project.static_library("VoidBuildRegistry");
|
||||
registry_lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources(project.glob("registry/service/*.cpp"))
|
||||
.include_directory("registry/include", Void::Build::Visibility::Public)
|
||||
.link(core, Void::Build::Visibility::Public);
|
||||
BuildSupport::compiler_warnings(registry_lib, 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"))
|
||||
.include_directory("registry/include", Void::Build::Visibility::Public)
|
||||
.link(core, Void::Build::Visibility::Public);
|
||||
BuildSupport::compiler_warnings(registry_lib, ctx);
|
||||
|
||||
auto registry_cli = project.executable("vbs-registry");
|
||||
registry_cli.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"registry/cli/Main.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.install("bin");
|
||||
BuildSupport::compiler_warnings(registry_cli, ctx);
|
||||
auto registry_cli = project.executable("vbs-registry");
|
||||
registry_cli.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"registry/cli/Main.cpp"})
|
||||
.depends_on(bootstrap_cfg)
|
||||
.include_directory("$GEN/include", Void::Build::Visibility::Private)
|
||||
.link(registry_lib)
|
||||
.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)
|
||||
@@ -139,16 +180,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)
|
||||
list(APPEND VOID_ENABLED_MODULES Sqlite)
|
||||
set(VBS_HAS_VOID_SQLITE ON PARENT_SCOPE)
|
||||
else()
|
||||
set(VBS_HAS_VOID_SQLITE OFF PARENT_SCOPE)
|
||||
endif()
|
||||
# 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)
|
||||
|
||||
# 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).
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
+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) {
|
||||
|
||||
@@ -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
|
||||
+92
-43
@@ -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,56 +491,83 @@ 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";
|
||||
if (!std::filesystem::exists(seal_marker, ec)) {
|
||||
const auto tmp_tree = options.snapshot_store_dir / "trees" /
|
||||
(snap.snapshot_id + ".staging_" +
|
||||
std::to_string(static_cast<long long>(::getpid())));
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
std::filesystem::create_directories(tmp_tree, ec);
|
||||
// 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)) {
|
||||
// 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(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()) {
|
||||
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);
|
||||
} else if (entry.kind == EntryKind::Symlink) {
|
||||
if (!entry.sha256.empty()) {
|
||||
// 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);
|
||||
if (!copied) {
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
return std::unexpected{copied.error()};
|
||||
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()) {
|
||||
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);
|
||||
} else if (entry.kind == EntryKind::Symlink) {
|
||||
if (!entry.sha256.empty()) {
|
||||
// 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);
|
||||
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);
|
||||
std::filesystem::rename(tmp_tree, snap.materialized_root, ec);
|
||||
if (ec) {
|
||||
// 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,
|
||||
std::format("snapshot: failed publishing tree '{}'",
|
||||
snap.materialized_root.string()))};
|
||||
(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.
|
||||
std::filesystem::remove_all(tmp_tree, ec);
|
||||
if (!std::filesystem::exists(seal_marker, ec)) {
|
||||
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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+22
-9
@@ -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
|
||||
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
add_test(NAME vbs_registry_tests COMMAND "$<TARGET_FILE:vbs_registry_tests>" --no-color)
|
||||
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)
|
||||
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)
|
||||
@@ -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
|
||||
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")
|
||||
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
||||
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")
|
||||
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(de1fdcda72ddd6ac069fba433b13f643327efa3f 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{"de1fdcda72ddd6ac069fba433b13f643327efa3f"});
|
||||
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