Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ba637e6b2 | ||
|
|
bb1059651b | ||
|
|
fe453bd601 | ||
|
|
9da1387031 | ||
|
|
2dec3e9259 |
No files matched your search
+25
-10
@@ -88,6 +88,10 @@ jobs:
|
|||||||
build_type: Debug
|
build_type: Debug
|
||||||
cxx_flags: "-fsanitize=address,undefined -fno-omit-frame-pointer"
|
cxx_flags: "-fsanitize=address,undefined -fno-omit-frame-pointer"
|
||||||
linker_flags: "-fsanitize=address,undefined"
|
linker_flags: "-fsanitize=address,undefined"
|
||||||
|
- variant: coverage
|
||||||
|
build_type: Debug
|
||||||
|
cxx_flags: "--coverage -O0"
|
||||||
|
linker_flags: "--coverage"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Configure
|
- name: Configure
|
||||||
@@ -124,13 +128,22 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- variant: debug
|
- variant: debug
|
||||||
test_regex: ""
|
test_regex: ""
|
||||||
|
host_sanitizer_flags: ""
|
||||||
- variant: relwithdebinfo
|
- variant: relwithdebinfo
|
||||||
test_regex: ""
|
test_regex: ""
|
||||||
|
host_sanitizer_flags: ""
|
||||||
- variant: sanitizers
|
- variant: sanitizers
|
||||||
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
||||||
|
host_sanitizer_flags: "-fsanitize=address,undefined -fno-omit-frame-pointer"
|
||||||
|
- variant: coverage
|
||||||
|
test_regex: "vbs_sdk_tests|vbs_core_tests"
|
||||||
|
host_sanitizer_flags: ""
|
||||||
env:
|
env:
|
||||||
ASAN_OPTIONS: detect_leaks=1
|
ASAN_OPTIONS: detect_leaks=1
|
||||||
UBSAN_OPTIONS: print_stacktrace=1
|
UBSAN_OPTIONS: print_stacktrace=1
|
||||||
|
# Instrument the build description too in the sanitizer lane.
|
||||||
|
VBS_HOST_CXX_FLAGS: ${{ matrix.host_sanitizer_flags }}
|
||||||
|
VBS_HOST_LDFLAGS: ${{ matrix.host_sanitizer_flags }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
# Jobs are fresh containers: the upgrade done by `requirements` does not carry over.
|
# Jobs are fresh containers: the upgrade done by `requirements` does not carry over.
|
||||||
@@ -156,12 +169,22 @@ jobs:
|
|||||||
- name: Benchmark smoke run
|
- name: Benchmark smoke run
|
||||||
if: matrix.variant == 'debug'
|
if: matrix.variant == 'debug'
|
||||||
run: build/linux-debug/bin/vbs_benchmarks --files 15
|
run: build/linux-debug/bin/vbs_benchmarks --files 15
|
||||||
|
- name: lcov coverage report
|
||||||
|
if: matrix.variant == 'coverage'
|
||||||
|
run: |
|
||||||
|
lcov --capture --directory "build/linux-coverage" --output-file coverage.info \
|
||||||
|
--ignore-errors mismatch,source,unused,empty,negative,inconsistent \
|
||||||
|
--rc branch_coverage=0 --rc geninfo_unexecuted_blocks=1
|
||||||
|
lcov --summary coverage.info --ignore-errors inconsistent,corrupt
|
||||||
|
lcov --list coverage.info --ignore-errors inconsistent,corrupt | head -40
|
||||||
- name: Upload the test log
|
- name: Upload the test log
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: vbs-linux-test-${{ matrix.variant }}
|
name: vbs-linux-test-${{ matrix.variant }}
|
||||||
path: ctest-linux-${{ matrix.variant }}.log
|
path: |
|
||||||
|
ctest-linux-${{ matrix.variant }}.log
|
||||||
|
coverage.info
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
wine-build:
|
wine-build:
|
||||||
@@ -209,10 +232,6 @@ jobs:
|
|||||||
name: "3B · Windows Wine test (${{ matrix.variant }})"
|
name: "3B · Windows Wine test (${{ matrix.variant }})"
|
||||||
needs: wine-build
|
needs: wine-build
|
||||||
runs-on: windows-gcc
|
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:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -364,9 +383,6 @@ jobs:
|
|||||||
name: "4A2 · VBS installers (windows target)"
|
name: "4A2 · VBS installers (windows target)"
|
||||||
needs: linux-test
|
needs: linux-test
|
||||||
runs-on: windows-gcc
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Download the RelWithDebInfo build
|
- name: Download the RelWithDebInfo build
|
||||||
@@ -450,8 +466,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: vbs-installers-linux-relwithdebinfo
|
name: vbs-installers-linux-relwithdebinfo
|
||||||
path: dist
|
path: dist
|
||||||
- name: Download the Windows installers (when available)
|
- name: Download the Windows installers
|
||||||
continue-on-error: true
|
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: vbs-installers-windows-relwithdebinfo
|
name: vbs-installers-windows-relwithdebinfo
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ add_library(VoidBuild_Core STATIC
|
|||||||
src/Config/CmakeImport.cpp
|
src/Config/CmakeImport.cpp
|
||||||
src/Config/Presets.cpp
|
src/Config/Presets.cpp
|
||||||
src/Config/Scaffold.cpp
|
src/Config/Scaffold.cpp
|
||||||
|
src/Cli/CommandModel.cpp
|
||||||
src/Daemon/Daemon.cpp
|
src/Daemon/Daemon.cpp
|
||||||
src/Report/Cdash.cpp
|
src/Report/Cdash.cpp
|
||||||
src/Report/Coverage.cpp
|
src/Report/Coverage.cpp
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Development state
|
# Development state
|
||||||
|
|
||||||
Updated: 2026-12-03
|
Updated: 2026-12-06
|
||||||
Branch: main
|
Branch: main
|
||||||
Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B1–B3) + Track E1 + `vbs ide` & `build.cpp` CompDB integration + Track D1/D2 + Track E2 + Track D3 SBOM (Docker GCC 16) + Track D3 Ed25519 signing primitives & trusted-key enforcement (OpenSSL-gated crypto) + Track E3 daemon core, bounded describe & build-serving + Track C1 Linux platform split complete
|
Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B1–B3) + Track E1 + `vbs ide` & `build.cpp` CompDB integration + Track D1/D2 + Track E2 + Track D3 SBOM (Docker GCC 16) + Track D3 Ed25519 signing primitives & trusted-key enforcement (OpenSSL-gated crypto) + Track E3 daemon core, bounded describe & build-serving + Track C1 Linux platform split complete
|
||||||
|
|
||||||
@@ -383,6 +383,22 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
|||||||
|
|
||||||
- **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.
|
- **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.
|
||||||
|
|
||||||
|
- **Wave 146 (Gitea CI Hardening, Explainability, Shared Caches, CLI Surface & Migration Breadth)**:
|
||||||
|
- **CI images (`Void/CI-Images`)**: the `vulkan` image gained `msitools` (wixl/msiinfo), `rpm-tools`, `dpkg`, `meson` and `lcov`; `windows-gcc` and `windows-clang` gained `msitools`, and the image workflow now verifies the tools inside every built image.
|
||||||
|
- **CI**: a `coverage` Linux variant (`--coverage`, lcov report uploaded as an artifact) joins Debug, RelWithDebInfo and Sanitizers; the MSI installer step stops being skipped once the images ship msitools. The lcov invocation is verified locally against a `--coverage` build of the SDK/core suites (lcov 2.4 needs `negative`/`inconsistent` ignored for GCC gcov data).
|
||||||
|
- **Test-runner controls**: `--repeat until-fail|until-pass|after-timeout[:N]`, `--retry N`, `--shuffle [--shuffle-seed N]` and `--stop-on-failure` (which also skips the remaining profiles).
|
||||||
|
- **Explainability**: `vbs explain [--format text|json]` reports why each action would run (missing cache record, changed discovered inputs, changed/missing outputs, restorable outputs, shared-remote-cache hits) via `Execution::explain_graph` without executing anything.
|
||||||
|
- **Observability**: `vbs build|test --trace FILE` writes a Chrome trace with phase spans (config, toolchain, eval, snapshot, graph, total) and per-action spans.
|
||||||
|
- **Cold start**: compiled descriptors and toolchain probes are shared through `$XDG_CACHE_HOME/vbs` (opt out with `VBS_SHARED_CACHE=0`). Measured on the 20-source fixture: a fresh build directory fell from 3897 ms to 755 ms (config 1986->128 ms, toolchain 562->6.5 ms); warm stays ~150 ms.
|
||||||
|
- **CLI surface**: `vbs completions --shell bash|zsh|fish` and `vbs man [--output DIR]` are generated from the live parser tree (86 man pages), so they cannot drift from the CLI; the generated bash script passes `bash -n`.
|
||||||
|
- **Migration breadth**: `vbs migrate --from meson` imports `project`, variable assignments (`files`, `include_directories`), `executable`/`static_library`/`shared_library`/`library` with `link_with`, `include_directories`, `dependencies`, `install`/`install_dir`, and reports everything else.
|
||||||
|
- **Templates & presets**: `vbs init --template app|library|header-only|shared` (all four scaffold and pass their own test), and `vbs presets --export FILE` writes VBS profiles as CMake configure presets (round-trippable through the importer).
|
||||||
|
- **Packaging**: `vbs install --archive-format msi` renders the WiX source with absolute file sources and compiles it with `wixl` (msitools) or the WiX toolset (`candle`/`light`), failing explicitly when neither exists; the release step replaces same-named assets when a tag is republished.
|
||||||
|
- **Sanitizer coverage**: `VBS_HOST_CXX_FLAGS`/`VBS_HOST_LDFLAGS` instrument the compiled build descriptor too, and the CI sanitizer lane sets them (previously descriptor compilation did not inherit sanitizer flags).
|
||||||
|
- **IDE debug integration**: `vbs ide generate` now also writes JetBrains run configurations (`.idea/runConfigurations/vbs_{build,test}_<target>.xml`) beside the VS Code and Zed debug configs.
|
||||||
|
- **Worker reliability**: the registry queue counts lease attempts per action (`attempt` in the lease response, `attempts` in the queue listing) and abandons an action after 5 attempts into an `abandoned` dead-letter list instead of leasing it forever; `RegistryTests.worker_queue_abandons_actions_after_repeated_leases` covers it.
|
||||||
|
|
||||||
|
|
||||||
## Remaining future scope
|
## 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.
|
- **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.
|
||||||
|
|||||||
@@ -145,4 +145,5 @@ Base HEAD: `fe0d1a6`
|
|||||||
| 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 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 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 |
|
| 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 |
|
||||||
|
| Wave 146 (CI hardening, explainability, shared caches, CLI surface, migration breadth) | CI image tool upgrades + coverage lane; test `--repeat/--retry/--shuffle/--stop-on-failure`; `vbs explain`; `--trace` Chrome traces; shared descriptor/probe caches; `vbs completions`/`vbs man`; `vbs migrate --from meson`; `vbs init --template`; `vbs presets --export`; MSI installer | COMPLETE & VERIFIED (GCC 16.2; new FullV1Tests cases for every feature pass, CLI contract suite passes; cold build 3897 -> 755 ms measured) | `src/Main.cpp`, `src/Execution/Scheduler.{hpp,cpp}`, `src/Cli/CommandModel.{hpp,cpp}`, `src/Config/{Frontend,Scaffold,CmakeImport}.cpp`, `src/Toolchain/Driver.cpp`, `include/Void/Build/Util/UserCache.hpp`, `.gitea/workflows/ci.yml`, [Void/CI-Images](https://git.faumaray.com/Void/CI-Images), `tests/{FullV1Tests,CliContracts}`, 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) |
|
| 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) |
|
||||||
@@ -122,36 +122,40 @@ first, then what makes VBS *better* rather than merely equal.
|
|||||||
3. **Platform breadth - deferred.** Native MSVC and Apple Clang/macOS stay deferred by
|
3. **Platform breadth - deferred.** Native MSVC and Apple Clang/macOS stay deferred by
|
||||||
decision; MinGW cross + Wine is the current Windows story.
|
decision; MinGW cross + Wine is the current Windows story.
|
||||||
4. **Package-generator parity.** CPack also ships NuGet, PKG/productbuild, APK and IFW
|
4. **Package-generator parity.** CPack also ships NuGet, PKG/productbuild, APK and IFW
|
||||||
installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX, UDIF and NuGet (Wave 144). PKG is
|
installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX, MSI (compiled with wixl/candle), UDIF and
|
||||||
the next useful one.
|
NuGet (Wave 144). PKG is the next useful one.
|
||||||
|
|
||||||
### 8.2 Developer experience and IDE integration
|
### 8.2 Developer experience and IDE integration
|
||||||
|
|
||||||
6. **Coverage reporting - done (Wave 145).** `vbs test --coverage` produces lcov (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
|
llvm-cov for Clang) alongside JUnit. CMake has `CTestCoverageCollectGCOV`; Meson has the
|
||||||
`b_coverage` option.
|
`b_coverage` option.
|
||||||
7. **Test repetition controls.** CTest offers `--repeat until-fail|after-timeout|until-pass`,
|
7. **Test repetition controls - done (Wave 146).** `vbs test` now has `--repeat
|
||||||
`--shuffle`, `--stop-on-failure` and per-test retries; VBS has labels, resources, fixtures,
|
until-fail|until-pass|after-timeout[:N]`, `--retry N`, `--shuffle [--shuffle-seed N]`
|
||||||
timeouts, JUnit and CDash but none of these. Flaky-test retries are valuable for CI.
|
and `--stop-on-failure`, alongside labels, resources, fixtures, timeouts, JUnit and CDash.
|
||||||
8. **IDE debug integration.** `vbs ide generate` writes editor configs, but not debug
|
8. **IDE debug integration.** `vbs ide generate` writes `.vscode/launch.json` and
|
||||||
configurations: add `.vscode/launch.json`/`tasks.json` (gdb/lldb) and JetBrains run
|
`.zed/debug.json` debug configurations; JetBrains run configurations per target remain
|
||||||
configurations per target. Also export `CMakePresets.json` so CMake-only tools can read a
|
open. `vbs presets --export FILE` (**done**) writes VBS profiles as CMake presets so
|
||||||
VBS project.
|
CMake-only tools can read a VBS project.
|
||||||
9. **Shell completions and man pages** for `vbs` (bash/zsh/fish), generated from the argparse
|
9. **Shell completions and man pages - done (Wave 146).** `vbs completions --shell
|
||||||
tree.
|
bash|zsh|fish` and `vbs man [--output DIR]` are generated from the argparse tree.
|
||||||
10. **Migration breadth.** `vbs migrate` handles a bounded CMake subset; add `--from meson`
|
10. **Migration breadth.** `vbs migrate` handles a bounded CMake subset and now also
|
||||||
and cover more CMake commands. `vbs init` could grow templates (header-only, shared
|
`--from meson` (`meson.build`: project, variables, targets, link_with,
|
||||||
library, GUI).
|
include_directories, install). `vbs init --template app|library|header-only|shared`
|
||||||
|
provides project templates.
|
||||||
|
|
||||||
### 8.3 Differentiators worth building (incumbents lack these)
|
### 8.3 Differentiators worth building (incumbents lack these)
|
||||||
|
|
||||||
11. **`vbs explain`.** Why did an action re-run? VBS already stores cached action digests and
|
11. **`vbs explain` - done (Wave 146).** Why did an action re-run? `vbs explain` compares
|
||||||
inputs; the explain report (changed input, command, environment, cache miss) is a cheap,
|
every selected action against the CAS record and reports the changed inputs/outputs,
|
||||||
high-value debugging feature that Ninja/CMake/Meson do not offer.
|
missing records, restorable outputs and remote-cache hits, as text or JSON. Ninja/CMake/Meson
|
||||||
|
do not offer this.
|
||||||
12. **Enforced hermetic sandboxing.** Snapshots already define exact inputs; enforcing that
|
12. **Enforced hermetic sandboxing.** Snapshots already define exact inputs; enforcing that
|
||||||
actions see *only* them (mount/user namespaces) would make incrementality and
|
actions see *only* them (mount/user namespaces) would make incrementality and
|
||||||
reproducibility a guarantee rather than a convention (Bazel-style).
|
reproducibility a guarantee rather than a convention (Bazel-style).
|
||||||
13. **Build Event Protocol / Chrome trace output** for CI dashboards and IDE timelines.
|
13. **Build Event Protocol / Chrome trace output - Chrome trace done (Wave 146).**
|
||||||
|
`vbs build|test --trace FILE` writes a Chrome trace with phase and action spans for CI
|
||||||
|
dashboards and IDE timelines; a full BEP stream remains open.
|
||||||
14. **Multi-machine orchestration.** The registry, queue, leases, remote execution and
|
14. **Multi-machine orchestration.** The registry, queue, leases, remote execution and
|
||||||
parallel workers exist; coordinating several machines (capacity, retries, affinity) is the
|
parallel workers exist; coordinating several machines (capacity, retries, affinity) is the
|
||||||
remaining step.
|
remaining step.
|
||||||
@@ -160,9 +164,10 @@ first, then what makes VBS *better* rather than merely equal.
|
|||||||
|
|
||||||
### 8.4 Performance note
|
### 8.4 Performance note
|
||||||
|
|
||||||
The 92 ms warm no-op was measured with a **Debug** `vbs` binary. Before optimizing further,
|
The 92 ms warm no-op was measured with a **Debug** `vbs` binary. The shared per-user caches
|
||||||
re-run `benchmarks/compare.sh` against a Release build, then attack the cold-start cost
|
(Wave 146) removed most of the cold-start cost in a fresh build directory (3897 -> 755 ms on
|
||||||
(descriptor compilation dominates: 2.6 s cold vs CMake's 97 ms on 20 sources).
|
the 20-source fixture); warm no-ops stay around 150 ms. Next: re-run `benchmarks/compare.sh`
|
||||||
|
against a Release build and keep snapshot work proportional to changed files.
|
||||||
|
|
||||||
## 7. Acceptance gates
|
## 7. Acceptance gates
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Void/Functional/Error.hpp>
|
||||||
|
#include <Void/Functional/Result.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Void::Build::Cli {
|
||||||
|
|
||||||
|
struct OptionSpec {
|
||||||
|
std::string long_name; // "--project" (empty for a positional-only entry)
|
||||||
|
std::string short_name; // "-C" or empty
|
||||||
|
bool takes_value{false};
|
||||||
|
std::string description;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CommandSpec {
|
||||||
|
std::string name; // "build", "use"; empty for the root command
|
||||||
|
std::string path; // "vbs", "vbs build", "vbs compdb use"
|
||||||
|
std::vector<std::string> argv; // {"compdb", "use"}
|
||||||
|
std::string usage;
|
||||||
|
std::string description;
|
||||||
|
std::vector<OptionSpec> flags;
|
||||||
|
std::vector<OptionSpec> options;
|
||||||
|
std::vector<CommandSpec> subcommands;
|
||||||
|
|
||||||
|
[[nodiscard]] std::vector<std::string> words() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Collects the whole command model by running `<vbs> <path...> --help` for the root command and
|
||||||
|
// every subcommand, so completions and man pages can never drift from the parser.
|
||||||
|
[[nodiscard]] Void::Result::Result<CommandSpec, Void::Result::Error>
|
||||||
|
build_command_model(const std::filesystem::path &vbs_executable);
|
||||||
|
|
||||||
|
// Flattens the tree into every command (root first, then depth-first).
|
||||||
|
[[nodiscard]] std::vector<const CommandSpec *> flatten_commands(const CommandSpec &root);
|
||||||
|
|
||||||
|
[[nodiscard]] std::string render_bash_completion(const CommandSpec &root);
|
||||||
|
[[nodiscard]] std::string render_zsh_completion(const CommandSpec &root);
|
||||||
|
[[nodiscard]] std::string render_fish_completion(const CommandSpec &root);
|
||||||
|
|
||||||
|
// roff man page for one command; `man_page_name` is its file stem ("vbs", "vbs-compdb-use").
|
||||||
|
[[nodiscard]] std::string man_page_name(const CommandSpec &command);
|
||||||
|
[[nodiscard]] std::string render_man_page(const CommandSpec &command, std::string_view version);
|
||||||
|
|
||||||
|
} // namespace Void::Build::Cli
|
||||||
@@ -39,6 +39,13 @@ struct MigrationResult {
|
|||||||
import_cmake_lists(const std::filesystem::path &cmake_file,
|
import_cmake_lists(const std::filesystem::path &cmake_file,
|
||||||
const std::filesystem::path &project_root);
|
const std::filesystem::path &project_root);
|
||||||
|
|
||||||
|
// Bounded meson.build reader: understands `project`, variable assignments (`files(...)`,
|
||||||
|
// `include_directories(...)`), `executable`/`static_library`/`shared_library`/`library` with
|
||||||
|
// `link_with`, `include_directories`, `install` and `install_dir`. Everything else is a note.
|
||||||
|
[[nodiscard]] Void::Result::Result<MigrationResult, Void::Result::Error>
|
||||||
|
import_meson_build(const std::filesystem::path &meson_file,
|
||||||
|
const std::filesystem::path &project_root);
|
||||||
|
|
||||||
// Renders the imported targets as a `build.cpp` scaffold.
|
// Renders the imported targets as a `build.cpp` scaffold.
|
||||||
[[nodiscard]] std::string render_build_cpp(const MigrationResult &result);
|
[[nodiscard]] std::string render_build_cpp(const MigrationResult &result);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ struct FrontendOptions {
|
|||||||
std::optional<std::filesystem::path> host_compiler;
|
std::optional<std::filesystem::path> host_compiler;
|
||||||
// Extra environment for the descriptor process (e.g. dependency options for a native dep).
|
// Extra environment for the descriptor process (e.g. dependency options for a native dep).
|
||||||
std::map<std::string, std::string, std::less<>> extra_environment;
|
std::map<std::string, std::string, std::less<>> extra_environment;
|
||||||
|
// Extra flags for compiling/linking the descriptor itself (e.g. sanitizer instrumentation
|
||||||
|
// so a sanitizer build covers the build description as well as the project).
|
||||||
|
std::vector<std::string> host_compile_flags;
|
||||||
|
std::vector<std::string> host_link_flags;
|
||||||
std::chrono::milliseconds eval_timeout{std::chrono::seconds{30}};
|
std::chrono::milliseconds eval_timeout{std::chrono::seconds{30}};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ struct ScaffoldOptions {
|
|||||||
bool library{false};
|
bool library{false};
|
||||||
bool with_toml{false};
|
bool with_toml{false};
|
||||||
bool force{false}; // Overwrite an existing build.cpp
|
bool force{false}; // Overwrite an existing build.cpp
|
||||||
|
// Template shape: "app" (default), "library", "header-only", "shared" or "gui".
|
||||||
|
std::string template_name{"app"};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScaffoldReport {
|
struct ScaffoldReport {
|
||||||
|
|||||||
@@ -62,6 +62,30 @@ struct ExecutionReport {
|
|||||||
std::string diagnostic;
|
std::string diagnostic;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Why an action would run (or be reused) on the next build: the explain report answers
|
||||||
|
// "what changed?" without executing anything.
|
||||||
|
struct ActionExplanation {
|
||||||
|
std::string action_id;
|
||||||
|
std::string target_name;
|
||||||
|
std::string label;
|
||||||
|
std::string action_key;
|
||||||
|
std::string command;
|
||||||
|
bool cacheable{true};
|
||||||
|
bool would_run{false};
|
||||||
|
bool restorable{false}; // outputs can be restored from the CAS without executing
|
||||||
|
bool remote_hit{false}; // a shared remote cache holds this action
|
||||||
|
std::string reason;
|
||||||
|
std::vector<std::string> changed_inputs;
|
||||||
|
std::vector<std::string> changed_outputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ExplainReport {
|
||||||
|
std::size_t total{0};
|
||||||
|
std::size_t up_to_date{0};
|
||||||
|
std::size_t would_run{0};
|
||||||
|
std::vector<ActionExplanation> actions;
|
||||||
|
};
|
||||||
|
|
||||||
// Parses a GCC/Clang GNU Make depfile (.d) into its list of dependency file paths.
|
// Parses a GCC/Clang GNU Make depfile (.d) into its list of dependency file paths.
|
||||||
[[nodiscard]] Void::Result::Result<std::vector<std::filesystem::path>, Void::Result::Error>
|
[[nodiscard]] Void::Result::Result<std::vector<std::filesystem::path>, Void::Result::Error>
|
||||||
parse_depfile(const std::filesystem::path &depfile_path);
|
parse_depfile(const std::filesystem::path &depfile_path);
|
||||||
@@ -72,4 +96,11 @@ parse_depfile(const std::filesystem::path &depfile_path);
|
|||||||
execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||||
const ExecutionOptions &options = {}, std::stop_token stop = {});
|
const ExecutionOptions &options = {}, std::stop_token stop = {});
|
||||||
|
|
||||||
|
// Explains, without executing anything, why each selected action would run or be reused:
|
||||||
|
// cache-record presence, changed discovered inputs, changed/missing outputs, and whether a
|
||||||
|
// shared remote cache holds the action.
|
||||||
|
[[nodiscard]] Void::Result::Result<ExplainReport, Void::Result::Error>
|
||||||
|
explain_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||||
|
const ExecutionOptions &options = {});
|
||||||
|
|
||||||
} // namespace Void::Build::Execution
|
} // namespace Void::Build::Execution
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Void/Configuration/Env.hpp>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <system_error>
|
||||||
|
|
||||||
|
namespace Void::Build::Util {
|
||||||
|
|
||||||
|
// Shared per-user cache root: $XDG_CACHE_HOME/vbs/<subdirectory>, or ~/.cache/vbs/<subdirectory>.
|
||||||
|
//
|
||||||
|
// These caches only ever hold content-addressed artifacts (toolchain probe results, compiled
|
||||||
|
// build descriptors) whose keys include the compiler identity and every input hash, so sharing
|
||||||
|
// them across build directories and projects cannot change a build's result. Set
|
||||||
|
// VBS_SHARED_CACHE=0 to keep every build directory self-contained (CI isolation).
|
||||||
|
[[nodiscard]] inline std::optional<std::filesystem::path>
|
||||||
|
user_cache_dir(std::string_view subdirectory) {
|
||||||
|
const std::string enabled = Void::Configuration::get_env_or("VBS_SHARED_CACHE", "1");
|
||||||
|
if (enabled == "0" || enabled == "false" || enabled == "off") {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
std::filesystem::path base;
|
||||||
|
const std::string xdg = Void::Configuration::get_env_or("XDG_CACHE_HOME", "");
|
||||||
|
if (!xdg.empty()) {
|
||||||
|
base = xdg;
|
||||||
|
} else {
|
||||||
|
const std::string home = Void::Configuration::get_env_or("HOME", "");
|
||||||
|
if (home.empty()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
base = std::filesystem::path{home} / ".cache";
|
||||||
|
}
|
||||||
|
std::error_code ec;
|
||||||
|
const auto dir = base / "vbs" / subdirectory;
|
||||||
|
std::filesystem::create_directories(dir, ec);
|
||||||
|
if (ec) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Void::Build::Util
|
||||||
@@ -179,6 +179,11 @@ class RegistryService {
|
|||||||
std::map<std::string, WorkerRecord, std::less<>> workers_;
|
std::map<std::string, WorkerRecord, std::less<>> workers_;
|
||||||
std::map<std::string, ActionLeaseRecord, std::less<>> action_leases_; // action_key -> lease
|
std::map<std::string, ActionLeaseRecord, std::less<>> action_leases_; // action_key -> lease
|
||||||
std::vector<std::string> action_queue_; // enqueued action keys (in-memory)
|
std::vector<std::string> action_queue_; // enqueued action keys (in-memory)
|
||||||
|
// Leases handed out per queued action; after kMaxActionAttempts the action is abandoned
|
||||||
|
// (dead-lettered) instead of being retried forever.
|
||||||
|
std::map<std::string, std::uint32_t, std::less<>> action_attempts_;
|
||||||
|
std::vector<std::string> abandoned_actions_;
|
||||||
|
static constexpr std::uint32_t kMaxActionAttempts = 5;
|
||||||
std::uint64_t worker_sequence_{0};
|
std::uint64_t worker_sequence_{0};
|
||||||
std::vector<AuditEntry> audits_;
|
std::vector<AuditEntry> audits_;
|
||||||
HttpServer server_;
|
HttpServer server_;
|
||||||
|
|||||||
@@ -1045,9 +1045,18 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
|
|||||||
leased_keys.push_back(key);
|
leased_keys.push_back(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::string attempts_json;
|
||||||
|
for (const auto &[key, attempts] : action_attempts_) {
|
||||||
|
if (!attempts_json.empty()) {
|
||||||
|
attempts_json += ',';
|
||||||
|
}
|
||||||
|
attempts_json += json_quote(key) + ":" + std::to_string(attempts);
|
||||||
|
}
|
||||||
return HttpResponse::json(
|
return HttpResponse::json(
|
||||||
200, "{\"pending\":" + json_array(pending, json_quote) +
|
200, "{\"pending\":" + json_array(pending, json_quote) +
|
||||||
",\"leased\":" + json_array(leased_keys, json_quote) + "}\n");
|
",\"leased\":" + json_array(leased_keys, json_quote) +
|
||||||
|
",\"attempts\":{" + attempts_json + "}" + ",\"abandoned\":" +
|
||||||
|
json_array(abandoned_actions_, json_quote) + "}\n");
|
||||||
}
|
}
|
||||||
if (segs.size() == 3 && req.method == "POST") {
|
if (segs.size() == 3 && req.method == "POST") {
|
||||||
if (!principal->scopes.contains("publish") && principal->role != Role::Admin) {
|
if (!principal->scopes.contains("publish") && principal->role != Role::Admin) {
|
||||||
@@ -1102,24 +1111,42 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
|
|||||||
return HttpResponse::error_json(404, "not_found", "worker not registered");
|
return HttpResponse::error_json(404, "not_found", "worker not registered");
|
||||||
}
|
}
|
||||||
prune_expired_leases();
|
prune_expired_leases();
|
||||||
const auto next = std::ranges::find_if(action_queue_, [&](const std::string &key) {
|
// Skip actions that exceeded their attempt budget (dead-letter them).
|
||||||
return !action_leases_.contains(key);
|
std::optional<std::string> picked;
|
||||||
});
|
for (auto it = action_queue_.begin(); it != action_queue_.end();) {
|
||||||
if (next == action_queue_.end()) {
|
if (action_leases_.contains(*it)) {
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto &attempts = action_attempts_[*it];
|
||||||
|
if (attempts >= kMaxActionAttempts) {
|
||||||
|
abandoned_actions_.push_back(*it);
|
||||||
|
append_audit_locked(principal->username, "queue.abandon", *it,
|
||||||
|
"attempts_exhausted", std::to_string(attempts));
|
||||||
|
action_attempts_.erase(*it);
|
||||||
|
it = action_queue_.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++attempts;
|
||||||
|
picked = *it;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!picked) {
|
||||||
return HttpResponse::error_json(404, "empty", "no queued action available");
|
return HttpResponse::error_json(404, "empty", "no queued action available");
|
||||||
}
|
}
|
||||||
ActionLeaseRecord lease;
|
ActionLeaseRecord lease;
|
||||||
lease.action_key = *next;
|
lease.action_key = *picked;
|
||||||
lease.worker_id = worker_id;
|
lease.worker_id = worker_id;
|
||||||
lease.lease_token = random_hex(16);
|
lease.lease_token = random_hex(16);
|
||||||
lease.expires_epoch = now_epoch() + lease_seconds;
|
lease.expires_epoch = now_epoch() + lease_seconds;
|
||||||
action_leases_[*next] = lease;
|
action_leases_[*picked] = lease;
|
||||||
append_audit_locked(principal->username, "queue.lease", *next, "ok", worker_id);
|
append_audit_locked(principal->username, "queue.lease", *picked, "ok", worker_id);
|
||||||
return HttpResponse::json(
|
return HttpResponse::json(
|
||||||
200, "{\"action_key\":" + json_quote(*next) +
|
200, "{\"action_key\":" + json_quote(*picked) +
|
||||||
",\"worker_id\":" + json_quote(worker_id) +
|
",\"worker_id\":" + json_quote(worker_id) +
|
||||||
",\"lease_token\":" + json_quote(lease.lease_token) +
|
",\"lease_token\":" + json_quote(lease.lease_token) +
|
||||||
",\"expires_epoch\":" + std::to_string(lease.expires_epoch) + "}\n");
|
",\"expires_epoch\":" + std::to_string(lease.expires_epoch) +
|
||||||
|
",\"attempt\":" + std::to_string(action_attempts_[*picked]) + "}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1295,6 +1322,7 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
|
|||||||
action_leases_.erase(lease_it);
|
action_leases_.erase(lease_it);
|
||||||
action_queue_.erase(std::remove(action_queue_.begin(), action_queue_.end(), action_key),
|
action_queue_.erase(std::remove(action_queue_.begin(), action_queue_.end(), action_key),
|
||||||
action_queue_.end());
|
action_queue_.end());
|
||||||
|
action_attempts_.erase(action_key);
|
||||||
append_audit_locked(principal->username, "action.result", action_key, "ok",
|
append_audit_locked(principal->username, "action.result", action_key, "ok",
|
||||||
existed ? "replaced" : "stored");
|
existed ? "replaced" : "stored");
|
||||||
return HttpResponse::json(200, "{\"stored\":true}\n");
|
return HttpResponse::json(200, "{\"stored\":true}\n");
|
||||||
|
|||||||
@@ -0,0 +1,521 @@
|
|||||||
|
#include <Void/Build/Cli/CommandModel.hpp>
|
||||||
|
|
||||||
|
#include <Void/Build/Platform/FileOps.hpp>
|
||||||
|
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||||
|
#include <Void/System/Types.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
|
namespace Void::Build::Cli {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Void::Result::Error make_error(std::string message) {
|
||||||
|
return Void::System::make_system_error(Void::System::SystemErrorCode::invalid_argument,
|
||||||
|
std::move(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string trim(std::string_view text) {
|
||||||
|
const auto first = text.find_first_not_of(" \t\r");
|
||||||
|
if (first == std::string_view::npos) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const auto last = text.find_last_not_of(" \t\r");
|
||||||
|
return std::string{text.substr(first, last - first + 1)};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> split_lines(std::string_view text) {
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
std::size_t pos = 0;
|
||||||
|
while (pos <= text.size()) {
|
||||||
|
const auto eol = text.find('\n', pos);
|
||||||
|
if (eol == std::string_view::npos) {
|
||||||
|
lines.emplace_back(text.substr(pos));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
lines.emplace_back(text.substr(pos, eol - pos));
|
||||||
|
pos = eol + 1;
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splits " --project, -C <value> Project directory" into its name and description parts.
|
||||||
|
std::pair<std::string, std::string> split_entry(std::string_view line) {
|
||||||
|
const std::string content = trim(line);
|
||||||
|
for (std::size_t i = 0; i + 1 < content.size(); ++i) {
|
||||||
|
if (content[i] == ' ' && content[i + 1] == ' ') {
|
||||||
|
return {trim(std::string_view{content}.substr(0, i)),
|
||||||
|
trim(std::string_view{content}.substr(i))};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {content, {}};
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionSpec parse_option_entry(std::string_view name_part, std::string description) {
|
||||||
|
OptionSpec spec;
|
||||||
|
spec.description = std::move(description);
|
||||||
|
const std::string text{name_part};
|
||||||
|
std::size_t pos = 0;
|
||||||
|
while (pos < text.size()) {
|
||||||
|
const auto comma = text.find(", ", pos);
|
||||||
|
const std::string token = trim(std::string_view{text}.substr(
|
||||||
|
pos, comma == std::string::npos ? std::string::npos : comma - pos));
|
||||||
|
pos = comma == std::string::npos ? text.size() : comma + 2;
|
||||||
|
std::string name = token;
|
||||||
|
if (const auto value = name.find(" <value>"); value != std::string::npos) {
|
||||||
|
spec.takes_value = true;
|
||||||
|
name = name.substr(0, value);
|
||||||
|
}
|
||||||
|
if (name.starts_with("--")) {
|
||||||
|
if (spec.long_name.empty()) {
|
||||||
|
spec.long_name = name;
|
||||||
|
}
|
||||||
|
} else if (name.starts_with("-") && spec.short_name.empty()) {
|
||||||
|
spec.short_name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ParsedHelp {
|
||||||
|
std::string usage;
|
||||||
|
std::string description;
|
||||||
|
std::vector<OptionSpec> flags;
|
||||||
|
std::vector<OptionSpec> options;
|
||||||
|
std::vector<std::pair<std::string, std::string>> commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
ParsedHelp parse_help(std::string_view text) {
|
||||||
|
ParsedHelp out;
|
||||||
|
enum class Section { None, Commands, Arguments, Flags, Options };
|
||||||
|
enum class Last { None, Command, Flag, Option };
|
||||||
|
Section section = Section::None;
|
||||||
|
Last last = Last::None;
|
||||||
|
std::size_t last_index = 0;
|
||||||
|
bool saw_usage = false;
|
||||||
|
std::string description;
|
||||||
|
|
||||||
|
const auto append = [](std::string &target, const std::string &text) {
|
||||||
|
if (!target.empty()) {
|
||||||
|
target += ' ';
|
||||||
|
}
|
||||||
|
target += text;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto &line : split_lines(text)) {
|
||||||
|
const std::string trimmed = trim(line);
|
||||||
|
if (trimmed.starts_with("Usage:")) {
|
||||||
|
out.usage = trim(std::string_view{trimmed}.substr(6));
|
||||||
|
saw_usage = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed == "Commands:") {
|
||||||
|
section = Section::Commands;
|
||||||
|
last = Last::None;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed == "Arguments:") {
|
||||||
|
section = Section::Arguments;
|
||||||
|
last = Last::None;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed == "Flags:") {
|
||||||
|
section = Section::Flags;
|
||||||
|
last = Last::None;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed == "Options:") {
|
||||||
|
section = Section::Options;
|
||||||
|
last = Last::None;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trimmed.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const bool entry_line = line.starts_with(" ") && !line.starts_with(" ");
|
||||||
|
if (!entry_line) {
|
||||||
|
if (section == Section::None) {
|
||||||
|
if (saw_usage) {
|
||||||
|
append(description, trimmed);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (last) {
|
||||||
|
case Last::Command:
|
||||||
|
append(out.commands[last_index].second, trimmed);
|
||||||
|
break;
|
||||||
|
case Last::Flag:
|
||||||
|
append(out.flags[last_index].description, trimmed);
|
||||||
|
break;
|
||||||
|
case Last::Option:
|
||||||
|
append(out.options[last_index].description, trimmed);
|
||||||
|
break;
|
||||||
|
case Last::None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto [name_part, entry_description] = split_entry(line);
|
||||||
|
switch (section) {
|
||||||
|
case Section::Commands:
|
||||||
|
out.commands.emplace_back(name_part, entry_description);
|
||||||
|
last = Last::Command;
|
||||||
|
last_index = out.commands.size() - 1;
|
||||||
|
break;
|
||||||
|
case Section::Flags:
|
||||||
|
out.flags.push_back(parse_option_entry(name_part, entry_description));
|
||||||
|
last = Last::Flag;
|
||||||
|
last_index = out.flags.size() - 1;
|
||||||
|
break;
|
||||||
|
case Section::Options:
|
||||||
|
out.options.push_back(parse_option_entry(name_part, entry_description));
|
||||||
|
last = Last::Option;
|
||||||
|
last_index = out.options.size() - 1;
|
||||||
|
break;
|
||||||
|
case Section::Arguments:
|
||||||
|
case Section::None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.description = trim(description);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string join_words(const std::vector<std::string> &words) {
|
||||||
|
std::string out;
|
||||||
|
for (const auto &word : words) {
|
||||||
|
if (!out.empty()) {
|
||||||
|
out += ' ';
|
||||||
|
}
|
||||||
|
out += word;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Void::Result::Result<std::string, Void::Result::Error>
|
||||||
|
run_help(const std::filesystem::path &vbs_executable, const std::vector<std::string> &argv) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_executable;
|
||||||
|
req.arguments = argv;
|
||||||
|
req.arguments.emplace_back("--help");
|
||||||
|
req.environment.set_vars["NO_COLOR"] = "1";
|
||||||
|
req.timeout = std::chrono::seconds{30};
|
||||||
|
auto res = Platform::run_supervised(req);
|
||||||
|
if (!res) {
|
||||||
|
return std::unexpected{res.error()};
|
||||||
|
}
|
||||||
|
if (!res->succeeded()) {
|
||||||
|
return std::unexpected{make_error(std::format("'vbs {} --help' failed (exit {})",
|
||||||
|
join_words(argv), res->exit_code))};
|
||||||
|
}
|
||||||
|
return res->stdout_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Void::Result::Result<void, Void::Result::Error>
|
||||||
|
populate(const std::filesystem::path &vbs_executable, CommandSpec &command, int depth) {
|
||||||
|
auto help = run_help(vbs_executable, command.argv);
|
||||||
|
if (!help) {
|
||||||
|
return std::unexpected{help.error()};
|
||||||
|
}
|
||||||
|
const auto parsed = parse_help(*help);
|
||||||
|
command.usage = parsed.usage;
|
||||||
|
command.description = parsed.description;
|
||||||
|
command.flags = parsed.flags;
|
||||||
|
command.options = parsed.options;
|
||||||
|
if (depth >= 4) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
for (const auto &[name, description] : parsed.commands) {
|
||||||
|
CommandSpec child;
|
||||||
|
child.name = name;
|
||||||
|
child.argv = command.argv;
|
||||||
|
child.argv.push_back(name);
|
||||||
|
child.path = command.path + " " + name;
|
||||||
|
child.description = description;
|
||||||
|
auto populated = populate(vbs_executable, child, depth + 1);
|
||||||
|
if (!populated) {
|
||||||
|
return populated;
|
||||||
|
}
|
||||||
|
command.subcommands.push_back(std::move(child));
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> child_names(const CommandSpec &command) {
|
||||||
|
std::vector<std::string> names;
|
||||||
|
names.reserve(command.subcommands.size());
|
||||||
|
for (const auto &child : command.subcommands) {
|
||||||
|
names.push_back(child.name);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string case_pattern(const std::vector<std::string> &names) {
|
||||||
|
std::string pattern;
|
||||||
|
for (const auto &name : names) {
|
||||||
|
if (!pattern.empty()) {
|
||||||
|
pattern += '|';
|
||||||
|
}
|
||||||
|
pattern += name;
|
||||||
|
}
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subcommand names plus every long and short option spelling, sorted and deduplicated.
|
||||||
|
std::vector<std::string> completion_words(const CommandSpec &command) {
|
||||||
|
std::vector<std::string> words = child_names(command);
|
||||||
|
for (const auto &spec : command.flags) {
|
||||||
|
if (!spec.long_name.empty()) {
|
||||||
|
words.push_back(spec.long_name);
|
||||||
|
}
|
||||||
|
if (!spec.short_name.empty()) {
|
||||||
|
words.push_back(spec.short_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &spec : command.options) {
|
||||||
|
if (!spec.long_name.empty()) {
|
||||||
|
words.push_back(spec.long_name);
|
||||||
|
}
|
||||||
|
if (!spec.short_name.empty()) {
|
||||||
|
words.push_back(spec.short_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::sort(words.begin(), words.end());
|
||||||
|
words.erase(std::unique(words.begin(), words.end()), words.end());
|
||||||
|
return words;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string command_key(const CommandSpec &command) {
|
||||||
|
return join_words(command.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emits the path-walking preamble shared by the bash and zsh scripts.
|
||||||
|
std::string render_path_walk(const std::vector<const CommandSpec *> &commands,
|
||||||
|
std::string_view word_var) {
|
||||||
|
std::string out;
|
||||||
|
const std::string root_pattern = case_pattern(child_names(*commands.front()));
|
||||||
|
out += " if [[ -z \"$path\" ]]; then\n";
|
||||||
|
out += std::format(" case \"${}\" in\n", word_var);
|
||||||
|
out += std::format(" {}) path=\"${}\" ;;\n", root_pattern, word_var);
|
||||||
|
out += " esac\n";
|
||||||
|
out += " else\n";
|
||||||
|
out += " case \"$path\" in\n";
|
||||||
|
for (const auto *command : commands) {
|
||||||
|
if (command->subcommands.empty() || command->argv.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out += std::format(" \"{}\") case \"${}\" in {}) path=\"$path {}\" ;; esac ;;\n",
|
||||||
|
command_key(*command), word_var, case_pattern(child_names(*command)),
|
||||||
|
word_var);
|
||||||
|
}
|
||||||
|
out += " esac\n";
|
||||||
|
out += " fi\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string roff_escape(std::string_view text) {
|
||||||
|
std::string out;
|
||||||
|
for (const char c : text) {
|
||||||
|
if (c == '\\') {
|
||||||
|
out += "\\\\";
|
||||||
|
} else if (c == '-') {
|
||||||
|
out += "\\-";
|
||||||
|
} else {
|
||||||
|
out.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string roff_text(std::string_view text) {
|
||||||
|
std::string escaped = roff_escape(text);
|
||||||
|
if (!escaped.empty() && (escaped.front() == '.' || escaped.front() == '\'')) {
|
||||||
|
escaped.insert(escaped.begin(), '&');
|
||||||
|
}
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
void append_option_section(std::string &out, std::string_view title,
|
||||||
|
const std::vector<OptionSpec> &specs) {
|
||||||
|
if (specs.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out += std::format(".SH {}\n", title);
|
||||||
|
for (const auto &spec : specs) {
|
||||||
|
std::string names;
|
||||||
|
if (!spec.long_name.empty()) {
|
||||||
|
names += std::format("\\fB{}\\fR", roff_escape(spec.long_name));
|
||||||
|
}
|
||||||
|
if (!spec.short_name.empty()) {
|
||||||
|
if (!names.empty()) {
|
||||||
|
names += ", ";
|
||||||
|
}
|
||||||
|
names += std::format("\\fB{}\\fR", roff_escape(spec.short_name));
|
||||||
|
}
|
||||||
|
if (spec.takes_value) {
|
||||||
|
names += " \\fI<value>\\fR";
|
||||||
|
}
|
||||||
|
out += ".TP\n" + names + "\n" + roff_text(spec.description) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
std::vector<std::string> CommandSpec::words() const { return completion_words(*this); }
|
||||||
|
|
||||||
|
Void::Result::Result<CommandSpec, Void::Result::Error>
|
||||||
|
build_command_model(const std::filesystem::path &vbs_executable) {
|
||||||
|
CommandSpec root;
|
||||||
|
root.path = "vbs";
|
||||||
|
auto populated = populate(vbs_executable, root, 0);
|
||||||
|
if (!populated) {
|
||||||
|
return std::unexpected{populated.error()};
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<const CommandSpec *> flatten_commands(const CommandSpec &root) {
|
||||||
|
std::vector<const CommandSpec *> out;
|
||||||
|
out.push_back(&root);
|
||||||
|
for (const auto &child : root.subcommands) {
|
||||||
|
const auto nested = flatten_commands(child);
|
||||||
|
out.insert(out.end(), nested.begin(), nested.end());
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string render_bash_completion(const CommandSpec &root) {
|
||||||
|
const auto commands = flatten_commands(root);
|
||||||
|
std::string out = "# bash completion for vbs (generated by `vbs completions --shell bash`)\n";
|
||||||
|
out += "_vbs_complete() {\n";
|
||||||
|
out += " local cur path word i opts\n";
|
||||||
|
out += " COMPREPLY=()\n";
|
||||||
|
out += " cur=\"${COMP_WORDS[COMP_CWORD]}\"\n";
|
||||||
|
out += " path=\"\"\n";
|
||||||
|
out += " for ((i = 1; i < COMP_CWORD; i++)); do\n";
|
||||||
|
out += " word=\"${COMP_WORDS[i]}\"\n";
|
||||||
|
out += " [[ \"$word\" == -* ]] && continue\n";
|
||||||
|
out += render_path_walk(commands, "word");
|
||||||
|
out += " done\n";
|
||||||
|
out += " opts=\"\"\n";
|
||||||
|
out += " case \"$path\" in\n";
|
||||||
|
for (const auto *command : commands) {
|
||||||
|
out += std::format(" \"{}\") opts=\"{}\" ;;\n", command_key(*command),
|
||||||
|
join_words(completion_words(*command)));
|
||||||
|
}
|
||||||
|
out += " *) opts=\"\" ;;\n";
|
||||||
|
out += " esac\n";
|
||||||
|
out += " COMPREPLY=( $(compgen -W \"$opts\" -- \"$cur\") )\n";
|
||||||
|
out += " return 0\n";
|
||||||
|
out += "}\n";
|
||||||
|
out += "complete -F _vbs_complete vbs\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string render_zsh_completion(const CommandSpec &root) {
|
||||||
|
const auto commands = flatten_commands(root);
|
||||||
|
std::string out = "#compdef vbs\n";
|
||||||
|
out += "# zsh completion for vbs (generated by `vbs completions --shell zsh`)\n";
|
||||||
|
out += "_vbs_complete() {\n";
|
||||||
|
out += " local cur path word i\n";
|
||||||
|
out += " local -a opts\n";
|
||||||
|
out += " cur=\"${words[CURRENT]}\"\n";
|
||||||
|
out += " path=\"\"\n";
|
||||||
|
out += " for ((i = 2; i < CURRENT; i++)); do\n";
|
||||||
|
out += " word=\"${words[i]}\"\n";
|
||||||
|
out += " [[ \"$word\" == -* ]] && continue\n";
|
||||||
|
out += render_path_walk(commands, "word");
|
||||||
|
out += " done\n";
|
||||||
|
out += " case \"$path\" in\n";
|
||||||
|
for (const auto *command : commands) {
|
||||||
|
out += std::format(" \"{}\") opts=({}) ;;\n", command_key(*command),
|
||||||
|
join_words(completion_words(*command)));
|
||||||
|
}
|
||||||
|
out += " *) opts=() ;;\n";
|
||||||
|
out += " esac\n";
|
||||||
|
out += " compadd -- $opts\n";
|
||||||
|
out += "}\n";
|
||||||
|
out += "if [ \"$funcstack[1]\" = \"_vbs_complete\" ]; then\n";
|
||||||
|
out += " _vbs_complete \"$@\"\n";
|
||||||
|
out += "else\n";
|
||||||
|
out += " compdef _vbs_complete vbs\n";
|
||||||
|
out += "fi\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string render_fish_completion(const CommandSpec &root) {
|
||||||
|
const auto commands = flatten_commands(root);
|
||||||
|
std::string out = "# fish completion for vbs (generated by `vbs completions --shell fish`)\n";
|
||||||
|
out += "function __vbs_path\n";
|
||||||
|
out += " set -l tokens (commandline -opc)\n";
|
||||||
|
out += " set -l path \"\"\n";
|
||||||
|
out += " for word in $tokens[2..-1]\n";
|
||||||
|
out += " if string match -q -- '-*' $word\n";
|
||||||
|
out += " continue\n";
|
||||||
|
out += " end\n";
|
||||||
|
out += " if test -z \"$path\"\n";
|
||||||
|
out += " switch $word\n";
|
||||||
|
out += std::format(" case {}\n", case_pattern(child_names(root)));
|
||||||
|
out += " set path $word\n";
|
||||||
|
out += " end\n";
|
||||||
|
out += " else\n";
|
||||||
|
out += " switch $path\n";
|
||||||
|
for (const auto *command : commands) {
|
||||||
|
if (command->subcommands.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out += std::format(" case '{}'\n", command_key(*command));
|
||||||
|
out += " switch $word\n";
|
||||||
|
out += std::format(" case {}\n", case_pattern(child_names(*command)));
|
||||||
|
out += " set path \"$path $word\"\n";
|
||||||
|
out += " end\n";
|
||||||
|
}
|
||||||
|
out += " end\n";
|
||||||
|
out += " end\n";
|
||||||
|
out += " end\n";
|
||||||
|
out += " echo $path\n";
|
||||||
|
out += "end\n";
|
||||||
|
out += "complete -c vbs -f\n";
|
||||||
|
for (const auto *command : commands) {
|
||||||
|
out += std::format("complete -c vbs -n '__vbs_path = \"{}\"' -a '{}'\n",
|
||||||
|
command_key(*command), join_words(completion_words(*command)));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string man_page_name(const CommandSpec &command) {
|
||||||
|
std::string name = "vbs";
|
||||||
|
for (const auto &arg : command.argv) {
|
||||||
|
name += "-" + arg;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string render_man_page(const CommandSpec &command, std::string_view version) {
|
||||||
|
const std::string name = man_page_name(command);
|
||||||
|
const std::string summary =
|
||||||
|
command.description.empty() ? std::string{"VoidBuildSystem"} : command.description;
|
||||||
|
std::string out;
|
||||||
|
out += std::format(".TH {} 1 \"\" \"vbs {}\" \"VoidBuildSystem\"\n", roff_escape(name),
|
||||||
|
roff_escape(version));
|
||||||
|
out += ".SH NAME\n";
|
||||||
|
out += std::format("{} \\- {}\n", roff_escape(name), roff_text(summary));
|
||||||
|
out += ".SH SYNOPSIS\n";
|
||||||
|
out += std::format(".B {}\n{}\n", roff_escape(name), roff_text(command.usage));
|
||||||
|
if (!command.subcommands.empty()) {
|
||||||
|
out += ".SH COMMANDS\n";
|
||||||
|
for (const auto &child : command.subcommands) {
|
||||||
|
out += std::format(".TP\n\\fB{}\\fR\n{}\n", roff_escape(child.name),
|
||||||
|
roff_text(child.description));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
append_option_section(out, "FLAGS", command.flags);
|
||||||
|
append_option_section(out, "OPTIONS", command.options);
|
||||||
|
out += ".SH SEE ALSO\n";
|
||||||
|
out += ".BR vbs (1)\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Void::Build::Cli
|
||||||
@@ -333,6 +333,359 @@ import_cmake_lists(const std::filesystem::path &cmake_file,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Meson importer -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::string trim_copy(std::string_view s) {
|
||||||
|
const auto first = s.find_first_not_of(" \t\r\n");
|
||||||
|
if (first == std::string_view::npos) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const auto last = s.find_last_not_of(" \t\r\n");
|
||||||
|
return std::string{s.substr(first, last - first + 1)};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strips `#` comments outside string literals.
|
||||||
|
std::string strip_meson_comments(std::string_view text) {
|
||||||
|
std::string out;
|
||||||
|
bool quoted = false;
|
||||||
|
for (std::size_t i = 0; i < text.size(); ++i) {
|
||||||
|
const char c = text[i];
|
||||||
|
if (c == '\'') {
|
||||||
|
quoted = !quoted;
|
||||||
|
} else if (c == '#' && !quoted) {
|
||||||
|
while (i < text.size() && text[i] != '\n') {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if (i < text.size()) {
|
||||||
|
out.push_back('\n');
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push_back(c);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splits a Meson file into statements, joining lines while parentheses/brackets are open.
|
||||||
|
std::vector<std::string> split_meson_statements(std::string_view text) {
|
||||||
|
std::vector<std::string> statements;
|
||||||
|
std::string current;
|
||||||
|
int depth = 0;
|
||||||
|
bool quoted = false;
|
||||||
|
for (std::size_t i = 0; i < text.size(); ++i) {
|
||||||
|
const char c = text[i];
|
||||||
|
if (c == '\'') {
|
||||||
|
quoted = !quoted;
|
||||||
|
current.push_back(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!quoted) {
|
||||||
|
if (c == '(' || c == '[') {
|
||||||
|
++depth;
|
||||||
|
} else if (c == ')' || c == ']') {
|
||||||
|
--depth;
|
||||||
|
} else if (c == '\n' && depth == 0) {
|
||||||
|
if (!trim_copy(current).empty()) {
|
||||||
|
statements.push_back(trim_copy(current));
|
||||||
|
}
|
||||||
|
current.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current.push_back(c);
|
||||||
|
}
|
||||||
|
if (!trim_copy(current).empty()) {
|
||||||
|
statements.push_back(trim_copy(current));
|
||||||
|
}
|
||||||
|
return statements;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string trim_copy(std::string_view s);
|
||||||
|
|
||||||
|
// Splits on commas at depth 0 (outside strings and nested brackets).
|
||||||
|
std::vector<std::string> split_meson_args(std::string_view text) {
|
||||||
|
std::vector<std::string> args;
|
||||||
|
std::string current;
|
||||||
|
int depth = 0;
|
||||||
|
bool quoted = false;
|
||||||
|
for (std::size_t i = 0; i < text.size(); ++i) {
|
||||||
|
const char c = text[i];
|
||||||
|
if (c == '\'') {
|
||||||
|
quoted = !quoted;
|
||||||
|
current.push_back(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!quoted) {
|
||||||
|
if (c == '(' || c == '[') {
|
||||||
|
++depth;
|
||||||
|
} else if (c == ')' || c == ']') {
|
||||||
|
--depth;
|
||||||
|
} else if (c == ',' && depth == 0) {
|
||||||
|
args.push_back(trim_copy(current));
|
||||||
|
current.clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current.push_back(c);
|
||||||
|
}
|
||||||
|
if (!trim_copy(current).empty()) {
|
||||||
|
args.push_back(trim_copy(current));
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MesonValue {
|
||||||
|
std::vector<std::string> items; // String values or string lists collapsed.
|
||||||
|
bool is_list{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Evaluates a bounded Meson expression: string literals, lists, identifiers of known variables,
|
||||||
|
// and files(...) calls.
|
||||||
|
MesonValue eval_meson_value(std::string_view expr,
|
||||||
|
const std::map<std::string, MesonValue, std::less<>> &variables);
|
||||||
|
|
||||||
|
MesonValue eval_meson_value(std::string_view expr,
|
||||||
|
const std::map<std::string, MesonValue, std::less<>> &variables) {
|
||||||
|
const std::string text = trim_copy(expr);
|
||||||
|
if (text.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (text.front() == '[' && text.back() == ']') {
|
||||||
|
MesonValue value;
|
||||||
|
value.is_list = true;
|
||||||
|
for (const auto &item : split_meson_args(std::string_view{text}.substr(1, text.size() - 2))) {
|
||||||
|
for (const auto &entry : eval_meson_value(item, variables).items) {
|
||||||
|
value.items.push_back(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if (text.front() == '\'') {
|
||||||
|
// One or more concatenated string literals.
|
||||||
|
MesonValue value;
|
||||||
|
std::string current;
|
||||||
|
bool quoted = false;
|
||||||
|
for (std::size_t i = 0; i < text.size(); ++i) {
|
||||||
|
const char c = text[i];
|
||||||
|
if (c == '\'') {
|
||||||
|
if (quoted) {
|
||||||
|
value.items.push_back(current);
|
||||||
|
current.clear();
|
||||||
|
}
|
||||||
|
quoted = !quoted;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (quoted) {
|
||||||
|
current.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
const auto paren = text.find('(');
|
||||||
|
if (paren != std::string::npos && text.back() == ')') {
|
||||||
|
const std::string call = trim_copy(std::string_view{text}.substr(0, paren));
|
||||||
|
if (call == "files" || call == "include_directories" || call == "dependency") {
|
||||||
|
MesonValue value;
|
||||||
|
value.is_list = true;
|
||||||
|
for (const auto &arg :
|
||||||
|
split_meson_args(std::string_view{text}.substr(paren + 1, text.size() - paren - 2))) {
|
||||||
|
for (const auto &entry : eval_meson_value(arg, variables).items) {
|
||||||
|
value.items.push_back(entry);
|
||||||
|
}
|
||||||
|
if (call == "dependency") {
|
||||||
|
break; // dependency('name', version : ...) -> just the name.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
// Other calls (dependency, declare_dependency, ...) are not values the importer uses.
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
if (const auto it = variables.find(text); it != variables.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Void::Result::Result<MigrationResult, Void::Result::Error>
|
||||||
|
import_meson_build(const std::filesystem::path &meson_file,
|
||||||
|
const std::filesystem::path &project_root) {
|
||||||
|
auto text = Void::FileSystem::read_file(meson_file);
|
||||||
|
if (!text) {
|
||||||
|
return std::unexpected{text.error()};
|
||||||
|
}
|
||||||
|
|
||||||
|
MigrationResult result;
|
||||||
|
std::map<std::string, MesonValue, std::less<>> variables;
|
||||||
|
|
||||||
|
for (const auto &statement : split_meson_statements(strip_meson_comments(*text))) {
|
||||||
|
// Variable assignment: `name = expr` (first '=' at depth 0, not '==' or inside a call).
|
||||||
|
int depth = 0;
|
||||||
|
bool quoted = false;
|
||||||
|
std::size_t assign = std::string::npos;
|
||||||
|
for (std::size_t i = 0; i < statement.size(); ++i) {
|
||||||
|
const char c = statement[i];
|
||||||
|
if (c == '\'') {
|
||||||
|
quoted = !quoted;
|
||||||
|
} else if (!quoted) {
|
||||||
|
if (c == '(' || c == '[') {
|
||||||
|
++depth;
|
||||||
|
} else if (c == ')' || c == ']') {
|
||||||
|
--depth;
|
||||||
|
} else if (c == '=' && depth == 0) {
|
||||||
|
assign = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string effective = statement;
|
||||||
|
std::string assigned_name;
|
||||||
|
if (assign != std::string::npos) {
|
||||||
|
const std::string name = trim_copy(std::string_view{statement}.substr(0, assign));
|
||||||
|
const std::string expr = trim_copy(std::string_view{statement}.substr(assign + 1));
|
||||||
|
// `lib = static_library(...)` declares a target and binds the variable to it.
|
||||||
|
static constexpr std::string_view kTargetCalls[] = {
|
||||||
|
"executable", "static_library", "shared_library", "library", "both_libraries"};
|
||||||
|
const bool declares_target = std::ranges::any_of(kTargetCalls, [&](std::string_view call) {
|
||||||
|
return expr.starts_with(std::string{call} + "(");
|
||||||
|
});
|
||||||
|
if (!declares_target) {
|
||||||
|
variables[name] = eval_meson_value(expr, variables);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assigned_name = name;
|
||||||
|
effective = expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto paren = effective.find('(');
|
||||||
|
if (paren == std::string::npos || effective.back() != ')') {
|
||||||
|
result.notes.push_back("unsupported meson statement '" + effective + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const std::string call = trim_copy(std::string_view{effective}.substr(0, paren));
|
||||||
|
const auto args = split_meson_args(
|
||||||
|
std::string_view{effective}.substr(paren + 1, effective.size() - paren - 2));
|
||||||
|
|
||||||
|
if (call == "project") {
|
||||||
|
if (!args.empty()) {
|
||||||
|
const auto name_value = eval_meson_value(args[0], variables);
|
||||||
|
result.project_name =
|
||||||
|
name_value.items.empty() ? args[0] : name_value.items.front();
|
||||||
|
}
|
||||||
|
for (std::size_t i = 1; i < args.size(); ++i) {
|
||||||
|
if (args[i].find(':') != std::string::npos) {
|
||||||
|
continue; // Keyword like version : '1.0'.
|
||||||
|
}
|
||||||
|
if (trim_copy(args[i]) != "'cpp'" && trim_copy(args[i]) != "'c'") {
|
||||||
|
result.notes.push_back("project language " + args[i] + " is not C/C++");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool is_target = call == "executable" || call == "static_library" ||
|
||||||
|
call == "shared_library" || call == "library" ||
|
||||||
|
call == "both_libraries" || call == "test";
|
||||||
|
if (!is_target) {
|
||||||
|
if (call == "subdir" || call == "dependency" || call == "find_program" ||
|
||||||
|
call == "custom_target" || call == "configure_file" || call == "run_command" ||
|
||||||
|
call == "install_headers" || call == "install_subdir" || call == "summary" ||
|
||||||
|
call == "add_test" || call == "add_project_arguments" ||
|
||||||
|
call == "add_project_link_arguments" || call == "pkg_modversion" ||
|
||||||
|
call == "vcs_tag" || call == "generator" || call == "declare_dependency" ||
|
||||||
|
call == "message" || call == "warning" || call == "import" ||
|
||||||
|
call == "include_directories" || call == "files") {
|
||||||
|
if (call == "subdir" || call == "dependency" || call == "custom_target" ||
|
||||||
|
call == "configure_file" || call == "run_command" || call == "import" ||
|
||||||
|
call == "generator" || call == "declare_dependency") {
|
||||||
|
result.notes.push_back(call + "(...) requires manual review");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.notes.push_back("unsupported meson function '" + call + "'");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MigratedTarget target;
|
||||||
|
const auto name_value = eval_meson_value(args[0], variables);
|
||||||
|
target.name = name_value.items.empty() ? args[0] : name_value.items[0];
|
||||||
|
if (call == "executable" || call == "test") {
|
||||||
|
target.kind = "executable";
|
||||||
|
} else if (call == "shared_library" || call == "both_libraries") {
|
||||||
|
target.kind = "shared";
|
||||||
|
} else if (call == "library") {
|
||||||
|
target.kind = "static";
|
||||||
|
result.notes.push_back("library() builds shared and static; imported as static");
|
||||||
|
} else {
|
||||||
|
target.kind = "static";
|
||||||
|
}
|
||||||
|
for (std::size_t i = 1; i < args.size(); ++i) {
|
||||||
|
const std::string arg = trim_copy(args[i]);
|
||||||
|
const auto colon = arg.find(':');
|
||||||
|
std::string key;
|
||||||
|
std::string value_expr = arg;
|
||||||
|
if (colon != std::string::npos) {
|
||||||
|
key = trim_copy(std::string_view{arg}.substr(0, colon));
|
||||||
|
value_expr = trim_copy(std::string_view{arg}.substr(colon + 1));
|
||||||
|
}
|
||||||
|
const auto value = eval_meson_value(value_expr, variables);
|
||||||
|
if (key.empty()) {
|
||||||
|
for (const auto &item : value.items) {
|
||||||
|
if (is_source_like(item)) {
|
||||||
|
target.sources.push_back(item);
|
||||||
|
} else {
|
||||||
|
result.notes.push_back(std::format("{} '{}': ignored non-source token '{}'",
|
||||||
|
call, target.name, item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (key == "link_with" || key == "link_whole") {
|
||||||
|
for (const auto &item : value.items) {
|
||||||
|
target.private_links.push_back(item);
|
||||||
|
}
|
||||||
|
} else if (key == "include_directories") {
|
||||||
|
for (const auto &item : value.items) {
|
||||||
|
target.private_includes.push_back(item);
|
||||||
|
}
|
||||||
|
} else if (key == "dependencies") {
|
||||||
|
for (const auto &item : value.items) {
|
||||||
|
result.notes.push_back("dependency '" + item +
|
||||||
|
"' requires .pkgconfig() or a registry entry");
|
||||||
|
}
|
||||||
|
} else if (key == "install") {
|
||||||
|
target.installed = value.items.empty() || value.items.front() != "false";
|
||||||
|
} else if (key == "install_dir") {
|
||||||
|
if (!value.items.empty()) {
|
||||||
|
target.install_destination = value.items.front();
|
||||||
|
}
|
||||||
|
target.installed = true;
|
||||||
|
} else {
|
||||||
|
result.notes.push_back(std::format("{} '{}': keyword '{}' is not translated", call,
|
||||||
|
target.name, key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.installed && target.install_destination.empty()) {
|
||||||
|
target.install_destination =
|
||||||
|
target.kind == "executable" ? "bin" : (target.kind == "interface" ? "include" : "lib");
|
||||||
|
}
|
||||||
|
if (!assigned_name.empty()) {
|
||||||
|
variables[assigned_name] = MesonValue{{target.name}, false};
|
||||||
|
}
|
||||||
|
result.targets.push_back(std::move(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.project_name.empty()) {
|
||||||
|
result.project_name = project_root.filename().string();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::string render_build_cpp(const MigrationResult &result) {
|
std::string render_build_cpp(const MigrationResult &result) {
|
||||||
using Util::json_quote;
|
using Util::json_quote;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||||
#include <Void/Build/Util/Json.hpp>
|
#include <Void/Build/Util/Json.hpp>
|
||||||
#include <Void/Build/Util/Sha256.hpp>
|
#include <Void/Build/Util/Sha256.hpp>
|
||||||
|
#include <Void/Build/Util/UserCache.hpp>
|
||||||
|
#include <Void/Log/Log.hpp>
|
||||||
#include <Void/Data/StrictJson.hpp>
|
#include <Void/Data/StrictJson.hpp>
|
||||||
#include <Void/System/Path.hpp>
|
#include <Void/System/Path.hpp>
|
||||||
#include <Void/System/Types.hpp>
|
#include <Void/System/Types.hpp>
|
||||||
@@ -561,6 +563,30 @@ compile_descriptor(const FrontendOptions &options) {
|
|||||||
const auto exe_path = config_dir / ("descriptor_" + seed_id.substr(0, 16));
|
const auto exe_path = config_dir / ("descriptor_" + seed_id.substr(0, 16));
|
||||||
const auto meta_path = config_dir / ("descriptor_" + seed_id.substr(0, 16) + ".headers.json");
|
const auto meta_path = config_dir / ("descriptor_" + seed_id.substr(0, 16) + ".headers.json");
|
||||||
|
|
||||||
|
// A fresh build directory can reuse a descriptor compiled for the same seed identity from
|
||||||
|
// the shared per-user cache: the identity covers the host compiler, the SDK, the generated
|
||||||
|
// driver source and every configuration source (path + content), and the discovered headers
|
||||||
|
// are re-verified below either way.
|
||||||
|
if (const auto shared_dir = Util::user_cache_dir("descriptors")) {
|
||||||
|
std::error_code shared_ec;
|
||||||
|
const bool local_missing = !std::filesystem::is_regular_file(exe_path, shared_ec) ||
|
||||||
|
!std::filesystem::is_regular_file(meta_path, shared_ec);
|
||||||
|
const auto shared_exe = *shared_dir / exe_path.filename();
|
||||||
|
const auto shared_meta = *shared_dir / meta_path.filename();
|
||||||
|
if (local_missing && std::filesystem::is_regular_file(shared_exe, shared_ec) &&
|
||||||
|
std::filesystem::is_regular_file(shared_meta, shared_ec)) {
|
||||||
|
std::filesystem::copy_file(shared_exe, exe_path,
|
||||||
|
std::filesystem::copy_options::overwrite_existing,
|
||||||
|
shared_ec);
|
||||||
|
std::filesystem::copy_file(shared_meta, meta_path,
|
||||||
|
std::filesystem::copy_options::overwrite_existing,
|
||||||
|
shared_ec);
|
||||||
|
if (!shared_ec) {
|
||||||
|
Void::Log::debug("Config", "descriptor artifact reused from the shared cache");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if cached descriptor executable exists AND all previously discovered headers match!
|
// Check if cached descriptor executable exists AND all previously discovered headers match!
|
||||||
// Header entries carry a stat fingerprint (size + mtime) beside the SHA-256: when the
|
// Header entries carry a stat fingerprint (size + mtime) beside the SHA-256: when the
|
||||||
// fingerprint is unchanged the content hash is trusted and no file is read. Legacy entries
|
// fingerprint is unchanged the content hash is trusted and no file is read. Legacy entries
|
||||||
@@ -687,6 +713,9 @@ compile_descriptor(const FrontendOptions &options) {
|
|||||||
Platform::ProcessRequest req;
|
Platform::ProcessRequest req;
|
||||||
req.executable = host_cxx;
|
req.executable = host_cxx;
|
||||||
req.arguments = {"-std=c++26", "-O1", "-I", canonical_root.string()};
|
req.arguments = {"-std=c++26", "-O1", "-I", canonical_root.string()};
|
||||||
|
for (const auto &flag : options.host_compile_flags) {
|
||||||
|
req.arguments.push_back(flag);
|
||||||
|
}
|
||||||
if (!options.sdk_include_dir.empty()) {
|
if (!options.sdk_include_dir.empty()) {
|
||||||
req.arguments.push_back("-I");
|
req.arguments.push_back("-I");
|
||||||
req.arguments.push_back(options.sdk_include_dir.string());
|
req.arguments.push_back(options.sdk_include_dir.string());
|
||||||
@@ -736,9 +765,15 @@ compile_descriptor(const FrontendOptions &options) {
|
|||||||
Platform::ProcessRequest req;
|
Platform::ProcessRequest req;
|
||||||
req.executable = host_cxx;
|
req.executable = host_cxx;
|
||||||
req.arguments = {"-std=c++26", "-o", staged_exe.string()};
|
req.arguments = {"-std=c++26", "-o", staged_exe.string()};
|
||||||
|
for (const auto &flag : options.host_compile_flags) {
|
||||||
|
req.arguments.push_back(flag);
|
||||||
|
}
|
||||||
for (const auto &o : objects) {
|
for (const auto &o : objects) {
|
||||||
req.arguments.push_back(o.string());
|
req.arguments.push_back(o.string());
|
||||||
}
|
}
|
||||||
|
for (const auto &flag : options.host_link_flags) {
|
||||||
|
req.arguments.push_back(flag);
|
||||||
|
}
|
||||||
if (use_prebuilt_sdk) {
|
if (use_prebuilt_sdk) {
|
||||||
req.arguments.push_back(options.sdk_library_path.string());
|
req.arguments.push_back(options.sdk_library_path.string());
|
||||||
}
|
}
|
||||||
@@ -772,6 +807,15 @@ compile_descriptor(const FrontendOptions &options) {
|
|||||||
}
|
}
|
||||||
write_meta(persisted_headers);
|
write_meta(persisted_headers);
|
||||||
|
|
||||||
|
// Publish the freshly compiled descriptor to the shared per-user cache (best effort).
|
||||||
|
if (const auto shared_dir = Util::user_cache_dir("descriptors")) {
|
||||||
|
std::error_code shared_ec;
|
||||||
|
std::filesystem::copy_file(exe_path, *shared_dir / exe_path.filename(),
|
||||||
|
std::filesystem::copy_options::overwrite_existing, shared_ec);
|
||||||
|
std::filesystem::copy_file(meta_path, *shared_dir / meta_path.filename(),
|
||||||
|
std::filesystem::copy_options::overwrite_existing, shared_ec);
|
||||||
|
}
|
||||||
|
|
||||||
CompiledDescriptor desc;
|
CompiledDescriptor desc;
|
||||||
desc.executable_path = exe_path;
|
desc.executable_path = exe_path;
|
||||||
desc.seed_identity_hash = seed_id;
|
desc.seed_identity_hash = seed_id;
|
||||||
|
|||||||
+36
-9
@@ -20,6 +20,17 @@ Error make_error(Void::System::SystemErrorCode code, std::string message) {
|
|||||||
|
|
||||||
Result<ScaffoldReport, Error> scaffold_project(const ScaffoldOptions &options) {
|
Result<ScaffoldReport, Error> scaffold_project(const ScaffoldOptions &options) {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
const std::string &shape = options.template_name;
|
||||||
|
if (shape != "app" && shape != "library" && shape != "header-only" && shape != "shared") {
|
||||||
|
return std::unexpected{make_error(
|
||||||
|
Void::System::SystemErrorCode::invalid_argument,
|
||||||
|
std::format("vbs init: unknown template '{}' (expected app, library, header-only "
|
||||||
|
"or shared)",
|
||||||
|
shape))};
|
||||||
|
}
|
||||||
|
const bool header_only = shape == "header-only";
|
||||||
|
const bool library_shape = options.library || shape == "library" || header_only;
|
||||||
|
const bool shared = shape == "shared";
|
||||||
const std::filesystem::path target_dir = options.target_dir.lexically_normal();
|
const std::filesystem::path target_dir = options.target_dir.lexically_normal();
|
||||||
std::filesystem::create_directories(target_dir, ec);
|
std::filesystem::create_directories(target_dir, ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
@@ -77,7 +88,17 @@ Result<ScaffoldReport, Error> scaffold_project(const ScaffoldOptions &options) {
|
|||||||
if (options.with_toml) {
|
if (options.with_toml) {
|
||||||
build_src += " project.dependencies_file(\"vbs.deps.toml\");\n\n";
|
build_src += " project.dependencies_file(\"vbs.deps.toml\");\n\n";
|
||||||
}
|
}
|
||||||
if (options.library) {
|
if (header_only) {
|
||||||
|
build_src += " auto lib = project.header_only_library(\"" + raw_name +
|
||||||
|
"\");\n"
|
||||||
|
" lib.include_directory(\"include\", Void::Build::Visibility::Public);\n\n"
|
||||||
|
" auto t = project.test(\"" +
|
||||||
|
ident +
|
||||||
|
"_tests\");\n"
|
||||||
|
" t.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
||||||
|
" .sources({\"tests/test_main.cpp\"})\n"
|
||||||
|
" .link(lib);\n";
|
||||||
|
} else if (library_shape) {
|
||||||
build_src += " auto lib = project.static_library(\"" + raw_name +
|
build_src += " auto lib = project.static_library(\"" + raw_name +
|
||||||
"\");\n"
|
"\");\n"
|
||||||
" lib.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
" lib.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
||||||
@@ -94,7 +115,8 @@ Result<ScaffoldReport, Error> scaffold_project(const ScaffoldOptions &options) {
|
|||||||
" .sources({\"tests/test_main.cpp\"})\n"
|
" .sources({\"tests/test_main.cpp\"})\n"
|
||||||
" .link(lib);\n";
|
" .link(lib);\n";
|
||||||
} else {
|
} else {
|
||||||
build_src += " auto lib = project.static_library(\"" + ident +
|
const std::string lib_factory = shared ? "shared_library" : "static_library";
|
||||||
|
build_src += " auto lib = project." + lib_factory + "(\"" + ident +
|
||||||
"_lib\");\n"
|
"_lib\");\n"
|
||||||
" lib.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
" lib.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
||||||
" .sources({\"src/" +
|
" .sources({\"src/" +
|
||||||
@@ -122,17 +144,22 @@ Result<ScaffoldReport, Error> scaffold_project(const ScaffoldOptions &options) {
|
|||||||
}
|
}
|
||||||
if (auto written =
|
if (auto written =
|
||||||
write_checked(target_dir / "include" / (ident + ".hpp"),
|
write_checked(target_dir / "include" / (ident + ".hpp"),
|
||||||
"#pragma once\n\nnamespace " + ident + " {\nint answer();\n}\n");
|
header_only ? "#pragma once\n\nnamespace " + ident +
|
||||||
|
" {\ninline int answer() { return 42; }\n}\n"
|
||||||
|
: "#pragma once\n\nnamespace " + ident +
|
||||||
|
" {\nint answer();\n}\n");
|
||||||
!written) {
|
!written) {
|
||||||
return std::unexpected{written.error()};
|
return std::unexpected{written.error()};
|
||||||
}
|
}
|
||||||
if (auto written = write_checked(target_dir / "src" / (ident + ".cpp"),
|
if (!header_only) {
|
||||||
"#include \"" + ident + ".hpp\"\n\nnamespace " + ident +
|
if (auto written = write_checked(target_dir / "src" / (ident + ".cpp"),
|
||||||
" {\nint answer() { return 42; }\n}\n");
|
"#include \"" + ident + ".hpp\"\n\nnamespace " + ident +
|
||||||
!written) {
|
" {\nint answer() { return 42; }\n}\n");
|
||||||
return std::unexpected{written.error()};
|
!written) {
|
||||||
|
return std::unexpected{written.error()};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!options.library) {
|
if (!library_shape) {
|
||||||
if (auto written = write_checked(target_dir / "src" / "main.cpp",
|
if (auto written = write_checked(target_dir / "src" / "main.cpp",
|
||||||
"#include \"" + ident +
|
"#include \"" + ident +
|
||||||
".hpp\"\n#include <iostream>\n\nint main() {\n"
|
".hpp\"\n#include <iostream>\n\nint main() {\n"
|
||||||
|
|||||||
@@ -1067,6 +1067,43 @@ generate_ide_configs(const Graph::BuildGraph &graph, const IdeConfigOptions &opt
|
|||||||
if (auto r = write_ide_file(proj_root / ".idea" / "customTargets.xml", xml); !r) {
|
if (auto r = write_ide_file(proj_root / ".idea" / "customTargets.xml", xml); !r) {
|
||||||
return std::unexpected{r.error()};
|
return std::unexpected{r.error()};
|
||||||
}
|
}
|
||||||
|
// JetBrains run configurations per target (shell-script configs, portable across hosts).
|
||||||
|
const auto shell_config = [&](const std::string &name, const std::string &script) {
|
||||||
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
"<component name=\"ProjectRunConfigurationManager\">\n"
|
||||||
|
" <configuration default=\"false\" name=\"" +
|
||||||
|
escape_xml_attr(name) +
|
||||||
|
"\" type=\"ShConfigurationType\">\n"
|
||||||
|
" <option name=\"SCRIPT_TEXT\" value=\"" +
|
||||||
|
escape_xml_attr(script) +
|
||||||
|
"\" />\n"
|
||||||
|
" <option name=\"INDEPENDENT_SCRIPT_PATH\" value=\"true\" />\n"
|
||||||
|
" <option name=\"SCRIPT_WORKING_DIRECTORY\" value=\"$PROJECT_DIR$\" />\n"
|
||||||
|
" <option name=\"INDEPENDENT_SCRIPT_WORKING_DIRECTORY\" value=\"true\" />\n"
|
||||||
|
" <method v=\"2\" />\n"
|
||||||
|
" </configuration>\n"
|
||||||
|
"</component>\n";
|
||||||
|
};
|
||||||
|
std::size_t run_configs = 0;
|
||||||
|
for (const auto &target : graph.targets) {
|
||||||
|
if (run_configs >= 128) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const bool is_test = target.kind == TargetKind::Test;
|
||||||
|
if (!is_test && target.kind != TargetKind::Executable) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const std::string script = is_test
|
||||||
|
? "vbs test --target " + target.name
|
||||||
|
: "vbs build --target " + target.name;
|
||||||
|
const auto file = proj_root / ".idea" / "runConfigurations" /
|
||||||
|
(std::string{is_test ? "vbs_test_" : "vbs_build_"} + target.name +
|
||||||
|
".xml");
|
||||||
|
if (auto r = write_ide_file(file, shell_config(script, script)); !r) {
|
||||||
|
return std::unexpected{r.error()};
|
||||||
|
}
|
||||||
|
++run_configs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
|
|||||||
+127
-2
@@ -130,8 +130,7 @@ bool restore_outputs_from_cache(const Graph::ActionNode &action,
|
|||||||
|
|
||||||
// Build-path-independent path mapping used for shared remote cache keys and records.
|
// Build-path-independent path mapping used for shared remote cache keys and records.
|
||||||
// Longest prefix wins so nested build/root prefixes are replaced before their parents.
|
// Longest prefix wins so nested build/root prefixes are replaced before their parents.
|
||||||
struct PathMapper {
|
struct PathMapper { std::vector<std::pair<std::string, std::string>> pairs;
|
||||||
std::vector<std::pair<std::string, std::string>> pairs;
|
|
||||||
|
|
||||||
[[nodiscard]] std::string normalize(std::string_view input) const {
|
[[nodiscard]] std::string normalize(std::string_view input) const {
|
||||||
std::string out{input};
|
std::string out{input};
|
||||||
@@ -954,4 +953,130 @@ execute_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
|||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Void::Result::Result<ExplainReport, Void::Result::Error>
|
||||||
|
explain_graph(const Graph::BuildGraph &graph, State::StateStore &state,
|
||||||
|
const ExecutionOptions &options) {
|
||||||
|
auto selected_indices_res = graph.select_action_closure(options.selected_targets);
|
||||||
|
if (!selected_indices_res) {
|
||||||
|
return std::unexpected{selected_indices_res.error()};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto label_for = [&](const Graph::ActionNode &act) -> std::string {
|
||||||
|
const auto rel_name = [&](const std::filesystem::path &p) -> std::string {
|
||||||
|
if (p.empty()) {
|
||||||
|
return act.target_name;
|
||||||
|
}
|
||||||
|
if (!graph.project_root.empty() && Platform::path_is_within(graph.project_root, p)) {
|
||||||
|
return p.lexically_relative(graph.project_root).generic_string();
|
||||||
|
}
|
||||||
|
return p.filename().string();
|
||||||
|
};
|
||||||
|
switch (act.kind) {
|
||||||
|
case Graph::ActionKind::Compile:
|
||||||
|
return std::format("Compile {}", rel_name(!act.logical_source_file.empty()
|
||||||
|
? act.logical_source_file
|
||||||
|
: act.logical_output_file));
|
||||||
|
case Graph::ActionKind::PrecompiledHeader:
|
||||||
|
return std::format("PCH {}", rel_name(act.logical_source_file));
|
||||||
|
case Graph::ActionKind::HeaderUnit:
|
||||||
|
return std::format("HdrUnit {}", rel_name(act.logical_source_file));
|
||||||
|
case Graph::ActionKind::ModuleScan:
|
||||||
|
return std::format("ModScan {}", rel_name(act.logical_source_file));
|
||||||
|
case Graph::ActionKind::ModuleBmi:
|
||||||
|
return std::format("BMI {}", rel_name(act.logical_source_file));
|
||||||
|
case Graph::ActionKind::Archive:
|
||||||
|
return std::format("Archive {}", rel_name(act.logical_output_file));
|
||||||
|
case Graph::ActionKind::Link:
|
||||||
|
return std::format("Link {}", rel_name(act.logical_output_file));
|
||||||
|
case Graph::ActionKind::Custom:
|
||||||
|
return std::format("Action {}", act.target_name);
|
||||||
|
}
|
||||||
|
return act.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
ExplainReport report;
|
||||||
|
RunDigestCache digest_cache;
|
||||||
|
const PathMapper path_mapper = make_path_mapper(graph);
|
||||||
|
|
||||||
|
for (const std::size_t idx : *selected_indices_res) {
|
||||||
|
const auto &act = graph.actions[idx];
|
||||||
|
ActionExplanation ex;
|
||||||
|
ex.action_id = act.id;
|
||||||
|
ex.target_name = act.target_name;
|
||||||
|
ex.label = label_for(act);
|
||||||
|
ex.cacheable = act.cacheable && !act.nondeterministic;
|
||||||
|
ex.action_key = compute_effective_action_key(act, digest_cache);
|
||||||
|
ex.command = act.executable.string();
|
||||||
|
for (const auto &arg : act.arguments) {
|
||||||
|
ex.command += ' ';
|
||||||
|
ex.command += arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ex.cacheable) {
|
||||||
|
ex.would_run = true;
|
||||||
|
ex.reason = act.nondeterministic ? "nondeterministic action (never cached)"
|
||||||
|
: "action is not cacheable";
|
||||||
|
} else {
|
||||||
|
auto cached = state.lookup_action(ex.action_key);
|
||||||
|
if (!cached) {
|
||||||
|
return std::unexpected{cached.error()};
|
||||||
|
}
|
||||||
|
if (!cached->has_value()) {
|
||||||
|
ex.would_run = true;
|
||||||
|
ex.reason = "no cached result for this action key";
|
||||||
|
if (state.has_remote_cache()) {
|
||||||
|
const std::string remote_key =
|
||||||
|
compute_remote_action_key(act, graph, digest_cache, path_mapper);
|
||||||
|
auto remote = state.fetch_remote_action(remote_key);
|
||||||
|
if (remote && remote->has_value()) {
|
||||||
|
ex.remote_hit = true;
|
||||||
|
ex.reason += " (available in the shared remote cache)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const auto &rec = **cached;
|
||||||
|
for (const auto &[path_str, expected_sha] : rec.discovered_inputs) {
|
||||||
|
const auto actual = digest_cache.hash_file(std::filesystem::path{path_str});
|
||||||
|
if (!actual) {
|
||||||
|
ex.changed_inputs.push_back(path_str + " (missing)");
|
||||||
|
} else if (*actual != expected_sha) {
|
||||||
|
ex.changed_inputs.push_back(path_str + " (modified)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &out : act.declared_outputs) {
|
||||||
|
const auto it = rec.outputs.find(out.string());
|
||||||
|
if (it == rec.outputs.end()) {
|
||||||
|
ex.changed_outputs.push_back(out.string() + " (not recorded)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto actual = digest_cache.hash_file(out);
|
||||||
|
if (!actual) {
|
||||||
|
ex.changed_outputs.push_back(out.string() + " (missing)");
|
||||||
|
} else if (*actual != it->second.sha256) {
|
||||||
|
ex.changed_outputs.push_back(out.string() + " (modified)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ex.changed_inputs.empty()) {
|
||||||
|
ex.would_run = true;
|
||||||
|
ex.reason = "inputs changed";
|
||||||
|
} else if (!ex.changed_outputs.empty()) {
|
||||||
|
ex.restorable = true;
|
||||||
|
ex.reason = "outputs changed or missing (restorable from the cache)";
|
||||||
|
} else {
|
||||||
|
ex.reason = "up to date";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.would_run) {
|
||||||
|
++report.would_run;
|
||||||
|
} else {
|
||||||
|
++report.up_to_date;
|
||||||
|
}
|
||||||
|
report.actions.push_back(std::move(ex));
|
||||||
|
}
|
||||||
|
report.total = report.actions.size();
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Void::Build::Execution
|
} // namespace Void::Build::Execution
|
||||||
+631
-43
@@ -1,6 +1,7 @@
|
|||||||
#include <Void/Build.hpp>
|
#include <Void/Build.hpp>
|
||||||
#include <Void/Build/BootstrapConfig.hpp>
|
#include <Void/Build/BootstrapConfig.hpp>
|
||||||
#include <Void/Build/Bridge/CMakeBridge.hpp>
|
#include <Void/Build/Bridge/CMakeBridge.hpp>
|
||||||
|
#include <Void/Build/Cli/CommandModel.hpp>
|
||||||
#include <Void/Build/Config/BuildTree.hpp>
|
#include <Void/Build/Config/BuildTree.hpp>
|
||||||
#include <Void/Build/Config/CmakeImport.hpp>
|
#include <Void/Build/Config/CmakeImport.hpp>
|
||||||
#include <Void/Build/Config/Frontend.hpp>
|
#include <Void/Build/Config/Frontend.hpp>
|
||||||
@@ -68,8 +69,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <numeric>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <random>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stop_token>
|
#include <stop_token>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -187,9 +190,30 @@ make_frontend_opts(const std::filesystem::path &project_root,
|
|||||||
const std::vector<std::filesystem::path> &extra_sources) {
|
const std::vector<std::filesystem::path> &extra_sources) {
|
||||||
Config::FrontendOptions opts;
|
Config::FrontendOptions opts;
|
||||||
opts.project_root = project_root;
|
opts.project_root = project_root;
|
||||||
opts.build_root = build_root;
|
opts.build_root = build_root; opts.sdk_include_dir = std::filesystem::path{Bootstrap::sdk_include_dir};
|
||||||
opts.sdk_include_dir = std::filesystem::path{Bootstrap::sdk_include_dir};
|
|
||||||
opts.sdk_source_dir = std::filesystem::path{Bootstrap::sdk_source_dir};
|
opts.sdk_source_dir = std::filesystem::path{Bootstrap::sdk_source_dir};
|
||||||
|
// Instrument the descriptor too when the invoker is building with sanitizers: the flags
|
||||||
|
// the project is built with are not otherwise visible to the descriptor compilation.
|
||||||
|
const auto split_flags = [](const std::string &text) {
|
||||||
|
std::vector<std::string> flags;
|
||||||
|
std::size_t pos = 0;
|
||||||
|
while (pos < text.size()) {
|
||||||
|
while (pos < text.size() && std::isspace(static_cast<unsigned char>(text[pos])) != 0) {
|
||||||
|
++pos;
|
||||||
|
}
|
||||||
|
const auto start = pos;
|
||||||
|
while (pos < text.size() && std::isspace(static_cast<unsigned char>(text[pos])) == 0) {
|
||||||
|
++pos;
|
||||||
|
}
|
||||||
|
if (pos > start) {
|
||||||
|
flags.emplace_back(text.substr(start, pos - start));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
};
|
||||||
|
opts.host_compile_flags =
|
||||||
|
split_flags(Void::Configuration::get_env_or("VBS_HOST_CXX_FLAGS", ""));
|
||||||
|
opts.host_link_flags = split_flags(Void::Configuration::get_env_or("VBS_HOST_LDFLAGS", ""));
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::vector<std::filesystem::path> sdk_candidates;
|
std::vector<std::filesystem::path> sdk_candidates;
|
||||||
if (const auto self_exe = Platform::current_executable_path(); self_exe) {
|
if (const auto self_exe = Platform::current_executable_path(); self_exe) {
|
||||||
@@ -381,7 +405,9 @@ struct TestRunRecord {
|
|||||||
std::string profile;
|
std::string profile;
|
||||||
std::string name;
|
std::string name;
|
||||||
bool passed{false};
|
bool passed{false};
|
||||||
|
bool timed_out{false};
|
||||||
int exit_code{-1};
|
int exit_code{-1};
|
||||||
|
int attempts{1};
|
||||||
double elapsed_ms{0};
|
double elapsed_ms{0};
|
||||||
std::string output;
|
std::string output;
|
||||||
};
|
};
|
||||||
@@ -415,6 +441,14 @@ struct BuildCmdOptions {
|
|||||||
std::optional<std::string> cdash_build_arg;
|
std::optional<std::string> cdash_build_arg;
|
||||||
std::optional<std::string> cdash_output_arg;
|
std::optional<std::string> cdash_output_arg;
|
||||||
std::string test_timeout_arg{"300"};
|
std::string test_timeout_arg{"300"};
|
||||||
|
std::optional<std::string> repeat_arg;
|
||||||
|
std::string retry_arg{"0"};
|
||||||
|
bool shuffle{false};
|
||||||
|
std::optional<std::string> shuffle_seed_arg;
|
||||||
|
bool stop_on_failure{false};
|
||||||
|
bool explain{false};
|
||||||
|
std::string explain_format{"text"};
|
||||||
|
std::optional<std::string> trace_arg;
|
||||||
bool publish_editor_selection{true};
|
bool publish_editor_selection{true};
|
||||||
bool no_cache{false};
|
bool no_cache{false};
|
||||||
bool locked{false};
|
bool locked{false};
|
||||||
@@ -431,9 +465,88 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
<< "' (expected 1..86400 seconds)\n";
|
<< "' (expected 1..86400 seconds)\n";
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
// Test repetition controls (CTest/Meson parity): --repeat MODE[:N], --retry N,
|
||||||
|
// --shuffle [--shuffle-seed N] and --stop-on-failure.
|
||||||
|
enum class RepeatMode { None, UntilFail, UntilPass, AfterTimeout };
|
||||||
|
RepeatMode repeat_mode = RepeatMode::None;
|
||||||
|
int repeat_count = 1;
|
||||||
|
if (opts.repeat_arg && !opts.repeat_arg->empty()) {
|
||||||
|
std::string mode_text = *opts.repeat_arg;
|
||||||
|
std::string count_text;
|
||||||
|
if (const auto colon = mode_text.find(':'); colon != std::string::npos) {
|
||||||
|
count_text = mode_text.substr(colon + 1);
|
||||||
|
mode_text = mode_text.substr(0, colon);
|
||||||
|
}
|
||||||
|
if (mode_text == "until-fail") {
|
||||||
|
repeat_mode = RepeatMode::UntilFail;
|
||||||
|
} else if (mode_text == "until-pass") {
|
||||||
|
repeat_mode = RepeatMode::UntilPass;
|
||||||
|
} else if (mode_text == "after-timeout") {
|
||||||
|
repeat_mode = RepeatMode::AfterTimeout;
|
||||||
|
} else {
|
||||||
|
std::cerr << cmd_name << ": invalid --repeat mode '" << mode_text
|
||||||
|
<< "' (expected until-fail, until-pass or after-timeout)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
repeat_count = 2;
|
||||||
|
if (!count_text.empty() &&
|
||||||
|
(!Void::Str::to_int(count_text, repeat_count) || repeat_count < 1 ||
|
||||||
|
repeat_count > 100)) {
|
||||||
|
std::cerr << cmd_name << ": invalid --repeat count '" << count_text
|
||||||
|
<< "' (expected 1..100)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int retry_count = 0;
|
||||||
|
if (!Void::Str::to_int(opts.retry_arg, retry_count) || retry_count < 0 || retry_count > 10) {
|
||||||
|
std::cerr << cmd_name << ": invalid --retry value '" << opts.retry_arg
|
||||||
|
<< "' (expected 0..10)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
std::optional<std::uint64_t> shuffle_seed;
|
||||||
|
if (opts.shuffle && opts.shuffle_seed_arg && !opts.shuffle_seed_arg->empty()) {
|
||||||
|
std::uint64_t parsed_seed = 0;
|
||||||
|
const auto &text = *opts.shuffle_seed_arg;
|
||||||
|
const auto [ptr, ec] = std::from_chars(text.data(), text.data() + text.size(), parsed_seed);
|
||||||
|
if (ec != std::errc{} || ptr != text.data() + text.size()) {
|
||||||
|
std::cerr << cmd_name << ": invalid --shuffle-seed '" << text
|
||||||
|
<< "' (expected an unsigned integer)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
shuffle_seed = parsed_seed;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<TestRunRecord> test_records;
|
std::vector<TestRunRecord> test_records;
|
||||||
const auto total_sw = Void::Time::Stopwatch::started();
|
const auto total_sw = Void::Time::Stopwatch::started();
|
||||||
|
|
||||||
|
// Chrome-trace collection (`--trace FILE`): build phases and per-action spans.
|
||||||
|
struct TraceEvent {
|
||||||
|
std::string name;
|
||||||
|
std::string category;
|
||||||
|
double ts_us{0};
|
||||||
|
double dur_us{0};
|
||||||
|
std::string detail;
|
||||||
|
};
|
||||||
|
std::vector<TraceEvent> trace_events;
|
||||||
|
std::mutex trace_mutex;
|
||||||
|
std::map<std::string, double> trace_started;
|
||||||
|
const auto trace_epoch = std::chrono::steady_clock::now();
|
||||||
|
const auto trace_now_us = [&] {
|
||||||
|
return std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() -
|
||||||
|
trace_epoch)
|
||||||
|
.count();
|
||||||
|
};
|
||||||
|
const auto trace_phase = [&](std::string name, std::string category, double elapsed_ms,
|
||||||
|
std::string detail) {
|
||||||
|
if (!opts.trace_arg) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const double dur = elapsed_ms * 1000.0;
|
||||||
|
std::lock_guard lock{trace_mutex};
|
||||||
|
trace_events.push_back({std::move(name), std::move(category),
|
||||||
|
std::max(0.0, trace_now_us() - dur), dur, std::move(detail)});
|
||||||
|
};
|
||||||
|
|
||||||
std::optional<CompilerFamily> compiler_override;
|
std::optional<CompilerFamily> compiler_override;
|
||||||
if (opts.compiler_arg) {
|
if (opts.compiler_arg) {
|
||||||
try {
|
try {
|
||||||
@@ -523,6 +636,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
}
|
}
|
||||||
Void::Log::info("Config", "Build description {} ({:.0f} ms)",
|
Void::Log::info("Config", "Build description {} ({:.0f} ms)",
|
||||||
compiled->recompiled ? "compiled" : "up to date (cached)", cfg_sw.elapsed_ms());
|
compiled->recompiled ? "compiled" : "up to date (cached)", cfg_sw.elapsed_ms());
|
||||||
|
trace_phase("config", "phase", cfg_sw.elapsed_ms(), "compile the build description");
|
||||||
|
|
||||||
auto profs = Config::discover_profiles(*compiled, fopts);
|
auto profs = Config::discover_profiles(*compiled, fopts);
|
||||||
if (!profs) {
|
if (!profs) {
|
||||||
@@ -582,11 +696,13 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
ctx.link_options.push_back("--coverage");
|
ctx.link_options.push_back("--coverage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto tc_sw = Void::Time::Stopwatch::started();
|
||||||
auto tc = Toolchain::discover_and_probe(ctx, build_root / ".vbs" / "probes");
|
auto tc = Toolchain::discover_and_probe(ctx, build_root / ".vbs" / "probes");
|
||||||
if (!tc) {
|
if (!tc) {
|
||||||
std::cerr << "vbs: " << tc.error().message() << '\n';
|
std::cerr << "vbs: " << tc.error().message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
trace_phase("toolchain", "phase", tc_sw.elapsed_ms(), "discover and probe the toolchain");
|
||||||
Void::Log::info("Toolchain", "[{}] Using {} ({}) [{}]", prof_name,
|
Void::Log::info("Toolchain", "[{}] Using {} ({}) [{}]", prof_name,
|
||||||
compiler_name(tc->family), tc->cxx_compiler.string(), tc->version_banner);
|
compiler_name(tc->family), tc->cxx_compiler.string(), tc->version_banner);
|
||||||
|
|
||||||
@@ -601,6 +717,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
Void::Log::info("Eval", "[{}] Evaluated {} target(s), {} dependenc(ies) ({:.0f} ms)",
|
Void::Log::info("Eval", "[{}] Evaluated {} target(s), {} dependenc(ies) ({:.0f} ms)",
|
||||||
prof_name, desc->targets.size(), desc->dependencies.size(),
|
prof_name, desc->targets.size(), desc->dependencies.size(),
|
||||||
eval_sw.elapsed_ms());
|
eval_sw.elapsed_ms());
|
||||||
|
trace_phase("eval", "phase", eval_sw.elapsed_ms(), "evaluate the project description");
|
||||||
|
|
||||||
// Load & merge any TOML dependency manifests declared by build.cpp.
|
// Load & merge any TOML dependency manifests declared by build.cpp.
|
||||||
std::vector<Package::NormalizedDependency> toml_deps;
|
std::vector<Package::NormalizedDependency> toml_deps;
|
||||||
@@ -768,6 +885,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
Void::Log::info("Snapshot", "[{}] Captured snapshot {} ({} file(s), {:.0f} ms)", prof_name,
|
Void::Log::info("Snapshot", "[{}] Captured snapshot {} ({} file(s), {:.0f} ms)", prof_name,
|
||||||
snap->snapshot_id.substr(0, 12), snap->entries.size(),
|
snap->snapshot_id.substr(0, 12), snap->entries.size(),
|
||||||
snap_sw.elapsed_ms());
|
snap_sw.elapsed_ms());
|
||||||
|
trace_phase("snapshot", "phase", snap_sw.elapsed_ms(), "capture the immutable snapshot");
|
||||||
|
|
||||||
const auto graph_sw = Void::Time::Stopwatch::started();
|
const auto graph_sw = Void::Time::Stopwatch::started();
|
||||||
Graph::GraphLowerOptions gopts{project_root, build_root, &(*snap),
|
Graph::GraphLowerOptions gopts{project_root, build_root, &(*snap),
|
||||||
@@ -782,6 +900,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
Void::Log::info("Graph", "[{}] Lowered {} action(s) across {} target(s) ({:.0f} ms)",
|
Void::Log::info("Graph", "[{}] Lowered {} action(s) across {} target(s) ({:.0f} ms)",
|
||||||
prof_name, graph->actions.size(), graph->targets.size(),
|
prof_name, graph->actions.size(), graph->targets.size(),
|
||||||
graph_sw.elapsed_ms());
|
graph_sw.elapsed_ms());
|
||||||
|
trace_phase("graph", "phase", graph_sw.elapsed_ms(), "lower the action graph");
|
||||||
|
|
||||||
// Publish compdb BEFORE compilation (Plan 09: compile failure does NOT undo selection!).
|
// Publish compdb BEFORE compilation (Plan 09: compile failure does NOT undo selection!).
|
||||||
Editor::PublishOptions popts;
|
Editor::PublishOptions popts;
|
||||||
@@ -801,6 +920,111 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
eopts.jobs = jobs;
|
eopts.jobs = jobs;
|
||||||
eopts.use_cache = !opts.no_cache;
|
eopts.use_cache = !opts.no_cache;
|
||||||
eopts.selected_targets = opts.targets;
|
eopts.selected_targets = opts.targets;
|
||||||
|
if (opts.trace_arg) {
|
||||||
|
eopts.on_event = [&](const Execution::ExecutionEvent &ev) {
|
||||||
|
std::lock_guard lock{trace_mutex};
|
||||||
|
const double now = trace_now_us();
|
||||||
|
if (ev.kind == Execution::ExecutionEvent::Kind::ActionStarted) {
|
||||||
|
trace_started[ev.action_id] = now;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const double dur = static_cast<double>(ev.elapsed.count()) * 1000.0;
|
||||||
|
double ts = std::max(0.0, now - dur);
|
||||||
|
if (const auto it = trace_started.find(ev.action_id); it != trace_started.end()) {
|
||||||
|
ts = it->second;
|
||||||
|
trace_started.erase(it);
|
||||||
|
}
|
||||||
|
const char *category =
|
||||||
|
ev.kind == Execution::ExecutionEvent::Kind::ActionCached
|
||||||
|
? "cache"
|
||||||
|
: (ev.kind == Execution::ExecutionEvent::Kind::ActionSucceeded ? "action"
|
||||||
|
: "failed");
|
||||||
|
trace_events.push_back({ev.label, category, ts, dur, ev.message});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.explain) {
|
||||||
|
auto explained = Execution::explain_graph(*graph, *state, eopts);
|
||||||
|
if (!explained) {
|
||||||
|
std::cerr << "vbs explain: " << explained.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const auto json_escape = [](std::string_view text) {
|
||||||
|
std::string out;
|
||||||
|
for (const char c : text) {
|
||||||
|
switch (c) {
|
||||||
|
case '"':
|
||||||
|
out += "\\\"";
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
out += "\\\\";
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
out += "\\n";
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
out += "\\t";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
out.push_back(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
if (opts.explain_format == "json") {
|
||||||
|
std::string json = std::format(
|
||||||
|
"{{\"profile\":\"{}\",\"total\":{},\"up_to_date\":{},\"would_run\":{},\"actions\":[",
|
||||||
|
json_escape(prof_name), explained->total, explained->up_to_date,
|
||||||
|
explained->would_run);
|
||||||
|
for (std::size_t i = 0; i < explained->actions.size(); ++i) {
|
||||||
|
const auto &ex = explained->actions[i];
|
||||||
|
if (i > 0) {
|
||||||
|
json += ',';
|
||||||
|
}
|
||||||
|
json += std::format(
|
||||||
|
"{{\"id\":\"{}\",\"target\":\"{}\",\"label\":\"{}\",\"action_key\":\"{}\","
|
||||||
|
"\"cacheable\":{},\"would_run\":{},\"restorable\":{},\"remote_hit\":{},"
|
||||||
|
"\"reason\":\"{}\",\"changed_inputs\":[",
|
||||||
|
json_escape(ex.action_id), json_escape(ex.target_name),
|
||||||
|
json_escape(ex.label), json_escape(ex.action_key),
|
||||||
|
ex.cacheable ? "true" : "false", ex.would_run ? "true" : "false",
|
||||||
|
ex.restorable ? "true" : "false", ex.remote_hit ? "true" : "false",
|
||||||
|
json_escape(ex.reason));
|
||||||
|
for (std::size_t j = 0; j < ex.changed_inputs.size(); ++j) {
|
||||||
|
json += (j > 0 ? "," : "") + std::format("\"{}\"", json_escape(ex.changed_inputs[j]));
|
||||||
|
}
|
||||||
|
json += "],\"changed_outputs\":[";
|
||||||
|
for (std::size_t j = 0; j < ex.changed_outputs.size(); ++j) {
|
||||||
|
json += (j > 0 ? "," : "") +
|
||||||
|
std::format("\"{}\"", json_escape(ex.changed_outputs[j]));
|
||||||
|
}
|
||||||
|
json += std::format("],\"command\":\"{}\"}}", json_escape(ex.command));
|
||||||
|
}
|
||||||
|
json += "]}";
|
||||||
|
std::cout << json << '\n';
|
||||||
|
} else {
|
||||||
|
std::cout << std::format("vbs explain: [{}] {} action(s): {} up to date, {} would run\n",
|
||||||
|
prof_name, explained->total, explained->up_to_date,
|
||||||
|
explained->would_run);
|
||||||
|
for (const auto &ex : explained->actions) {
|
||||||
|
std::cout << std::format(" {:<11} {}", ex.would_run ? "would run" : "up to date",
|
||||||
|
ex.label);
|
||||||
|
if (!ex.reason.empty() && ex.reason != "up to date") {
|
||||||
|
std::cout << " — " << ex.reason;
|
||||||
|
}
|
||||||
|
std::cout << '\n';
|
||||||
|
for (const auto &input : ex.changed_inputs) {
|
||||||
|
std::cout << " input: " << input << '\n';
|
||||||
|
}
|
||||||
|
for (const auto &output : ex.changed_outputs) {
|
||||||
|
std::cout << " output: " << output << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto rep = Execution::execute_graph(*graph, *state, eopts);
|
auto rep = Execution::execute_graph(*graph, *state, eopts);
|
||||||
if (!rep) {
|
if (!rep) {
|
||||||
std::cerr << "vbs: " << rep.error().message() << '\n';
|
std::cerr << "vbs: " << rep.error().message() << '\n';
|
||||||
@@ -1032,6 +1256,43 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
// Claim order: declaration order, or a seeded shuffle (--shuffle).
|
||||||
|
std::vector<std::size_t> claim_order(test_jobs.size());
|
||||||
|
std::iota(claim_order.begin(), claim_order.end(), std::size_t{0});
|
||||||
|
if (opts.shuffle) {
|
||||||
|
const std::uint64_t seed =
|
||||||
|
shuffle_seed.value_or(static_cast<std::uint64_t>(std::random_device{}()));
|
||||||
|
std::mt19937_64 rng{seed};
|
||||||
|
std::ranges::shuffle(claim_order, rng);
|
||||||
|
Void::Log::info("Test", "[{}] Shuffled {} test(s) (seed {})", prof_name,
|
||||||
|
claim_order.size(), seed);
|
||||||
|
}
|
||||||
|
const auto run_attempt = [&](const TestJob &job) {
|
||||||
|
const auto tsw = Void::Time::Stopwatch::started();
|
||||||
|
Platform::ProcessRequest treq;
|
||||||
|
if (wine) {
|
||||||
|
treq.executable = *wine;
|
||||||
|
treq.arguments = {job.executable.string()};
|
||||||
|
} else {
|
||||||
|
treq.executable = job.executable;
|
||||||
|
}
|
||||||
|
treq.working_directory = project_root;
|
||||||
|
treq.timeout = std::chrono::seconds{test_timeout_seconds};
|
||||||
|
auto tres = Platform::run_supervised(treq);
|
||||||
|
TestRunRecord record;
|
||||||
|
record.profile = prof_name;
|
||||||
|
record.name = job.name;
|
||||||
|
record.passed = tres.has_value() && tres->succeeded();
|
||||||
|
record.elapsed_ms = tsw.elapsed_ms();
|
||||||
|
if (tres) {
|
||||||
|
record.output = tres->stdout_data + tres->stderr_data;
|
||||||
|
record.exit_code = tres->exit_code;
|
||||||
|
record.timed_out = tres->timed_out;
|
||||||
|
} else {
|
||||||
|
record.output = tres.error().message();
|
||||||
|
}
|
||||||
|
return record;
|
||||||
|
};
|
||||||
const auto worker = [&] {
|
const auto worker = [&] {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
std::size_t index = 0;
|
std::size_t index = 0;
|
||||||
@@ -1041,12 +1302,18 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
if (remaining == 0) {
|
if (remaining == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (; index < test_jobs.size(); ++index) {
|
std::optional<std::size_t> pick;
|
||||||
if (!claimed[index] && prerequisites_done(index) &&
|
for (const std::size_t candidate : claim_order) {
|
||||||
resources_free(index)) {
|
if (!claimed[candidate] && prerequisites_done(candidate) &&
|
||||||
|
resources_free(candidate)) {
|
||||||
|
pick = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!pick) {
|
||||||
|
continue; // Woken spuriously; wait again.
|
||||||
|
}
|
||||||
|
index = *pick;
|
||||||
claimed[index] = true;
|
claimed[index] = true;
|
||||||
// A failed fixture setup skips its dependents.
|
// A failed fixture setup skips its dependents.
|
||||||
const bool blocked =
|
const bool blocked =
|
||||||
@@ -1068,37 +1335,49 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto &job = test_jobs[index];
|
const auto &job = test_jobs[index];
|
||||||
Void::Log::info("Test", "[{}] Running test target '{}'...", prof_name,
|
|
||||||
job.name);
|
|
||||||
const auto tsw = Void::Time::Stopwatch::started();
|
|
||||||
Platform::ProcessRequest treq;
|
|
||||||
if (wine) {
|
|
||||||
treq.executable = *wine;
|
|
||||||
treq.arguments = {job.executable.string()};
|
|
||||||
} else {
|
|
||||||
treq.executable = job.executable;
|
|
||||||
}
|
|
||||||
treq.working_directory = project_root;
|
|
||||||
treq.timeout = std::chrono::seconds{test_timeout_seconds};
|
|
||||||
auto tres = Platform::run_supervised(treq);
|
|
||||||
TestRunRecord record;
|
TestRunRecord record;
|
||||||
record.profile = prof_name;
|
double elapsed_total = 0.0;
|
||||||
record.name = job.name;
|
int attempts = 0;
|
||||||
record.passed = tres.has_value() && tres->succeeded();
|
for (;;) {
|
||||||
record.elapsed_ms = tsw.elapsed_ms();
|
++attempts;
|
||||||
if (tres) {
|
Void::Log::info("Test", "[{}] Running test target '{}' (attempt {})...",
|
||||||
record.output = tres->stdout_data + tres->stderr_data;
|
prof_name, job.name, attempts);
|
||||||
record.exit_code = tres->exit_code;
|
record = run_attempt(job);
|
||||||
} else {
|
elapsed_total += record.elapsed_ms;
|
||||||
record.output = tres.error().message();
|
bool again = false;
|
||||||
|
switch (repeat_mode) {
|
||||||
|
case RepeatMode::UntilFail:
|
||||||
|
again = record.passed && attempts < repeat_count;
|
||||||
|
break;
|
||||||
|
case RepeatMode::UntilPass:
|
||||||
|
again = !record.passed && attempts < repeat_count;
|
||||||
|
break;
|
||||||
|
case RepeatMode::AfterTimeout:
|
||||||
|
again = record.timed_out && attempts < repeat_count;
|
||||||
|
break;
|
||||||
|
case RepeatMode::None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!again && !record.passed && retry_count > 0 &&
|
||||||
|
attempts <= retry_count) {
|
||||||
|
again = true;
|
||||||
|
}
|
||||||
|
if (!again) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Void::Log::warn("Test", "[{}] Repeating '{}' ({})", prof_name, job.name,
|
||||||
|
record.passed ? "repeat policy"
|
||||||
|
: (record.timed_out ? "timed out" : "failed"));
|
||||||
}
|
}
|
||||||
|
record.attempts = attempts;
|
||||||
|
record.elapsed_ms = elapsed_total;
|
||||||
const bool passed = record.passed;
|
const bool passed = record.passed;
|
||||||
if (!passed) {
|
if (!passed) {
|
||||||
Void::Log::error("Test", "[{}] FAILED '{}' ({:.0f} ms)", prof_name,
|
Void::Log::error("Test", "[{}] FAILED '{}' after {} attempt(s) ({:.0f} ms)",
|
||||||
job.name, tsw.elapsed_ms());
|
prof_name, job.name, attempts, elapsed_total);
|
||||||
} else {
|
} else {
|
||||||
Void::Log::info("Test", "[{}] PASSED '{}' ({:.0f} ms)", prof_name, job.name,
|
Void::Log::info("Test", "[{}] PASSED '{}' after {} attempt(s) ({:.0f} ms)",
|
||||||
tsw.elapsed_ms());
|
prof_name, job.name, attempts, elapsed_total);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::lock_guard lock{test_mutex};
|
std::lock_guard lock{test_mutex};
|
||||||
@@ -1109,6 +1388,22 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
completed[index] = true;
|
completed[index] = true;
|
||||||
failed[index] = !passed;
|
failed[index] = !passed;
|
||||||
--remaining;
|
--remaining;
|
||||||
|
if (!passed && opts.stop_on_failure) {
|
||||||
|
std::size_t skipped = 0;
|
||||||
|
for (std::size_t i = 0; i < test_jobs.size(); ++i) {
|
||||||
|
if (!claimed[i] && !completed[i]) {
|
||||||
|
claimed[i] = true;
|
||||||
|
completed[i] = true;
|
||||||
|
--remaining;
|
||||||
|
++skipped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skipped > 0) {
|
||||||
|
Void::Log::warn("Test",
|
||||||
|
"[{}] --stop-on-failure: skipped {} remaining test(s)",
|
||||||
|
prof_name, skipped);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
test_cv.notify_all();
|
test_cv.notify_all();
|
||||||
}
|
}
|
||||||
@@ -1139,6 +1434,10 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
test_records.push_back(std::move(*record));
|
test_records.push_back(std::move(*record));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (opts.stop_on_failure && !all_ok) {
|
||||||
|
Void::Log::warn("Test", "--stop-on-failure: skipping the remaining profiles");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lcov coverage report from the gcov data produced by the instrumented test binaries.
|
// lcov coverage report from the gcov data produced by the instrumented test binaries.
|
||||||
@@ -1291,6 +1590,53 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.trace_arg && !opts.trace_arg->empty()) {
|
||||||
|
trace_phase("total", "phase", total_sw.elapsed_ms(), "whole invocation");
|
||||||
|
const auto json_escape = [](std::string_view text) {
|
||||||
|
std::string out;
|
||||||
|
for (const char c : text) {
|
||||||
|
switch (c) {
|
||||||
|
case '"':
|
||||||
|
out += "\\\"";
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
out += "\\\\";
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
out += "\\n";
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
out += "\\t";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
out.push_back(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
std::string json = "{\"traceEvents\":[";
|
||||||
|
for (std::size_t i = 0; i < trace_events.size(); ++i) {
|
||||||
|
const auto &ev = trace_events[i];
|
||||||
|
if (i > 0) {
|
||||||
|
json += ',';
|
||||||
|
}
|
||||||
|
json += std::format(
|
||||||
|
"{{\"name\":\"{}\",\"cat\":\"{}\",\"ph\":\"X\",\"ts\":{:.0f},\"dur\":{:.0f},"
|
||||||
|
"\"pid\":1,\"tid\":1,\"args\":{{\"detail\":\"{}\"}}}}",
|
||||||
|
json_escape(ev.name), json_escape(ev.category), ev.ts_us, ev.dur_us,
|
||||||
|
json_escape(ev.detail));
|
||||||
|
}
|
||||||
|
json += "],\"displayTimeUnit\":\"ms\"}";
|
||||||
|
if (auto written = Platform::atomic_write_file(*opts.trace_arg, json, false); !written) {
|
||||||
|
std::cerr << "vbs: cannot write trace file: " << written.error().message() << '\n';
|
||||||
|
all_ok = false;
|
||||||
|
} else {
|
||||||
|
Void::Log::info("Build", "Wrote {} trace event(s) to {}", trace_events.size(),
|
||||||
|
*opts.trace_arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Void::Log::debug("Build", "Total wall time: {:.2f}s", total_sw.elapsed_ms() / 1000.0);
|
Void::Log::debug("Build", "Total wall time: {:.2f}s", total_sw.elapsed_ms() / 1000.0);
|
||||||
return all_ok ? 0 : 1;
|
return all_ok ? 0 : 1;
|
||||||
}
|
}
|
||||||
@@ -2147,20 +2493,45 @@ int execute_worker_command(const WorkerCmdOptions &opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MigrateCmdOptions {
|
struct MigrateCmdOptions {
|
||||||
std::string input_arg{"CMakeLists.txt"};
|
std::string input_arg;
|
||||||
std::string output_arg{"build.cpp"};
|
std::string output_arg{"build.cpp"};
|
||||||
std::string project_arg{"."};
|
std::string project_arg{"."};
|
||||||
|
std::string from_arg{"cmake"};
|
||||||
bool force{false};
|
bool force{false};
|
||||||
bool dry_run{false};
|
bool dry_run{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
int execute_migrate_command(const MigrateCmdOptions &opts) {
|
int execute_migrate_command(const MigrateCmdOptions &opts) {
|
||||||
auto imported = Config::import_cmake_lists(opts.input_arg, opts.project_arg);
|
std::string input = opts.input_arg;
|
||||||
|
if (input.empty()) {
|
||||||
|
input = opts.from_arg == "meson" ? "meson.build" : "CMakeLists.txt";
|
||||||
|
}
|
||||||
|
std::string source_kind = "CMakeLists.txt";
|
||||||
|
if (opts.from_arg != "cmake" && opts.from_arg != "meson") {
|
||||||
|
std::cerr << "vbs migrate: unsupported --from '" << opts.from_arg
|
||||||
|
<< "' (expected cmake or meson)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (opts.from_arg == "meson") {
|
||||||
|
source_kind = "meson.build";
|
||||||
|
}
|
||||||
|
auto imported = opts.from_arg == "meson"
|
||||||
|
? Config::import_meson_build(input, opts.project_arg)
|
||||||
|
: Config::import_cmake_lists(input, opts.project_arg);
|
||||||
if (!imported) {
|
if (!imported) {
|
||||||
std::cerr << "vbs migrate: " << imported.error().message() << '\n';
|
std::cerr << "vbs migrate: " << imported.error().message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const std::string rendered = Config::render_build_cpp(*imported);
|
std::string rendered = Config::render_build_cpp(*imported);
|
||||||
|
// The renderer header names the CMake source; correct it for Meson imports.
|
||||||
|
if (source_kind == "meson.build") {
|
||||||
|
const std::string header = "// Generated by `vbs migrate` from CMakeLists.txt. Review before use.";
|
||||||
|
if (const auto at = rendered.find(header); at != std::string::npos) {
|
||||||
|
rendered.replace(at, header.size(),
|
||||||
|
"// Generated by `vbs migrate --from meson` from meson.build. "
|
||||||
|
"Review before use.");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (opts.dry_run) {
|
if (opts.dry_run) {
|
||||||
std::cout << rendered;
|
std::cout << rendered;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2185,9 +2556,81 @@ struct PresetsCmdOptions {
|
|||||||
std::string file_arg{"CMakePresets.json"};
|
std::string file_arg{"CMakePresets.json"};
|
||||||
std::string project_arg;
|
std::string project_arg;
|
||||||
std::optional<std::string> name_arg;
|
std::optional<std::string> name_arg;
|
||||||
|
std::optional<std::string> export_arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
int execute_presets_command(const PresetsCmdOptions &opts) {
|
int execute_presets_command(const PresetsCmdOptions &opts) {
|
||||||
|
if (opts.export_arg) {
|
||||||
|
// Export VBS profiles as CMake configure presets so CMake-only tools can read a VBS
|
||||||
|
// project. The inverse of the import path (round-trippable through `vbs presets`).
|
||||||
|
const std::filesystem::path project_root{opts.project_arg};
|
||||||
|
const auto build_root = project_root / "build";
|
||||||
|
const auto fopts = make_frontend_opts(project_root, build_root, {});
|
||||||
|
auto compiled = Config::compile_descriptor(fopts);
|
||||||
|
if (!compiled) {
|
||||||
|
std::cerr << "vbs presets: " << compiled.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
auto profs = Config::discover_profiles(*compiled, fopts);
|
||||||
|
if (!profs) {
|
||||||
|
std::cerr << "vbs presets: " << profs.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::string json = "{\n \"version\": 3,\n \"configurePresets\": [\n";
|
||||||
|
bool first = true;
|
||||||
|
const auto cmake_build_type = [](std::string_view profile) {
|
||||||
|
std::string lower = Void::Str::to_lower_ascii(profile);
|
||||||
|
if (lower == "debug") {
|
||||||
|
return std::string{"Debug"};
|
||||||
|
}
|
||||||
|
if (lower == "release") {
|
||||||
|
return std::string{"Release"};
|
||||||
|
}
|
||||||
|
if (lower == "relwithdebinfo") {
|
||||||
|
return std::string{"RelWithDebInfo"};
|
||||||
|
}
|
||||||
|
if (lower == "minsizerel") {
|
||||||
|
return std::string{"MinSizeRel"};
|
||||||
|
}
|
||||||
|
return std::string{profile};
|
||||||
|
};
|
||||||
|
for (const auto &record : profs->records()) {
|
||||||
|
const std::string &profile = record.name;
|
||||||
|
ProfileContext ctx;
|
||||||
|
try {
|
||||||
|
ctx = profs->resolve(profile, std::nullopt, Toolchain::host_os_name(),
|
||||||
|
Toolchain::host_architecture_name());
|
||||||
|
} catch (const std::exception &ex) {
|
||||||
|
std::cerr << "vbs presets: " << ex.what() << '\n';
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (!first) {
|
||||||
|
json += ",\n";
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
json += " {\n";
|
||||||
|
json += " \"name\": " + Util::json_quote(profile) + ",\n";
|
||||||
|
json += " \"displayName\": " + Util::json_quote("VBS " + profile) + ",\n";
|
||||||
|
json += " \"generator\": \"Ninja\",\n";
|
||||||
|
json += " \"binaryDir\": " +
|
||||||
|
Util::json_quote("${sourceDir}/build/" + profile) + ",\n";
|
||||||
|
json += " \"cacheVariables\": {\n";
|
||||||
|
json += " \"CMAKE_BUILD_TYPE\": " + Util::json_quote(cmake_build_type(profile)) +
|
||||||
|
",\n";
|
||||||
|
json += " \"CMAKE_CXX_COMPILER\": " +
|
||||||
|
Util::json_quote(compiler_name(ctx.compiler)) + ",\n";
|
||||||
|
json += " \"CMAKE_EXPORT_COMPILE_COMMANDS\": \"ON\"\n";
|
||||||
|
json += " }\n }";
|
||||||
|
}
|
||||||
|
json += "\n ]\n}\n";
|
||||||
|
if (auto written = Platform::atomic_write_file(*opts.export_arg, json, false); !written) {
|
||||||
|
std::cerr << "vbs presets: cannot write '" << *opts.export_arg
|
||||||
|
<< "': " << written.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::cout << "wrote " << *opts.export_arg << '\n';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
auto presets = Config::load_cmake_presets(opts.file_arg, opts.project_arg);
|
auto presets = Config::load_cmake_presets(opts.file_arg, opts.project_arg);
|
||||||
if (!presets) {
|
if (!presets) {
|
||||||
std::cerr << "vbs presets: " << presets.error().message() << '\n';
|
std::cerr << "vbs presets: " << presets.error().message() << '\n';
|
||||||
@@ -3310,6 +3753,7 @@ struct InitCmdOptions {
|
|||||||
bool library{false};
|
bool library{false};
|
||||||
bool with_toml{false};
|
bool with_toml{false};
|
||||||
bool force{false};
|
bool force{false};
|
||||||
|
std::string template_arg{"app"};
|
||||||
};
|
};
|
||||||
|
|
||||||
int execute_init_command(const InitCmdOptions &opts) {
|
int execute_init_command(const InitCmdOptions &opts) {
|
||||||
@@ -3319,14 +3763,15 @@ int execute_init_command(const InitCmdOptions &opts) {
|
|||||||
options.library = opts.library;
|
options.library = opts.library;
|
||||||
options.with_toml = opts.with_toml;
|
options.with_toml = opts.with_toml;
|
||||||
options.force = opts.force;
|
options.force = opts.force;
|
||||||
|
options.template_name = opts.template_arg;
|
||||||
auto report = Config::scaffold_project(options);
|
auto report = Config::scaffold_project(options);
|
||||||
if (!report) {
|
if (!report) {
|
||||||
std::cerr << report.error().message() << '\n';
|
std::cerr << report.error().message() << '\n';
|
||||||
return report.error().kind() == Void::Result::ErrorKind::conflict ? 2 : 1;
|
return report.error().kind() == Void::Result::ErrorKind::conflict ? 2 : 1;
|
||||||
}
|
}
|
||||||
Void::Log::info("Init", "Initialized VBS {} project '{}' in '{}'",
|
Void::Log::info("Init", "Initialized VBS {} project '{}' in '{}'",
|
||||||
opts.library ? "library" : "application", report->project_name,
|
opts.template_arg == "app" ? "application" : opts.template_arg,
|
||||||
report->target_dir.string());
|
report->project_name, report->target_dir.string());
|
||||||
std::cout << "initialized " << report->project_name << " in " << report->target_dir.string()
|
std::cout << "initialized " << report->project_name << " in " << report->target_dir.string()
|
||||||
<< '\n';
|
<< '\n';
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3418,6 +3863,92 @@ struct GraphCmdOptions {
|
|||||||
std::string format{"dot"};
|
std::string format{"dot"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CompletionsCmdOptions {
|
||||||
|
std::string shell_arg;
|
||||||
|
std::optional<std::string> output_arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ManCmdOptions {
|
||||||
|
std::optional<std::string> output_arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
int execute_completions_command(const CompletionsCmdOptions &opts) {
|
||||||
|
if (opts.shell_arg != "bash" && opts.shell_arg != "zsh" && opts.shell_arg != "fish") {
|
||||||
|
std::cerr << "vbs completions: unsupported --shell '" << opts.shell_arg
|
||||||
|
<< "' (expected bash, zsh or fish)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
auto exe = Platform::current_executable_path();
|
||||||
|
if (!exe) {
|
||||||
|
std::cerr << "vbs completions: " << exe.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
auto model = Cli::build_command_model(*exe);
|
||||||
|
if (!model) {
|
||||||
|
std::cerr << "vbs completions: " << model.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::string script;
|
||||||
|
if (opts.shell_arg == "bash") {
|
||||||
|
script = Cli::render_bash_completion(*model);
|
||||||
|
} else if (opts.shell_arg == "zsh") {
|
||||||
|
script = Cli::render_zsh_completion(*model);
|
||||||
|
} else {
|
||||||
|
script = Cli::render_fish_completion(*model);
|
||||||
|
}
|
||||||
|
if (opts.output_arg) {
|
||||||
|
if (auto written = Platform::atomic_write_file(*opts.output_arg, script, false); !written) {
|
||||||
|
std::cerr << "vbs completions: cannot write '" << *opts.output_arg
|
||||||
|
<< "': " << written.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::cout << "wrote " << *opts.output_arg << '\n';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::cout << script;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int execute_man_command(const ManCmdOptions &opts) {
|
||||||
|
auto exe = Platform::current_executable_path();
|
||||||
|
if (!exe) {
|
||||||
|
std::cerr << "vbs man: " << exe.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
auto model = Cli::build_command_model(*exe);
|
||||||
|
if (!model) {
|
||||||
|
std::cerr << "vbs man: " << model.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const std::string version{Bootstrap::version};
|
||||||
|
if (!opts.output_arg) {
|
||||||
|
std::cout << Cli::render_man_page(*model, version);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::error_code ec;
|
||||||
|
const std::filesystem::path out_dir{*opts.output_arg};
|
||||||
|
std::filesystem::create_directories(out_dir, ec);
|
||||||
|
if (ec) {
|
||||||
|
std::cerr << "vbs man: cannot create '" << out_dir.string() << "': " << ec.message()
|
||||||
|
<< '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::size_t written_pages = 0;
|
||||||
|
for (const auto *command : Cli::flatten_commands(*model)) {
|
||||||
|
const auto page = out_dir / (Cli::man_page_name(*command) + ".1");
|
||||||
|
if (auto wrote = Platform::atomic_write_file(page, Cli::render_man_page(*command, version),
|
||||||
|
false);
|
||||||
|
!wrote) {
|
||||||
|
std::cerr << "vbs man: cannot write '" << page.string()
|
||||||
|
<< "': " << wrote.error().message() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
++written_pages;
|
||||||
|
}
|
||||||
|
std::cout << "wrote " << written_pages << " man page(s) to " << out_dir.string() << '\n';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int execute_graph_command(const GraphCmdOptions &opts) {
|
int execute_graph_command(const GraphCmdOptions &opts) {
|
||||||
if (opts.format != "dot" && opts.format != "json") {
|
if (opts.format != "dot" && opts.format != "json") {
|
||||||
std::cerr << "vbs graph: unsupported --format '" << opts.format
|
std::cerr << "vbs graph: unsupported --format '" << opts.format
|
||||||
@@ -3808,6 +4339,8 @@ int main(int argc, char **argv) {
|
|||||||
const std::string clean_default_build = clean_opts.build_arg;
|
const std::string clean_default_build = clean_opts.build_arg;
|
||||||
GraphCmdOptions graph_opts;
|
GraphCmdOptions graph_opts;
|
||||||
graph_opts.project_arg = cwd;
|
graph_opts.project_arg = cwd;
|
||||||
|
CompletionsCmdOptions completions_opts;
|
||||||
|
ManCmdOptions man_opts;
|
||||||
IdeCmdOptions ide_opts;
|
IdeCmdOptions ide_opts;
|
||||||
ide_opts.project_arg = cwd;
|
ide_opts.project_arg = cwd;
|
||||||
DaemonCmdOptions daemon_opts;
|
DaemonCmdOptions daemon_opts;
|
||||||
@@ -3833,6 +4366,19 @@ int main(int argc, char **argv) {
|
|||||||
build_opts.target_arch_arg)
|
build_opts.target_arch_arg)
|
||||||
.option_default("--test-timeout", "", "Per-test timeout in seconds (1..86400)",
|
.option_default("--test-timeout", "", "Per-test timeout in seconds (1..86400)",
|
||||||
build_opts.test_timeout_arg, "300")
|
build_opts.test_timeout_arg, "300")
|
||||||
|
.option("--repeat", "",
|
||||||
|
"Repeat tests: until-fail[:N], until-pass[:N] or after-timeout[:N] (N=1..100)",
|
||||||
|
build_opts.repeat_arg)
|
||||||
|
.option_default("--retry", "", "Retry a failed test up to N times (0..10)",
|
||||||
|
build_opts.retry_arg, "0")
|
||||||
|
.flag("--shuffle", "", "Run tests in a shuffled order", build_opts.shuffle)
|
||||||
|
.option("--shuffle-seed", "", "Seed for --shuffle (default: random)",
|
||||||
|
build_opts.shuffle_seed_arg)
|
||||||
|
.flag("--stop-on-failure", "", "Stop scheduling tests after the first failure",
|
||||||
|
build_opts.stop_on_failure)
|
||||||
|
.option("--trace", "",
|
||||||
|
"Write a Chrome trace (JSON) of build phases and action spans",
|
||||||
|
build_opts.trace_arg)
|
||||||
.option("--junit", "", "Write a JUnit XML report of test results", build_opts.junit_arg)
|
.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",
|
.option("--coverage", "", "Build with --coverage and write an lcov report to this directory",
|
||||||
build_opts.coverage_arg)
|
build_opts.coverage_arg)
|
||||||
@@ -3883,6 +4429,11 @@ int main(int argc, char **argv) {
|
|||||||
configure_build_or_test(
|
configure_build_or_test(
|
||||||
root.subcommand("build", "Configure and build selected profiles and targets"));
|
root.subcommand("build", "Configure and build selected profiles and targets"));
|
||||||
configure_build_or_test(root.subcommand("test", "Build and run declared test targets"));
|
configure_build_or_test(root.subcommand("test", "Build and run declared test targets"));
|
||||||
|
auto &explain_cmd =
|
||||||
|
root.subcommand("explain", "Explain why each action would run or be reused");
|
||||||
|
configure_build_or_test(explain_cmd);
|
||||||
|
explain_cmd.option_default("--format", "", "Output format: text (default) or json",
|
||||||
|
build_opts.explain_format, "text");
|
||||||
|
|
||||||
auto &describe_cmd =
|
auto &describe_cmd =
|
||||||
root.subcommand("describe", "Evaluate build.cpp and emit versioned graph summary JSON");
|
root.subcommand("describe", "Evaluate build.cpp and emit versioned graph summary JSON");
|
||||||
@@ -4047,25 +4598,30 @@ int main(int argc, char **argv) {
|
|||||||
add_log_flags(worker_cmd);
|
add_log_flags(worker_cmd);
|
||||||
|
|
||||||
auto &migrate_cmd = root.subcommand(
|
auto &migrate_cmd = root.subcommand(
|
||||||
"migrate", "Generate a build.cpp scaffold from a CMakeLists.txt (bounded subset)");
|
"migrate", "Generate a build.cpp scaffold from a CMakeLists.txt or meson.build");
|
||||||
migrate_cmd
|
migrate_cmd
|
||||||
.option_default("--input", "-i", "CMakeLists.txt path", migrate_opts.input_arg,
|
.option_default("--input", "-i",
|
||||||
"CMakeLists.txt")
|
"Input file (default depends on --from: CMakeLists.txt or meson.build)",
|
||||||
|
migrate_opts.input_arg, "")
|
||||||
.option_default("--output", "-o", "Output build.cpp path", migrate_opts.output_arg,
|
.option_default("--output", "-o", "Output build.cpp path", migrate_opts.output_arg,
|
||||||
"build.cpp")
|
"build.cpp")
|
||||||
.option_default("--project", "-C", "Project root", migrate_opts.project_arg, ".")
|
.option_default("--project", "-C", "Project root", migrate_opts.project_arg, ".")
|
||||||
|
.option_default_checked("--from", "", "Input format: cmake (default) or meson",
|
||||||
|
migrate_opts.from_arg, "cmake", {"cmake", "meson"})
|
||||||
.flag("--force", "", "Overwrite an existing output file", migrate_opts.force)
|
.flag("--force", "", "Overwrite an existing output file", migrate_opts.force)
|
||||||
.flag("--dry-run", "", "Print the scaffold instead of writing it", migrate_opts.dry_run);
|
.flag("--dry-run", "", "Print the scaffold instead of writing it", migrate_opts.dry_run);
|
||||||
add_log_flags(migrate_cmd);
|
add_log_flags(migrate_cmd);
|
||||||
|
|
||||||
auto &presets_cmd = root.subcommand(
|
auto &presets_cmd = root.subcommand(
|
||||||
"presets", "Import CMake configure presets (CMakePresets.json) as VBS equivalents");
|
"presets", "Import or export CMake configure presets (CMakePresets.json)");
|
||||||
presets_cmd
|
presets_cmd
|
||||||
.option_default("--file", "-f", "CMakePresets.json path", presets_opts.file_arg,
|
.option_default("--file", "-f", "CMakePresets.json path", presets_opts.file_arg,
|
||||||
"CMakePresets.json")
|
"CMakePresets.json")
|
||||||
.option_default("--project", "-C", "Project root for ${sourceDir}",
|
.option_default("--project", "-C", "Project root for ${sourceDir}",
|
||||||
presets_opts.project_arg, cwd)
|
presets_opts.project_arg, cwd)
|
||||||
.option("--name", "-n", "Print the VBS command for one preset", presets_opts.name_arg);
|
.option("--name", "-n", "Print the VBS command for one preset", presets_opts.name_arg)
|
||||||
|
.option("--export", "-e", "Write the VBS profiles as CMake presets to this file",
|
||||||
|
presets_opts.export_arg);
|
||||||
add_log_flags(presets_cmd);
|
add_log_flags(presets_cmd);
|
||||||
|
|
||||||
auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock");
|
auto &lock_cmd = root.subcommand("lock", "Inspect the project's vbs.lock");
|
||||||
@@ -4195,6 +4751,10 @@ int main(int argc, char **argv) {
|
|||||||
init_cmd.option_default("--dir", "-C", "Target project directory", init_opts.dir_arg, cwd)
|
init_cmd.option_default("--dir", "-C", "Target project directory", init_opts.dir_arg, cwd)
|
||||||
.option("--name", "-n", "Project/target name (defaults to directory name)",
|
.option("--name", "-n", "Project/target name (defaults to directory name)",
|
||||||
init_opts.name_arg)
|
init_opts.name_arg)
|
||||||
|
.option_default_checked("--template", "-t",
|
||||||
|
"Project template: app (default), library, header-only or shared",
|
||||||
|
init_opts.template_arg, "app",
|
||||||
|
{"app", "library", "header-only", "shared"})
|
||||||
.flag("--library", "", "Scaffold a static library project instead of an executable",
|
.flag("--library", "", "Scaffold a static library project instead of an executable",
|
||||||
init_opts.library)
|
init_opts.library)
|
||||||
.flag("--with-toml", "", "Include a vbs.deps.toml dependency manifest", init_opts.with_toml)
|
.flag("--with-toml", "", "Include a vbs.deps.toml dependency manifest", init_opts.with_toml)
|
||||||
@@ -4214,6 +4774,21 @@ int main(int argc, char **argv) {
|
|||||||
root.subcommand("doctor", "Check host compilers, tools, and VBS runtime capabilities");
|
root.subcommand("doctor", "Check host compilers, tools, and VBS runtime capabilities");
|
||||||
add_log_flags(doctor_cmd);
|
add_log_flags(doctor_cmd);
|
||||||
|
|
||||||
|
auto &completions_cmd = root.subcommand(
|
||||||
|
"completions", "Print a shell completion script generated from the CLI itself");
|
||||||
|
completions_cmd
|
||||||
|
.option_default("--shell", "-s", "Shell: bash, zsh or fish", completions_opts.shell_arg,
|
||||||
|
"bash")
|
||||||
|
.option("--output", "-o", "Write the script to this file instead of stdout",
|
||||||
|
completions_opts.output_arg);
|
||||||
|
add_log_flags(completions_cmd);
|
||||||
|
|
||||||
|
auto &man_cmd =
|
||||||
|
root.subcommand("man", "Render man pages for vbs and every subcommand");
|
||||||
|
man_cmd.option("--output", "-o", "Directory to write vbs.1 and vbs-<command>.1 pages into",
|
||||||
|
man_opts.output_arg);
|
||||||
|
add_log_flags(man_cmd);
|
||||||
|
|
||||||
auto &graph_cmd =
|
auto &graph_cmd =
|
||||||
root.subcommand("graph", "Export target dependency graph in Graphviz DOT or JSON format");
|
root.subcommand("graph", "Export target dependency graph in Graphviz DOT or JSON format");
|
||||||
graph_cmd.option_default("--project", "-C", "Project directory", graph_opts.project_arg, cwd)
|
graph_cmd.option_default("--project", "-C", "Project directory", graph_opts.project_arg, cwd)
|
||||||
@@ -4478,7 +5053,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
const std::string_view cmd = parsed.matched_command_path.front();
|
const std::string_view cmd = parsed.matched_command_path.front();
|
||||||
const bool machine_quiet_default =
|
const bool machine_quiet_default =
|
||||||
(cmd == "describe") || (cmd == "graph") || (cmd == "doctor") ||
|
(cmd == "describe") || (cmd == "graph") || (cmd == "doctor") || (cmd == "explain") ||
|
||||||
(cmd == "compdb" && parsed.matched_command_path.size() >= 2 &&
|
(cmd == "compdb" && parsed.matched_command_path.size() >= 2 &&
|
||||||
parsed.matched_command_path[1] == "show") ||
|
parsed.matched_command_path[1] == "show") ||
|
||||||
(cmd == "ide" && parsed.matched_command_path.size() >= 2 &&
|
(cmd == "ide" && parsed.matched_command_path.size() >= 2 &&
|
||||||
@@ -4489,8 +5064,15 @@ int main(int argc, char **argv) {
|
|||||||
: Void::Log::Level::Info);
|
: Void::Log::Level::Info);
|
||||||
ConsoleLogGuard log_guard{log_level};
|
ConsoleLogGuard log_guard{log_level};
|
||||||
|
|
||||||
if (cmd == "build" || cmd == "test") {
|
if (cmd == "build" || cmd == "test" || cmd == "explain") {
|
||||||
const bool run_tests = cmd == "test";
|
const bool run_tests = cmd == "test";
|
||||||
|
build_opts.explain = cmd == "explain";
|
||||||
|
if (build_opts.explain && build_opts.explain_format != "text" &&
|
||||||
|
build_opts.explain_format != "json") {
|
||||||
|
std::cerr << "vbs explain: unsupported --format '" << build_opts.explain_format
|
||||||
|
<< "' (expected text or json)\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
if (Config::is_workspace_root(std::filesystem::path{build_opts.project_arg})) {
|
if (Config::is_workspace_root(std::filesystem::path{build_opts.project_arg})) {
|
||||||
return execute_workspace(std::move(build_opts), run_tests);
|
return execute_workspace(std::move(build_opts), run_tests);
|
||||||
}
|
}
|
||||||
@@ -4575,6 +5157,12 @@ int main(int argc, char **argv) {
|
|||||||
if (cmd == "doctor") {
|
if (cmd == "doctor") {
|
||||||
return execute_doctor_command();
|
return execute_doctor_command();
|
||||||
}
|
}
|
||||||
|
if (cmd == "completions") {
|
||||||
|
return execute_completions_command(completions_opts);
|
||||||
|
}
|
||||||
|
if (cmd == "man") {
|
||||||
|
return execute_man_command(man_opts);
|
||||||
|
}
|
||||||
if (cmd == "graph") {
|
if (cmd == "graph") {
|
||||||
return execute_graph_command(graph_opts);
|
return execute_graph_command(graph_opts);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||||
#include <Void/Build/Util/Json.hpp>
|
#include <Void/Build/Util/Json.hpp>
|
||||||
#include <Void/Build/Util/Sha256.hpp>
|
#include <Void/Build/Util/Sha256.hpp>
|
||||||
|
#include <Void/Build/Util/UserCache.hpp>
|
||||||
#include <Void/Configuration/Env.hpp>
|
#include <Void/Configuration/Env.hpp>
|
||||||
#include <Void/Data/StrictJson.hpp>
|
#include <Void/Data/StrictJson.hpp>
|
||||||
|
#include <Void/Log/Log.hpp>
|
||||||
#include <Void/System/Path.hpp>
|
#include <Void/System/Path.hpp>
|
||||||
#include <Void/System/TempDir.hpp>
|
#include <Void/System/TempDir.hpp>
|
||||||
#include <Void/System/Types.hpp>
|
#include <Void/System/Types.hpp>
|
||||||
@@ -410,14 +412,38 @@ discover_and_probe(const ProfileContext &context,
|
|||||||
}
|
}
|
||||||
const std::string probe_cache_key = key_hasher.finalize_hex();
|
const std::string probe_cache_key = key_hasher.finalize_hex();
|
||||||
|
|
||||||
|
// Probe results are content-addressed by compiler identity, sysroot, target and the relevant
|
||||||
|
// environment, so a shared per-user cache can serve fresh build directories (CI jobs, new
|
||||||
|
// clones) without re-running ~20 compiler probes.
|
||||||
|
const auto shared_probe_dir = Util::user_cache_dir("probes");
|
||||||
|
const auto load_cached = [&](const std::filesystem::path &file)
|
||||||
|
-> std::optional<ToolchainCapabilities> {
|
||||||
|
auto cached_text = Void::FileSystem::read_file(file);
|
||||||
|
if (!cached_text) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
auto cached = deserialize_capabilities(*cached_text);
|
||||||
|
if (!cached) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
cached->relevant_env = relevant_env;
|
||||||
|
attach_shader_tools(*cached);
|
||||||
|
return *cached;
|
||||||
|
};
|
||||||
if (cache_dir) {
|
if (cache_dir) {
|
||||||
const auto cache_file = *cache_dir / (probe_cache_key + ".json");
|
if (auto cached = load_cached(*cache_dir / (probe_cache_key + ".json"))) {
|
||||||
if (auto cached_text = Void::FileSystem::read_file(cache_file); cached_text) {
|
return *cached;
|
||||||
if (auto cached = deserialize_capabilities(*cached_text); cached) {
|
}
|
||||||
cached->relevant_env = relevant_env;
|
}
|
||||||
attach_shader_tools(*cached);
|
if (shared_probe_dir) {
|
||||||
return *cached;
|
if (auto cached = load_cached(*shared_probe_dir / (probe_cache_key + ".json"))) {
|
||||||
|
if (cache_dir) {
|
||||||
|
// Seed the build-local cache so later runs never touch the shared one.
|
||||||
|
(void)Platform::atomic_write_file(*cache_dir / (probe_cache_key + ".json"),
|
||||||
|
serialize_capabilities(*cached), false);
|
||||||
}
|
}
|
||||||
|
Void::Log::debug("Toolchain", "probe capabilities reused from the shared cache");
|
||||||
|
return *cached;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,6 +592,10 @@ discover_and_probe(const ProfileContext &context,
|
|||||||
const auto cache_file = *cache_dir / (probe_cache_key + ".json");
|
const auto cache_file = *cache_dir / (probe_cache_key + ".json");
|
||||||
(void)Platform::atomic_write_file(cache_file, serialize_capabilities(cap), false);
|
(void)Platform::atomic_write_file(cache_file, serialize_capabilities(cap), false);
|
||||||
}
|
}
|
||||||
|
if (shared_probe_dir) {
|
||||||
|
(void)Platform::atomic_write_file(*shared_probe_dir / (probe_cache_key + ".json"),
|
||||||
|
serialize_capabilities(cap), false);
|
||||||
|
}
|
||||||
|
|
||||||
attach_shader_tools(cap);
|
attach_shader_tools(cap);
|
||||||
return cap;
|
return cap;
|
||||||
|
|||||||
@@ -28,6 +28,25 @@ check_process(2 "" "unknown subcommand: invalid" invalid)
|
|||||||
check_process(0 "Usage: vbs build .*--native-foreign.*--profile.*\\(repeatable\\)" "" build --help)
|
check_process(0 "Usage: vbs build .*--native-foreign.*--profile.*\\(repeatable\\)" "" build --help)
|
||||||
check_process(0 "Usage: vbs test " "" test --help)
|
check_process(0 "Usage: vbs test " "" test --help)
|
||||||
check_process(2 "" "invalid --test-timeout" test --test-timeout 0)
|
check_process(2 "" "invalid --test-timeout" test --test-timeout 0)
|
||||||
|
check_process(0 "Usage: vbs test .*--repeat" "" test --help)
|
||||||
|
check_process(0 "--shuffle" "" test --help)
|
||||||
|
check_process(0 "--stop-on-failure" "" test --help)
|
||||||
|
check_process(0 "Usage: vbs explain " "" explain --help)
|
||||||
|
check_process(0 "--format" "" explain --help)
|
||||||
|
check_process(2 "" "unsupported --format" explain --format xml)
|
||||||
|
check_process(0 "--trace" "" build --help)
|
||||||
|
check_process(0 "Usage: vbs completions " "" completions --help)
|
||||||
|
check_process(2 "" "unsupported --shell" completions --shell tcsh)
|
||||||
|
check_process(0 "Usage: vbs man " "" man --help)
|
||||||
|
check_process(0 "--from" "" migrate --help)
|
||||||
|
check_process(2 "" "invalid value 'bazel' for '--from'" migrate --from bazel)
|
||||||
|
check_process(2 "" "invalid value 'bogus' for '--template'" init --template bogus)
|
||||||
|
check_process(0 "--template" "" init --help)
|
||||||
|
check_process(0 "--export" "" presets --help)
|
||||||
|
check_process(2 "" "invalid --repeat mode" test --repeat bogus)
|
||||||
|
check_process(2 "" "invalid --repeat count" test --repeat until-pass:0)
|
||||||
|
check_process(2 "" "invalid --retry value" test --retry 99)
|
||||||
|
check_process(2 "" "invalid --shuffle-seed" test --shuffle --shuffle-seed abc)
|
||||||
check_process(0 "Usage: vbs init " "" init --help)
|
check_process(0 "Usage: vbs init " "" init --help)
|
||||||
check_process(0 "Usage: vbs clean " "" clean --help)
|
check_process(0 "Usage: vbs clean " "" clean --help)
|
||||||
check_process(0 "Usage: vbs doctor " "" doctor --help)
|
check_process(0 "Usage: vbs doctor " "" doctor --help)
|
||||||
|
|||||||
@@ -3475,6 +3475,11 @@ VOID_TEST(FullV1Tests, ide_integration_compdb_build_cpp_and_editor_configs_end_t
|
|||||||
// Check every generated file exists and every JSON file parses strictly.
|
// Check every generated file exists and every JSON file parses strictly.
|
||||||
Void::Testing::expect(std::filesystem::exists(proj / ".clangd"));
|
Void::Testing::expect(std::filesystem::exists(proj / ".clangd"));
|
||||||
Void::Testing::expect(std::filesystem::exists(proj / ".idea" / "customTargets.xml"));
|
Void::Testing::expect(std::filesystem::exists(proj / ".idea" / "customTargets.xml"));
|
||||||
|
// JetBrains run configurations for the scaffolded targets (shell configs).
|
||||||
|
Void::Testing::expect(std::filesystem::exists(proj / ".idea" / "runConfigurations" /
|
||||||
|
"vbs_build_ide_demo.xml"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(proj / ".idea" / "runConfigurations" /
|
||||||
|
"vbs_test_ide_demo_tests.xml"));
|
||||||
for (const auto &json_file : {proj / ".vscode" / "tasks.json", proj / ".vscode" / "launch.json",
|
for (const auto &json_file : {proj / ".vscode" / "tasks.json", proj / ".vscode" / "launch.json",
|
||||||
proj / ".vscode" / "settings.json", proj / ".zed" / "tasks.json",
|
proj / ".vscode" / "settings.json", proj / ".zed" / "tasks.json",
|
||||||
proj / ".zed" / "debug.json"}) {
|
proj / ".zed" / "debug.json"}) {
|
||||||
@@ -3800,3 +3805,545 @@ class DemoPkg(ConanFile):
|
|||||||
Void::Testing::expect(found_install_output);
|
Void::Testing::expect(found_install_output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Test-runner parity: repetition controls, shuffle and stop-on-failure ===
|
||||||
|
VOID_TEST(FullV1Tests, test_repeat_retry_shuffle_and_stop_on_failure) {
|
||||||
|
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_repeat_"};
|
||||||
|
const auto proj = tmp / "proj";
|
||||||
|
const auto bdir = tmp / "build";
|
||||||
|
|
||||||
|
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||||
|
void build(Void::Build::Project &p) {
|
||||||
|
p.test("t_fail")
|
||||||
|
.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||||
|
.sources({"tests/fail.cpp"});
|
||||||
|
p.test("t_pass")
|
||||||
|
.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||||
|
.sources({"tests/pass.cpp"});
|
||||||
|
p.test("t_flaky")
|
||||||
|
.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||||
|
.sources({"tests/flaky.cpp"});
|
||||||
|
}
|
||||||
|
)cpp");
|
||||||
|
write_file(proj / "tests" / "fail.cpp",
|
||||||
|
"#include <fstream>\n"
|
||||||
|
"int main() {\n"
|
||||||
|
" std::ofstream log{\"order.log\", std::ios::app};\n"
|
||||||
|
" log << \"fail\\n\";\n"
|
||||||
|
" return 1;\n"
|
||||||
|
"}\n");
|
||||||
|
write_file(proj / "tests" / "pass.cpp",
|
||||||
|
"#include <fstream>\n"
|
||||||
|
"int main() {\n"
|
||||||
|
" std::ofstream log{\"order.log\", std::ios::app};\n"
|
||||||
|
" log << \"pass\\n\";\n"
|
||||||
|
" return 0;\n"
|
||||||
|
"}\n");
|
||||||
|
// Fails on its first invocation, passes afterwards (state in the project directory,
|
||||||
|
// which is the working directory of every test run).
|
||||||
|
write_file(proj / "tests" / "flaky.cpp",
|
||||||
|
"#include <fstream>\n"
|
||||||
|
"#include <string>\n"
|
||||||
|
"int main() {\n"
|
||||||
|
" int prior = 0;\n"
|
||||||
|
" { std::ifstream in{\"flaky.count\"}; std::string line; while (std::getline(in, line)) ++prior; }\n"
|
||||||
|
" { std::ofstream out{\"flaky.count\", std::ios::app}; out << \"run\\n\"; }\n"
|
||||||
|
" { std::ofstream log{\"order.log\", std::ios::app}; log << \"flaky\\n\"; }\n"
|
||||||
|
" return prior == 0 ? 1 : 0;\n"
|
||||||
|
"}\n");
|
||||||
|
|
||||||
|
auto run_vbs = [&](std::vector<std::string> args) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = std::move(args);
|
||||||
|
req.timeout = std::chrono::seconds{300};
|
||||||
|
return Platform::run_supervised(req);
|
||||||
|
};
|
||||||
|
const auto count_in_log = [&](std::string_view needle) {
|
||||||
|
const auto text = Void::FileSystem::read_file(proj / "order.log");
|
||||||
|
if (!text) {
|
||||||
|
return std::size_t{0};
|
||||||
|
}
|
||||||
|
std::size_t count = 0;
|
||||||
|
for (std::size_t pos = text->find(needle); pos != std::string::npos;
|
||||||
|
pos = text->find(needle, pos + needle.size())) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
const auto reset_logs = [&] {
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::remove(proj / "order.log", ec);
|
||||||
|
std::filesystem::remove(proj / "flaky.count", ec);
|
||||||
|
};
|
||||||
|
|
||||||
|
// until-pass: the flaky test must be retried until it passes.
|
||||||
|
reset_logs();
|
||||||
|
auto until_pass = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--target", "t_flaky", "--jobs", "1", "--repeat", "until-pass:3"});
|
||||||
|
Void::Testing::expect(until_pass.has_value() && until_pass->succeeded());
|
||||||
|
Void::Testing::expect_eq(count_in_log("flaky"), std::size_t{2});
|
||||||
|
|
||||||
|
// --retry: the same recovery without a repeat policy.
|
||||||
|
reset_logs();
|
||||||
|
auto retry = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--target", "t_flaky", "--jobs", "1", "--retry", "2"});
|
||||||
|
Void::Testing::expect(retry.has_value() && retry->succeeded());
|
||||||
|
Void::Testing::expect_eq(count_in_log("flaky"), std::size_t{2});
|
||||||
|
|
||||||
|
// until-fail: a passing test must run N times.
|
||||||
|
reset_logs();
|
||||||
|
auto until_fail = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--target", "t_pass", "--jobs", "1", "--repeat", "until-fail:3"});
|
||||||
|
Void::Testing::expect(until_fail.has_value() && until_fail->succeeded());
|
||||||
|
Void::Testing::expect_eq(count_in_log("pass"), std::size_t{3});
|
||||||
|
|
||||||
|
// --shuffle with a fixed seed is deterministic and still runs every selected test.
|
||||||
|
reset_logs();
|
||||||
|
auto shuffled = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--target", "t_pass", "--target", "t_flaky", "--jobs", "1",
|
||||||
|
"--shuffle", "--shuffle-seed", "42", "--retry", "1"});
|
||||||
|
Void::Testing::expect(shuffled.has_value() && shuffled->succeeded());
|
||||||
|
const auto first_order = Void::FileSystem::read_file(proj / "order.log");
|
||||||
|
Void::Testing::require(first_order.has_value());
|
||||||
|
reset_logs();
|
||||||
|
auto shuffled_again = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--target", "t_pass", "--target", "t_flaky", "--jobs", "1",
|
||||||
|
"--shuffle", "--shuffle-seed", "42", "--retry", "1"});
|
||||||
|
Void::Testing::expect(shuffled_again.has_value() && shuffled_again->succeeded());
|
||||||
|
const auto second_order = Void::FileSystem::read_file(proj / "order.log");
|
||||||
|
Void::Testing::require(second_order.has_value());
|
||||||
|
Void::Testing::expect(*first_order == *second_order);
|
||||||
|
|
||||||
|
// --stop-on-failure: t_fail is declared first, so with one job nothing else runs.
|
||||||
|
reset_logs();
|
||||||
|
auto stopped = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--jobs", "1", "--stop-on-failure"});
|
||||||
|
Void::Testing::expect(stopped.has_value() && !stopped->succeeded());
|
||||||
|
Void::Testing::expect_eq(count_in_log("fail"), std::size_t{1});
|
||||||
|
Void::Testing::expect_eq(count_in_log("pass"), std::size_t{0});
|
||||||
|
Void::Testing::expect_eq(count_in_log("flaky"), std::size_t{0});
|
||||||
|
|
||||||
|
// Invalid values are rejected before any project work.
|
||||||
|
auto bad_repeat = run_vbs({"test", "--project", proj.string(), "--repeat", "bogus"});
|
||||||
|
Void::Testing::expect(bad_repeat.has_value() && bad_repeat->exit_code == 2);
|
||||||
|
auto bad_retry = run_vbs({"test", "--project", proj.string(), "--retry", "99"});
|
||||||
|
Void::Testing::expect(bad_retry.has_value() && bad_retry->exit_code == 2);
|
||||||
|
auto bad_seed = run_vbs({"test", "--project", proj.string(), "--shuffle", "--shuffle-seed",
|
||||||
|
"not-a-number"});
|
||||||
|
Void::Testing::expect(bad_seed.has_value() && bad_seed->exit_code == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Explainability: why would an action run, and Chrome-trace output ===
|
||||||
|
VOID_TEST(FullV1Tests, explain_reports_stale_actions_and_trace_writes_chrome_json) {
|
||||||
|
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_explain_"};
|
||||||
|
const auto proj = tmp / "proj";
|
||||||
|
const auto bdir = tmp / "build";
|
||||||
|
|
||||||
|
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||||
|
void build(Void::Build::Project &p) {
|
||||||
|
auto lib = p.static_library("demo").sources({"src/a.cpp"});
|
||||||
|
p.executable("app").sources({"src/main.cpp"}).link(lib);
|
||||||
|
}
|
||||||
|
)cpp");
|
||||||
|
write_file(proj / "src" / "hdr.hpp", "#define EXPECT 3\nint a();\n");
|
||||||
|
write_file(proj / "src" / "a.cpp", "#include \"hdr.hpp\"\nint a() { return 1; }\n");
|
||||||
|
write_file(proj / "src" / "main.cpp",
|
||||||
|
"#include \"hdr.hpp\"\nint main() { return a() + 2 == EXPECT ? 0 : 1; }\n");
|
||||||
|
|
||||||
|
auto run_vbs = [&](std::vector<std::string> args) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = std::move(args);
|
||||||
|
req.timeout = std::chrono::seconds{300};
|
||||||
|
return Platform::run_supervised(req);
|
||||||
|
};
|
||||||
|
const auto json_number = [](const Void::Json::Strict::Value &value) {
|
||||||
|
if (const auto *integer = std::get_if<std::int64_t>(&value.value)) {
|
||||||
|
return static_cast<long long>(*integer);
|
||||||
|
}
|
||||||
|
if (const auto *real = std::get_if<double>(&value.value)) {
|
||||||
|
return static_cast<long long>(*real);
|
||||||
|
}
|
||||||
|
return -1LL;
|
||||||
|
};
|
||||||
|
const auto json_field = [](const Void::Json::Strict::Value::Object &object,
|
||||||
|
std::string_view key) -> const Void::Json::Strict::Value * {
|
||||||
|
const auto it = object.find(std::string{key});
|
||||||
|
return it == object.end() ? nullptr : &it->second;
|
||||||
|
};
|
||||||
|
|
||||||
|
// First build: everything executes.
|
||||||
|
auto built = run_vbs({"build", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--jobs", "2"});
|
||||||
|
Void::Testing::expect(built.has_value() && built->succeeded());
|
||||||
|
|
||||||
|
// Nothing changed: every action is up to date.
|
||||||
|
auto explained = run_vbs({"explain", "--project", proj.string(), "--build-dir",
|
||||||
|
bdir.string(), "--format", "json"});
|
||||||
|
Void::Testing::expect(explained.has_value() && explained->succeeded());
|
||||||
|
if (explained) {
|
||||||
|
auto parsed = Void::Json::Strict::parse(explained->stdout_data);
|
||||||
|
Void::Testing::require(parsed.has_value());
|
||||||
|
const auto *root = std::get_if<Void::Json::Strict::Value::Object>(&parsed->value);
|
||||||
|
Void::Testing::require(root != nullptr);
|
||||||
|
const auto *total = json_field(*root, "total");
|
||||||
|
const auto *would_run = json_field(*root, "would_run");
|
||||||
|
Void::Testing::require(total != nullptr && would_run != nullptr);
|
||||||
|
Void::Testing::expect(json_number(*total) >= 3);
|
||||||
|
Void::Testing::expect_eq(json_number(*would_run), 0LL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A changed header must be reported as work to do.
|
||||||
|
write_file(proj / "src" / "hdr.hpp", "#define EXPECT 4\nint a();\n");
|
||||||
|
auto stale = run_vbs({"explain", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--format", "json"});
|
||||||
|
Void::Testing::expect(stale.has_value() && stale->succeeded());
|
||||||
|
if (stale) {
|
||||||
|
auto parsed = Void::Json::Strict::parse(stale->stdout_data);
|
||||||
|
Void::Testing::require(parsed.has_value());
|
||||||
|
const auto *root = std::get_if<Void::Json::Strict::Value::Object>(&parsed->value);
|
||||||
|
Void::Testing::require(root != nullptr);
|
||||||
|
const auto *would_run = json_field(*root, "would_run");
|
||||||
|
Void::Testing::require(would_run != nullptr);
|
||||||
|
Void::Testing::expect(json_number(*would_run) >= 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text output names the reason.
|
||||||
|
auto text = run_vbs({"explain", "--project", proj.string(), "--build-dir", bdir.string()});
|
||||||
|
Void::Testing::expect(text.has_value() && text->succeeded());
|
||||||
|
if (text) {
|
||||||
|
Void::Testing::expect(text->stdout_data.find("would run") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// An unsupported format is rejected before any work.
|
||||||
|
auto bad = run_vbs({"explain", "--project", proj.string(), "--format", "xml"});
|
||||||
|
Void::Testing::expect(bad.has_value() && bad->exit_code == 2);
|
||||||
|
|
||||||
|
// The rebuild writes a Chrome trace with phases and per-action spans.
|
||||||
|
const auto trace_path = tmp / "trace.json";
|
||||||
|
auto traced = run_vbs({"build", "--project", proj.string(), "--build-dir", bdir.string(),
|
||||||
|
"--jobs", "2", "--trace", trace_path.string()});
|
||||||
|
Void::Testing::expect(traced.has_value() && traced->succeeded());
|
||||||
|
auto trace_text = Void::FileSystem::read_file(trace_path);
|
||||||
|
Void::Testing::require(trace_text.has_value());
|
||||||
|
auto trace = Void::Json::Strict::parse(*trace_text);
|
||||||
|
Void::Testing::require(trace.has_value());
|
||||||
|
const auto *trace_root = std::get_if<Void::Json::Strict::Value::Object>(&trace->value);
|
||||||
|
Void::Testing::require(trace_root != nullptr);
|
||||||
|
const auto *events = json_field(*trace_root, "traceEvents");
|
||||||
|
Void::Testing::require(events != nullptr);
|
||||||
|
const auto *event_array = std::get_if<Void::Json::Strict::Value::Array>(&events->value);
|
||||||
|
Void::Testing::require(event_array != nullptr);
|
||||||
|
Void::Testing::expect(event_array->size() >= 6);
|
||||||
|
bool saw_phase = false;
|
||||||
|
bool saw_action = false;
|
||||||
|
for (const auto &event : *event_array) {
|
||||||
|
const auto *object = std::get_if<Void::Json::Strict::Value::Object>(&event.value);
|
||||||
|
if (object == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto *category = json_field(*object, "cat");
|
||||||
|
const auto *phase = json_field(*object, "ph");
|
||||||
|
if (category == nullptr || phase == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto *category_text = std::get_if<std::string>(&category->value);
|
||||||
|
const auto *phase_text = std::get_if<std::string>(&phase->value);
|
||||||
|
if (category_text == nullptr || phase_text == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Void::Testing::expect(*phase_text == "X");
|
||||||
|
if (*category_text == "phase") {
|
||||||
|
saw_phase = true;
|
||||||
|
}
|
||||||
|
if (*category_text == "action" || *category_text == "cache") {
|
||||||
|
saw_action = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Void::Testing::expect(saw_phase);
|
||||||
|
Void::Testing::expect(saw_action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Cold-start performance: shared per-user descriptor and probe caches ===
|
||||||
|
VOID_TEST(FullV1Tests, shared_user_cache_reuses_descriptor_and_probes_across_build_dirs) {
|
||||||
|
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_shared_cache_"};
|
||||||
|
const auto proj = tmp / "proj";
|
||||||
|
const auto cache = tmp / "cache";
|
||||||
|
|
||||||
|
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||||
|
void build(Void::Build::Project &p) {
|
||||||
|
auto lib = p.static_library("demo").sources({"src/a.cpp"});
|
||||||
|
p.executable("app").sources({"src/main.cpp"}).link(lib);
|
||||||
|
}
|
||||||
|
)cpp");
|
||||||
|
write_file(proj / "src" / "a.cpp", "int a() { return 1; }\n");
|
||||||
|
write_file(proj / "src" / "main.cpp", "int a();\nint main() { return a() == 1 ? 0 : 1; }\n");
|
||||||
|
|
||||||
|
auto run_vbs = [&](const std::filesystem::path &build_dir, bool shared) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = {"build", "--project", proj.string(), "--build-dir", build_dir.string(),
|
||||||
|
"--jobs", "2"};
|
||||||
|
req.environment.set_vars["XDG_CACHE_HOME"] = cache.string();
|
||||||
|
if (!shared) {
|
||||||
|
req.environment.set_vars["VBS_SHARED_CACHE"] = "0";
|
||||||
|
}
|
||||||
|
req.timeout = std::chrono::seconds{300};
|
||||||
|
return Platform::run_supervised(req);
|
||||||
|
};
|
||||||
|
|
||||||
|
// First build in a fresh build directory compiles the descriptor and probes the toolchain.
|
||||||
|
auto first = run_vbs(tmp / "build-a", true);
|
||||||
|
Void::Testing::expect(first.has_value() && first->succeeded());
|
||||||
|
if (first) {
|
||||||
|
Void::Testing::expect((first->stdout_data + first->stderr_data).find("compiled") !=
|
||||||
|
std::string::npos);
|
||||||
|
}
|
||||||
|
Void::Testing::expect(std::filesystem::exists(cache / "vbs" / "descriptors"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(cache / "vbs" / "probes"));
|
||||||
|
|
||||||
|
// A second, independent build directory reuses both artifacts instead of recompiling.
|
||||||
|
auto second = run_vbs(tmp / "build-b", true);
|
||||||
|
Void::Testing::expect(second.has_value() && second->succeeded());
|
||||||
|
if (second) {
|
||||||
|
Void::Testing::expect((second->stdout_data + second->stderr_data)
|
||||||
|
.find("up to date (cached)") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Opting out keeps a build directory self-contained.
|
||||||
|
auto isolated = run_vbs(tmp / "build-c", false);
|
||||||
|
Void::Testing::expect(isolated.has_value() && isolated->succeeded());
|
||||||
|
if (isolated) {
|
||||||
|
Void::Testing::expect((isolated->stdout_data + isolated->stderr_data).find("compiled") !=
|
||||||
|
std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// === CLI surface: generated shell completions and man pages ===
|
||||||
|
VOID_TEST(FullV1Tests, completions_and_man_pages_are_generated_from_the_cli) {
|
||||||
|
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_completions_"};
|
||||||
|
|
||||||
|
auto run_vbs = [&](std::vector<std::string> args) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = std::move(args);
|
||||||
|
req.timeout = std::chrono::seconds{120};
|
||||||
|
return Platform::run_supervised(req);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto bash_script = run_vbs({"completions", "--shell", "bash"});
|
||||||
|
Void::Testing::expect(bash_script.has_value() && bash_script->succeeded());
|
||||||
|
if (bash_script) {
|
||||||
|
Void::Testing::expect(bash_script->stdout_data.find("_vbs_complete") != std::string::npos);
|
||||||
|
Void::Testing::expect(bash_script->stdout_data.find("complete -F _vbs_complete vbs") !=
|
||||||
|
std::string::npos);
|
||||||
|
Void::Testing::expect(bash_script->stdout_data.find("--project") != std::string::npos);
|
||||||
|
Void::Testing::expect(bash_script->stdout_data.find("\"compdb use\")") !=
|
||||||
|
std::string::npos);
|
||||||
|
// The generated script must be valid bash.
|
||||||
|
if (const auto bash = Platform::resolve_executable("bash"); bash) {
|
||||||
|
const auto script_path = tmp / "vbs.bash";
|
||||||
|
write_file(script_path, bash_script->stdout_data);
|
||||||
|
Platform::ProcessRequest check;
|
||||||
|
check.executable = *bash;
|
||||||
|
check.arguments = {"-n", script_path.string()};
|
||||||
|
check.timeout = std::chrono::seconds{30};
|
||||||
|
auto checked = Platform::run_supervised(check);
|
||||||
|
Void::Testing::expect(checked.has_value() && checked->succeeded());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto zsh_script = run_vbs({"completions", "--shell", "zsh"});
|
||||||
|
Void::Testing::expect(zsh_script.has_value() && zsh_script->succeeded());
|
||||||
|
if (zsh_script) {
|
||||||
|
Void::Testing::expect(zsh_script->stdout_data.find("#compdef vbs") != std::string::npos);
|
||||||
|
Void::Testing::expect(zsh_script->stdout_data.find("compadd") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto fish_script = run_vbs({"completions", "--shell", "fish"});
|
||||||
|
Void::Testing::expect(fish_script.has_value() && fish_script->succeeded());
|
||||||
|
if (fish_script) {
|
||||||
|
Void::Testing::expect(fish_script->stdout_data.find("complete -c vbs") != std::string::npos);
|
||||||
|
Void::Testing::expect(fish_script->stdout_data.find("__vbs_path") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto bad_shell = run_vbs({"completions", "--shell", "tcsh"});
|
||||||
|
Void::Testing::expect(bad_shell.has_value() && bad_shell->exit_code == 2);
|
||||||
|
|
||||||
|
// Root man page on stdout.
|
||||||
|
auto man_root = run_vbs({"man"});
|
||||||
|
Void::Testing::expect(man_root.has_value() && man_root->succeeded());
|
||||||
|
if (man_root) {
|
||||||
|
Void::Testing::expect(man_root->stdout_data.find(".TH vbs 1") != std::string::npos);
|
||||||
|
Void::Testing::expect(man_root->stdout_data.find(".SH COMMANDS") != std::string::npos);
|
||||||
|
Void::Testing::expect(man_root->stdout_data.find(".SH OPTIONS") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A full page set on disk, including nested commands.
|
||||||
|
const auto man_dir = tmp / "man";
|
||||||
|
auto man_pages = run_vbs({"man", "--output", man_dir.string()});
|
||||||
|
Void::Testing::expect(man_pages.has_value() && man_pages->succeeded());
|
||||||
|
Void::Testing::expect(std::filesystem::exists(man_dir / "vbs.1"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(man_dir / "vbs-build.1"));
|
||||||
|
Void::Testing::expect(std::filesystem::exists(man_dir / "vbs-compdb-use.1"));
|
||||||
|
std::size_t page_count = 0;
|
||||||
|
std::error_code ec;
|
||||||
|
for (const auto &entry : std::filesystem::directory_iterator(man_dir, ec)) {
|
||||||
|
if (entry.path().extension() == ".1") {
|
||||||
|
++page_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Void::Testing::expect(page_count >= 20);
|
||||||
|
auto nested = Void::FileSystem::read_file(man_dir / "vbs-compdb-use.1");
|
||||||
|
Void::Testing::require(nested.has_value());
|
||||||
|
Void::Testing::expect(nested->find(".TH vbs\\-compdb\\-use 1") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Migration breadth: meson.build -> build.cpp scaffold ===
|
||||||
|
VOID_TEST(FullV1Tests, meson_build_import_renders_build_cpp_scaffold) {
|
||||||
|
Void::FileSystem::TempDir tmp{"vbs_meson_migrate_"};
|
||||||
|
write_file(tmp / "meson.build", R"meson(
|
||||||
|
project('bench', 'cpp', version : '1.0')
|
||||||
|
|
||||||
|
bench_sources = files('src/f1.cpp', 'src/f2.cpp')
|
||||||
|
|
||||||
|
lib = static_library('bench_lib', bench_sources,
|
||||||
|
include_directories : include_directories('include'))
|
||||||
|
|
||||||
|
app_sources = ['src/main.cpp']
|
||||||
|
executable('bench_app', app_sources,
|
||||||
|
link_with : lib,
|
||||||
|
dependencies : [dependency('zlib')],
|
||||||
|
install : true,
|
||||||
|
install_dir : 'bin')
|
||||||
|
|
||||||
|
# Not translated, must be reported.
|
||||||
|
custom_target('gen', output : 'gen.cpp', command : ['gen.sh'])
|
||||||
|
)meson");
|
||||||
|
|
||||||
|
auto imported = Config::import_meson_build(tmp / "meson.build", tmp.path());
|
||||||
|
Void::Testing::require(imported.has_value());
|
||||||
|
Void::Testing::expect_eq(imported->project_name, std::string{"bench"});
|
||||||
|
Void::Testing::expect_eq(imported->targets.size(), std::size_t{2});
|
||||||
|
|
||||||
|
const auto &library = imported->targets.at(0);
|
||||||
|
Void::Testing::expect_eq(library.name, std::string{"bench_lib"});
|
||||||
|
Void::Testing::expect_eq(library.kind, std::string{"static"});
|
||||||
|
Void::Testing::expect_eq(library.sources.size(), std::size_t{2});
|
||||||
|
Void::Testing::expect_eq(library.sources.at(0), std::string{"src/f1.cpp"});
|
||||||
|
Void::Testing::expect_eq(library.private_includes.at(0), std::string{"include"});
|
||||||
|
|
||||||
|
const auto &app = imported->targets.at(1);
|
||||||
|
Void::Testing::expect_eq(app.name, std::string{"bench_app"});
|
||||||
|
Void::Testing::expect_eq(app.kind, std::string{"executable"});
|
||||||
|
Void::Testing::expect_eq(app.sources.at(0), std::string{"src/main.cpp"});
|
||||||
|
Void::Testing::expect_eq(app.private_links.at(0), std::string{"bench_lib"});
|
||||||
|
Void::Testing::expect(app.installed);
|
||||||
|
Void::Testing::expect_eq(app.install_destination, std::string{"bin"});
|
||||||
|
|
||||||
|
bool saw_dependency_note = false;
|
||||||
|
bool saw_custom_target_note = false;
|
||||||
|
for (const auto ¬e : imported->notes) {
|
||||||
|
if (note.find("zlib") != std::string::npos) {
|
||||||
|
saw_dependency_note = true;
|
||||||
|
}
|
||||||
|
if (note.find("custom_target") != std::string::npos) {
|
||||||
|
saw_custom_target_note = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Void::Testing::expect(saw_dependency_note);
|
||||||
|
Void::Testing::expect(saw_custom_target_note);
|
||||||
|
|
||||||
|
const std::string rendered = Config::render_build_cpp(*imported);
|
||||||
|
Void::Testing::expect(rendered.find("static_library(\"bench_lib\")") != std::string::npos);
|
||||||
|
Void::Testing::expect(rendered.find("executable(\"bench_app\")") != std::string::npos);
|
||||||
|
Void::Testing::expect(rendered.find(".link(t_bench_lib") != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Project templates: `vbs init --template` shapes build and test ===
|
||||||
|
VOID_TEST(FullV1Tests, init_templates_scaffold_buildable_projects) {
|
||||||
|
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_init_templates_"};
|
||||||
|
auto run_vbs = [&](std::vector<std::string> args) {
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = std::move(args);
|
||||||
|
req.timeout = std::chrono::seconds{600};
|
||||||
|
return Platform::run_supervised(req);
|
||||||
|
};
|
||||||
|
for (const char *shape : {"app", "library", "header-only", "shared"}) {
|
||||||
|
const auto dir = tmp / shape;
|
||||||
|
auto initialized = run_vbs({"init", "--dir", dir.string(), "--name", "demo",
|
||||||
|
"--template", shape});
|
||||||
|
Void::Testing::expect(initialized.has_value() && initialized->succeeded());
|
||||||
|
auto built = run_vbs({"test", "--project", dir.string(),
|
||||||
|
"--build-dir", (dir / "build").string(), "--jobs", "2"});
|
||||||
|
Void::Testing::expect(built.has_value() && built->succeeded());
|
||||||
|
if (built && !built->succeeded()) {
|
||||||
|
std::cerr << "template '" << shape << "' failed:\n" << built->stderr_data << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto bad = run_vbs({"init", "--dir", (tmp / "bogus").string(), "--template", "bogus"});
|
||||||
|
Void::Testing::expect(bad.has_value() && bad->exit_code == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Presets export: VBS profiles -> CMakePresets.json (round-trips through the importer) ===
|
||||||
|
VOID_TEST(FullV1Tests, presets_export_round_trips_through_the_importer) {
|
||||||
|
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_presets_export_"};
|
||||||
|
const auto proj = tmp / "proj";
|
||||||
|
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||||
|
void build(Void::Build::Project &p) {
|
||||||
|
p.executable("app").sources({"src/main.cpp"});
|
||||||
|
}
|
||||||
|
)cpp");
|
||||||
|
write_file(proj / "src" / "main.cpp", "int main() { return 0; }\n");
|
||||||
|
const auto exported = tmp / "CMakePresets.json";
|
||||||
|
Platform::ProcessRequest req;
|
||||||
|
req.executable = vbs_bin;
|
||||||
|
req.arguments = {"presets", "--project", proj.string(), "--export", exported.string()};
|
||||||
|
req.timeout = std::chrono::seconds{300};
|
||||||
|
auto res = Platform::run_supervised(req);
|
||||||
|
Void::Testing::expect(res.has_value() && res->succeeded());
|
||||||
|
auto text = Void::FileSystem::read_file(exported);
|
||||||
|
Void::Testing::require(text.has_value());
|
||||||
|
Void::Testing::expect(text->find("\"configurePresets\"") != std::string::npos);
|
||||||
|
Void::Testing::expect(text->find("\"CMAKE_BUILD_TYPE\"") != std::string::npos);
|
||||||
|
|
||||||
|
// The exported file must be readable by the importer.
|
||||||
|
auto imported = Config::load_cmake_presets(exported, proj);
|
||||||
|
Void::Testing::require(imported.has_value());
|
||||||
|
Void::Testing::expect(!imported->empty());
|
||||||
|
for (const auto &preset : *imported) {
|
||||||
|
Void::Testing::expect(preset.build_dir.has_value());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2264,10 +2264,71 @@ VOID_TEST(RegistryTests, worker_action_queue_enqueue_lease_and_complete) {
|
|||||||
Void::Testing::expect(listing.has_value() && listing->status == 200);
|
Void::Testing::expect(listing.has_value() && listing->status == 200);
|
||||||
if (listing) {
|
if (listing) {
|
||||||
Void::Testing::expect(listing->body.find(key_a) != std::string::npos);
|
Void::Testing::expect(listing->body.find(key_a) != std::string::npos);
|
||||||
|
Void::Testing::expect(listing->body.find("\"attempts\"") != std::string::npos);
|
||||||
}
|
}
|
||||||
(*svc)->stop_http();
|
(*svc)->stop_http();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leases are retried, but only up to a budget: a queued action that never reports a
|
||||||
|
// result is abandoned (dead-lettered) instead of being leased forever.
|
||||||
|
VOID_TEST(RegistryTests, worker_queue_abandons_actions_after_repeated_leases) {
|
||||||
|
Void::FileSystem::TempDir tmp{"vbs_queue_attempts_"};
|
||||||
|
RegistryConfig cfg;
|
||||||
|
cfg.data_dir = tmp / "reg_data";
|
||||||
|
cfg.bind_address = "127.0.0.1";
|
||||||
|
cfg.port = 0;
|
||||||
|
cfg.bootstrap_admin_user = "admin";
|
||||||
|
cfg.bootstrap_admin_password = "admin_pw";
|
||||||
|
auto svc = RegistryService::open(cfg);
|
||||||
|
Void::Testing::expect(svc.has_value());
|
||||||
|
if (!svc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Void::Testing::expect((*svc)->create_user("q_pub", "q_pass", Role::Publisher).has_value());
|
||||||
|
auto tok = (*svc)->create_token("q_pub", "q", {"read", "publish"});
|
||||||
|
Void::Testing::require(tok.has_value());
|
||||||
|
Void::Testing::expect((*svc)->start_http().has_value());
|
||||||
|
const auto port = (*svc)->bound_port();
|
||||||
|
const std::map<std::string, std::string, std::less<>> auth{{"Authorization", "Bearer " + *tok}};
|
||||||
|
|
||||||
|
const std::string key = Util::sha256_hex("poison-action");
|
||||||
|
auto enqueued = send_loopback_http(port, "POST", "/api/v1/queue", auth,
|
||||||
|
"{\"action_keys\":[\"" + key + "\"]}");
|
||||||
|
Void::Testing::expect(enqueued.has_value() && enqueued->status == 200);
|
||||||
|
auto registered = send_loopback_http(port, "POST", "/api/v1/workers", auth, "{}");
|
||||||
|
Void::Testing::require(registered.has_value() && registered->status == 201);
|
||||||
|
const std::string worker_id = extract_json_str(registered->body, "worker_id");
|
||||||
|
|
||||||
|
// Five leases that are never completed (each lease expires after one second).
|
||||||
|
int leases = 0;
|
||||||
|
for (int attempt = 1; attempt <= 5; ++attempt) {
|
||||||
|
auto leased = send_loopback_http(port, "POST", "/api/v1/queue/lease", auth,
|
||||||
|
"{\"worker_id\":\"" + worker_id +
|
||||||
|
"\",\"lease_seconds\":1}");
|
||||||
|
Void::Testing::expect(leased.has_value() && leased->status == 200);
|
||||||
|
if (!leased || leased->status != 200) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++leases;
|
||||||
|
Void::Testing::expect(leased->body.find("\"attempt\":" + std::to_string(attempt)) !=
|
||||||
|
std::string::npos);
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds{1100});
|
||||||
|
}
|
||||||
|
Void::Testing::expect_eq(leases, 5);
|
||||||
|
|
||||||
|
// The sixth lease finds nothing: the action was abandoned, not leased again.
|
||||||
|
auto exhausted = send_loopback_http(port, "POST", "/api/v1/queue/lease", auth,
|
||||||
|
"{\"worker_id\":\"" + worker_id +
|
||||||
|
"\",\"lease_seconds\":60}");
|
||||||
|
Void::Testing::expect(exhausted.has_value() && exhausted->status == 404);
|
||||||
|
auto listing = send_loopback_http(port, "GET", "/api/v1/queue", auth);
|
||||||
|
Void::Testing::require(listing.has_value() && listing->status == 200);
|
||||||
|
Void::Testing::expect(listing->body.find(key) != std::string::npos); // in "abandoned"
|
||||||
|
Void::Testing::expect(listing->body.find("\"abandoned\":[\"" + key + "\"]") !=
|
||||||
|
std::string::npos);
|
||||||
|
(*svc)->stop_http();
|
||||||
|
}
|
||||||
|
|
||||||
// `vbs test --cdash-output FILE --cdash URL`: writes a CDash Test.xml report and submits it as
|
// `vbs test --cdash-output FILE --cdash URL`: writes a CDash Test.xml report and submits it as
|
||||||
// multipart/form-data to submit.php (captured by a loopback HTTP server).
|
// multipart/form-data to submit.php (captured by a loopback HTTP server).
|
||||||
VOID_TEST(RegistryTests, cdash_test_report_output_and_submission) {
|
VOID_TEST(RegistryTests, cdash_test_report_output_and_submission) {
|
||||||
|
|||||||
Reference in new issue
Block a user