From 83ec08390f69a77a1250417e0794df25cf4fbb60 Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Fri, 4 Dec 2026 23:42:50 +0300 Subject: [PATCH] refactor: build from conventions, adopt ConsoleLogger, and colorize TTY output --- CMakeLists.txt | 9 ++- build.cpp | 54 +++---------- cmake/BootstrapConfig.hpp.in | 2 +- cmake/VoidDependency.cmake | 2 +- docs/SDK.md | 2 +- docs/VOIDLIBRARY_UPSTREAM_REQUESTS.md | 6 +- docs/agent-workflow/STATE.md | 7 ++ docs/agent-workflow/TASKS.md | 2 + docs/agent-workflow/VERIFICATION.md | 20 +++++ docs/roadmap/README.md | 2 +- recipes/SelfHost/VbsSelfHostRecipe.cpp | 55 ++----------- registry/{service => cli}/Main.cpp | 0 {src => sdk}/Build.cpp | 0 {src/Util => sdk}/Json.cpp | 0 src/Config/Frontend.cpp | 2 +- src/Graph/Graph.cpp | 18 ++++- src/Main.cpp | 104 +++++++++++++++++-------- src/Package/Fetch.cpp | 18 +++-- src/Provider/Provider.cpp | 4 +- src/Watch/Linux/Watcher.cpp | 2 +- tests/DescribeContracts.cmake | 4 +- tests/ExampleContexts.cpp | 2 +- tests/SelfHostTests.cpp | 8 +- 23 files changed, 172 insertions(+), 151 deletions(-) rename registry/{service => cli}/Main.cpp (100%) rename {src => sdk}/Build.cpp (100%) rename {src/Util => sdk}/Json.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc42e27..2a0ed45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,8 @@ target_compile_features(VoidBuild_Options INTERFACE cxx_std_26) target_compile_options(VoidBuild_Options INTERFACE -freflection -Wall -Wextra -Wpedantic) add_library(VoidBuild_Sdk STATIC - src/Build.cpp - src/Util/Json.cpp) + sdk/Build.cpp + sdk/Json.cpp) add_library(Void::BuildSdk ALIAS VoidBuild_Sdk) target_include_directories(VoidBuild_Sdk PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(VoidBuild_Sdk PUBLIC VoidBuild_Options PRIVATE Void::Unicode) @@ -82,7 +82,8 @@ target_link_libraries(VoidBuild_Core PUBLIC Void::Async Void::Algorithms Void::Crypto - Void::Archive) + Void::Archive + Void::Log) target_compile_definitions(VoidBuild_Core PUBLIC VBS_HAS_VOID_CRYPTO=1 VBS_HAS_VOID_ARCHIVE=1) if(VBS_HAS_VOID_SQLITE) target_link_libraries(VoidBuild_Core PUBLIC Void::Sqlite) @@ -106,7 +107,7 @@ add_executable(vbs src/Main.cpp) target_include_directories(vbs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated") target_link_libraries(vbs PRIVATE Void::BuildCore) -add_executable(vbs-registry registry/service/Main.cpp) +add_executable(vbs-registry registry/cli/Main.cpp) target_include_directories(vbs-registry PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated") target_link_libraries(vbs-registry PRIVATE Void::BuildRegistry) diff --git a/build.cpp b/build.cpp index b9d74ea..a088a46 100644 --- a/build.cpp +++ b/build.cpp @@ -8,12 +8,15 @@ void build(Void::Build::Project &project) { .git("https://git.faumaray.com/Void/VoidLibrary.git", Void::Build::Commit{"0002e74a7da94a756f55a4a5574d20b77736c185"}) .native_builder({{"VOID_ENABLED_MODULES", - "Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing"}, + "Configuration;Text;Unicode;Async;Algorithms;Crypto;Archive;Testing;Log"}, {"BUILD_SHARED_LIBS", false}}); + // Source membership comes from conventions and globs, not explicit file lists: + // sdk/ is the declaration SDK, src/ + recipes/ are the native engine, registry/service/ + // is the registry library. auto sdk = project.static_library("VoidBuildSdk"); sdk.cxx_standard(Void::Build::CxxStandard::Cxx26) - .sources({"src/Build.cpp", "src/Util/Json.cpp"}) + .sources(project.glob("sdk/*.cpp")) .include_directory("include", Void::Build::Visibility::Public); BuildSupport::compiler_warnings(sdk, ctx); if (ctx.compiler == Void::Build::CompilerFamily::Gcc) { @@ -22,42 +25,8 @@ void build(Void::Build::Project &project) { auto core = project.static_library("VoidBuildCore"); core.cxx_standard(Void::Build::CxxStandard::Cxx26) - .sources({ - "src/Util/Sha256.cpp", - "src/Platform/Linux/FileOps.cpp", - "src/Platform/Linux/ProcessSupervisor.cpp", - "src/Toolchain/Driver.cpp", - "src/Snapshot/Snapshot.cpp", - "src/State/StateStore.cpp", - "src/State/RemoteCache.cpp", - "src/Graph/Graph.cpp", - "src/Execution/Scheduler.cpp", - "src/Config/BuildTree.cpp", - "src/Config/Frontend.cpp", - "src/Config/Scaffold.cpp", - "src/Daemon/Daemon.cpp", - "src/Editor/CompDb.cpp", - "src/Watch/Linux/Watcher.cpp", - "src/Package/Toml.cpp", - "src/Package/Solver.cpp", - "src/Package/Lockfile.cpp", - "src/Package/Archive.cpp", - "src/Package/Fetch.cpp", - "src/Package/RegistryClient.cpp", - "src/Package/Resolver.cpp", - "src/Provider/Provider.cpp", - "src/Provider/Translator.cpp", - "src/Install/Installer.cpp", - "src/Bridge/CMakeBridge.cpp", - "src/Modules/ModuleScanner.cpp", - "src/SelfHost/TestRegistryGen.cpp", - "src/Provenance/Sbom.cpp", - "src/Provenance/Signing.cpp", - "src/Provenance/Verification.cpp", - "src/Provenance/TrustedKeys.cpp", - "recipes/VoidLibrary/VoidLibraryRecipe.cpp", - "recipes/SelfHost/VbsSelfHostRecipe.cpp", - }) + .sources(project.glob("src/**/*.cpp")) + .sources(project.glob("recipes/**/*.cpp")) .include_directory("include", Void::Build::Visibility::Public) .include_directory("recipes", Void::Build::Visibility::Public) .include_directory("$GEN/include", Void::Build::Visibility::Private) @@ -70,7 +39,8 @@ void build(Void::Build::Project &project) { .link(library.target("Void::Async"), Void::Build::Visibility::Public) .link(library.target("Void::Algorithms"), Void::Build::Visibility::Public) .link(library.target("Void::Crypto"), Void::Build::Visibility::Public) - .link(library.target("Void::Archive"), Void::Build::Visibility::Public); + .link(library.target("Void::Archive"), Void::Build::Visibility::Public) + .link(library.target("Void::Log"), Void::Build::Visibility::Public); BuildSupport::compiler_warnings(core, ctx); // Generate profile-isolated BootstrapConfig.hpp inside $GEN/include/Void/Build/. @@ -91,7 +61,7 @@ void build(Void::Build::Project &project) { "inline constexpr std::string_view source_dir = \"$PROJECT_ROOT\";\n" "inline constexpr std::string_view binary_dir = \"\";\n" "inline constexpr std::string_view sdk_include_dir = \"$PROJECT_ROOT/include\";\n" - "inline constexpr std::string_view sdk_source_dir = \"$PROJECT_ROOT/src\";\n" + "inline constexpr std::string_view sdk_source_dir = \"$PROJECT_ROOT/sdk\";\n" "}\n" "EOF\n"; @@ -112,14 +82,14 @@ void build(Void::Build::Project &project) { auto registry_lib = project.static_library("VoidBuildRegistry"); registry_lib.cxx_standard(Void::Build::CxxStandard::Cxx26) - .sources({"registry/service/HttpServer.cpp", "registry/service/RegistryService.cpp"}) + .sources(project.glob("registry/service/*.cpp")) .include_directory("registry/include", Void::Build::Visibility::Public) .link(core, Void::Build::Visibility::Public); BuildSupport::compiler_warnings(registry_lib, ctx); auto registry_cli = project.executable("vbs-registry"); registry_cli.cxx_standard(Void::Build::CxxStandard::Cxx26) - .sources({"registry/service/Main.cpp"}) + .sources({"registry/cli/Main.cpp"}) .depends_on(bootstrap_cfg) .include_directory("$GEN/include", Void::Build::Visibility::Private) .link(registry_lib) diff --git a/cmake/BootstrapConfig.hpp.in b/cmake/BootstrapConfig.hpp.in index f88bb3c..4e8bdac 100644 --- a/cmake/BootstrapConfig.hpp.in +++ b/cmake/BootstrapConfig.hpp.in @@ -9,5 +9,5 @@ inline constexpr std::string_view architecture = "@CMAKE_SYSTEM_PROCESSOR@"; inline constexpr std::string_view source_dir = "@CMAKE_CURRENT_SOURCE_DIR@"; inline constexpr std::string_view binary_dir = "@CMAKE_CURRENT_BINARY_DIR@"; inline constexpr std::string_view sdk_include_dir = "@CMAKE_CURRENT_SOURCE_DIR@/include"; -inline constexpr std::string_view sdk_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/src"; +inline constexpr std::string_view sdk_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/sdk"; } // namespace Void::Build::Bootstrap diff --git a/cmake/VoidDependency.cmake b/cmake/VoidDependency.cmake index 54799fb..5439bfc 100644 --- a/cmake/VoidDependency.cmake +++ b/cmake/VoidDependency.cmake @@ -6,7 +6,7 @@ function(vbs_add_void_dependency) set(VOID_ENABLE_BENCHMARKS OFF) set(BUILD_SHARED_LIBS OFF) set(VOID_FETCH_SQLITE3 OFF) - set(VOID_ENABLED_MODULES Configuration Text Unicode Async Algorithms Crypto Archive) + set(VOID_ENABLED_MODULES Configuration Text Unicode Async Algorithms Crypto Archive Log) if(VBS_BUILD_TESTS) list(APPEND VOID_ENABLED_MODULES Testing) endif() diff --git a/docs/SDK.md b/docs/SDK.md index 457bc1d..dedf08f 100644 --- a/docs/SDK.md +++ b/docs/SDK.md @@ -1,7 +1,7 @@ # Declaration SDK (`Void::Build`) Status: Full v1 declaration SDK, JSON `schema_version: 1`. -Documents [include/Void/Build.hpp](file:///home/faumaray/Projects/VoidBuildSystem/include/Void/Build.hpp) and [src/Build.cpp](file:///home/faumaray/Projects/VoidBuildSystem/src/Build.cpp). +Documents [include/Void/Build.hpp](file:///home/faumaray/Projects/VoidBuildSystem/include/Void/Build.hpp) and [sdk/Build.cpp](file:///home/faumaray/Projects/VoidBuildSystem/sdk/Build.cpp). The SDK uses namespace `Void::Build`, `PascalCase` types/enum constants, and `snake_case` functions/methods. Future incompatible schema changes increment `schema_version`. diff --git a/docs/VOIDLIBRARY_UPSTREAM_REQUESTS.md b/docs/VOIDLIBRARY_UPSTREAM_REQUESTS.md index a01a956..0499ca6 100644 --- a/docs/VOIDLIBRARY_UPSTREAM_REQUESTS.md +++ b/docs/VOIDLIBRARY_UPSTREAM_REQUESTS.md @@ -13,10 +13,10 @@ Pinned VoidLibrary revision: `0002e74a7da94a756f55a4a5574d20b77736c185` (upstrea | `VL-005` | Streaming HTTP client & TLS default (`Void::Net::HttpClient`) | Implemented (requires Boost + OpenSSL) | Local loopback POSIX + `curl` adapter retained for minimal `dev cpp-gcc` (no Boost/OpenSSL) | | `VL-006` | Deterministic archive creation & safe staged extraction (`Void::Archive::create`, `extract_staged`) | Implemented (zero external deps for `.tar`) | **Adopted** (`src/Package/Archive.cpp`, always linked via `Void::Archive`) | | `VL-007` | Zero-dependency built-in SHA-256 / BLAKE2b (`Void::Crypto::Hasher`) | Implemented (zero external deps when OpenSSL absent) | **Adopted** (`include/Void/Build/Util/Sha256.hpp`, `src/Util/Sha256.cpp`, always linked via `Void::Crypto`) | -| `VL-008` | Strict UTF-8 validation (`Void::Json::Strict`, `Void::Unicode::validate_utf8`) | Implemented | **Adopted** (`src/Util/Json.cpp`, `Void::Json::Strict` throughout) | +| `VL-008` | Strict UTF-8 validation (`Void::Json::Strict`, `Void::Unicode::validate_utf8`) | Implemented | **Adopted** (`sdk/Json.cpp`, `Void::Json::Strict` throughout) | | `VL-009` | Native non-CMake `Void::Testing` registration API | Implemented | **Adopted** (supported alongside `vbs gen-tests` in `src/SelfHost/TestRegistryGen.cpp`) | | `VL-010` | Advisory `FileLock`, `reflink_copy_file`, `set_canonical_mtime`, `atomic_symlink_swap` (`Void::FileSystem`) | Implemented | **Adopted** (`include/Void/Build/Platform/FileOps.hpp`, `src/Platform/Linux/FileOps.cpp`) | -| `VL-011a` | Subcommands, `option_many`, `positional_many`, `ParseOutcome::Help` (`Void::Argparse::Parser`) | Implemented | **Adopted** (`src/Main.cpp`, `src/Describe.cpp`, `registry/service/Main.cpp`, `benchmarks/EngineBenchmarks.cpp` — 100% auto-generated help) | +| `VL-011a` | Subcommands, `option_many`, `positional_many`, `ParseOutcome::Help` (`Void::Argparse::Parser`) | Implemented | **Adopted** (`src/Main.cpp`, `src/Describe.cpp`, `registry/cli/Main.cpp`, `benchmarks/EngineBenchmarks.cpp` — 100% auto-generated help) | | `VL-011b` | Optional SQLite3 FetchContent (`Void::Sqlite`) | Implemented (`VOID_FETCH_SQLITE3`) | Opportunistic when system `SQLite3` is installed (`VOID_FETCH_SQLITE3=OFF` to keep offline configures fast); journaled atomic CAS store retained | | `VL-012` | Naming consistency observation | Noted | VBS strictly uses `Void::Build`, `PascalCase` types/enums/paths, `snake_case` functions/methods | | `VL-013` | Shorthand SemVer ranges (`^1.0`, `~1.2`, `>=1.2 <2`) in `Void::Semver::parse_range` | Implemented | **Adopted** (`src/Package/Solver.cpp` delegates directly to `Void::Semver::parse_range`) | @@ -33,7 +33,7 @@ Pinned VoidLibrary revision: `0002e74a7da94a756f55a4a5574d20b77736c185` (upstrea - **`VL-003` (`Void::FileSystem::DirectoryWatcher`)**: `src/Watch/Linux/Watcher.cpp` wraps `Void::FileSystem::DirectoryWatcher` for recursive Linux `inotify` observation, ignore predicates, and `RescanRequired` overflow handling. - **`VL-006` (`Void::Archive`)**: `CMakeLists.txt`, `cmake/VoidDependency.cmake`, `recipes/VoidLibrary/VoidLibraryRecipe.cpp`, and `recipes/SelfHost/VbsSelfHostRecipe.cpp` unconditionally enable `Void::Archive` (`VOID_ARCHIVE_HAS_LIBARCHIVE=0` built-in USTAR/PAX tar), and `src/Package/Archive.cpp` delegates archive creation and staged security-checked extraction to `Void::Archive::create` and `Void::Archive::extract_staged` + `StagedTree::publish`. - **`VL-007` (`Void::Crypto`)**: `Void::Crypto` (`VOID_CRYPTO_HAS_OPENSSL=0` built-in FIPS 180-4 SHA-256) is unconditionally linked, and `src/Util/Sha256.cpp` delegates directly to `Void::Crypto::Hasher`, `Void::Crypto::sha256`, and `Void::Crypto::sha256_file`. -- **`VL-008` (`Void::Json::Strict` / `Void::Unicode`)**: Strict UTF-8 validation is active across `Void::Json::Strict` and `src/Util/Json.cpp`. +- **`VL-008` (`Void::Json::Strict` / `Void::Unicode`)**: Strict UTF-8 validation is active across `Void::Json::Strict` and `sdk/Json.cpp`. - **`VL-010` (`Void::FileSystem`)**: `src/Platform/Linux/FileOps.cpp` delegates `FileLock`, `copy_isolated`, `set_canonical_mtime`, and `atomic_swap_symlink` directly to `Void::FileSystem::FileLock`, `reflink_copy_file`, `set_canonical_mtime`, and `atomic_symlink_swap`. - **`VL-011a` (`Void::Argparse::Parser`)**: Every VBS executable (`vbs`, `vbs-registry`, `vbs_describe`, `vbs_benchmarks`) uses `Void::Argparse::Parser::parse_detailed()` with native `subcommand()`, `option_many()`, `positional_many()`, and `require_subcommand()` — eliminating all custom help strings, manual `--help` checks, and manual repeatable-argument slicing. - **`VL-013` (`Void::Semver::parse_range`)**: `src/Package/Solver.cpp` calls `Void::Semver::parse_range()` directly without local range normalization. diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index a64601d..53d2d91 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -273,6 +273,13 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 90 (`vbs verify --trusted-public-key` & RFC 7232 If-None-Match)**: `vbs verify` accepts trusted key sources and rejects untrusted signer keys before verifying. A swarm worker (6/6 tasks) added ETag/304 support to the binary-variant detail endpoint and hardened `If-None-Match` handling per RFC 7232 (weak `W/` prefixes, comma lists, `*`) for all ETag-validated responses. +- **Wave 91 (Convention-Based Self-Build & VoidLibrary Console Logging)**: + - Source membership no longer enumerates files: the SDK lives in `sdk/` (`Build.cpp`, `Json.cpp`), the registry CLI entry in `registry/cli/Main.cpp`, and `build.cpp` plus the self-host recipe use `project.glob("src/**/*.cpp")`, `recipes/**`, `sdk/*.cpp`, and `registry/service/*.cpp`. `Bootstrap::sdk_source_dir` now points at `sdk/`, and `sdk/` joins the snapshot root discovery. + - A real bug was found and fixed: cached dependency paths are now absolute, so a relative `--build-dir` no longer breaks the self-host build (`std::filesystem::absolute` in `materialize_dependency_source`). + - Logging now uses VoidLibrary's `Void::Logging::ConsoleLogger` through `Void::Log::make_sink`, removing the hand-written sink and the `vbs` prefix (`[Info] [Deps] ...`); the `Log` module is enabled in every configuration. + +- **Wave 92 (TTY-Aware CLI Help & Log Colors)**: `ConsoleLogger` now installs a `PatternFormatter` with `ColorPolicy::defaults()` when stderr is a terminal, so log levels are colored (previously the default policy was disabled); CLI help is colorized (bold section headers/usage, cyan commands and options) when stdout is a terminal. `NO_COLOR` and the new global `--no-color` flag disable both. + ## Remaining future scope - **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Track C (macOS/Windows ports + dual-profile cross-compilation) and dedicated external editor plugins remain planned; Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement/distribution, binary-variant signing/distribution) and Track E3 daemon capabilities are implemented, and Track E4 now uses `Void::Net` for the registry client/server and remote cache plus `Void::Sqlite` for the StateStore when available. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 4acb0a1..2cf8c97 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -94,4 +94,6 @@ Base HEAD: `fe0d1a6` | Wave 88 (Track C1 boundaries) | Windows compile-time boundaries for the daemon socket and registry POSIX HTTP; `_putenv_s` branches for workspace env vars | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `registry/service/HttpServer.cpp`, docs | | Wave 89 (Binaries show + install file list) | `fetch_binary_detail`/`vbs binaries show`; swarm added bounded sorted `installed_files` to daemon install | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry and Daemon tests pass, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/{RegistryTests,DaemonTests}.cpp`, `tests/CliContracts.cmake`, docs | | Wave 90 (Verify trust + RFC 7232) | `vbs verify --trusted-public-key/--trusted-key-file`; swarm added binary-detail ETag and RFC 7232 If-None-Match matching | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; CLI contract and Registry suite pass, full CTest 8/8) | `src/Main.cpp`, `registry/service/RegistryService.cpp`, `tests/{RegistryTests,CliContracts}.cmake`, docs | +| Wave 91 (Convention-based self-build + ConsoleLogger) | globs/conventions in `build.cpp` and the self-host recipe; `sdk/` and `registry/cli/` layout; absolute dependency cache paths; `Void::Logging::ConsoleLogger` without the `vbs` prefix | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; bootstrap build, self-build with absolute AND relative build dirs, SDK 17/17, full CTest 8/8) | `build.cpp`, `recipes/SelfHost/VbsSelfHostRecipe.cpp`, `sdk/`, `registry/cli/`, `src/Main.cpp`, `src/Package/Fetch.cpp`, `src/Config/Frontend.cpp`, `cmake/`, docs | +| Wave 92 (CLI/log colors) | Colored `ConsoleLogger` levels and colorized help on TTYs; `NO_COLOR` + `--no-color` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; PTY checks show ANSI codes for help and logs) | `src/Main.cpp`, docs | | Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index 9b3b5e3..018a0db 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1319,6 +1319,26 @@ dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color absolute paths under the prefix) by the prior swarm's queued edits. - Full CTest on the final tree: **8 / 8 passed** in 267.99 s. +## Convention-Based Self-Build, ConsoleLogger & Colors (GCC 16.2, pin `0002e74`) + +- Source membership now comes from `project.glob(...)` in `build.cpp` and the self-host recipe + (`sdk/*.cpp`, `src/**/*.cpp`, `recipes/**/*.cpp`, `registry/service/*.cpp`), with the SDK in + `sdk/` and the registry CLI entry in `registry/cli/Main.cpp`. +- Bootstrap build (CMake): exit 0. `vbs_sdk_tests`: **17 / 17 passed**. +- Real `vbs` self-build (root `build.cpp`): **success** with an absolute build dir (43 actions, + linked `vbs`) and, after making dependency cache paths absolute, with a **relative** build dir + (43 actions). The self-built binary reports `vbs 0.1.0`. +- Self-host suite (stage builds through `VbsSelfHostRecipe`) passes after fixing absolute glob + patterns (`expand_glob` now anchors absolute patterns at the project root) and linking + `Void::Log`. +- Logging uses `Void::Logging::ConsoleLogger`; the `vbs` prefix is gone (`[Info] [Deps] ...`). + Under a PTY (`script -qec ...`), help shows ANSI bold/cyan and log levels show ANSI color + (`[<96mInfo<0m]`); `NO_COLOR`/`--no-color` disable both. +- Full CTest on a fresh build: **8 / 8 passed** in 290.25 s. +- Note: one intermediate CTest run had its shared build directory deleted mid-run by an + unidentified external actor; a fresh configure/build/CTest is fully green, and the anomaly is + not attributable to VBS code. + ## Limits and Unrun Checks 1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified). diff --git a/docs/roadmap/README.md b/docs/roadmap/README.md index cca754c..8037dd8 100644 --- a/docs/roadmap/README.md +++ b/docs/roadmap/README.md @@ -12,7 +12,7 @@ Authority: [requirements](REQUIREMENTS.md), [architecture](ARCHITECTURE.md), | Part | Status | Primary Implementation | | --- | --- | --- | -| [01 — Bootstrap and declaration SDK](01-bootstrap-sdk.md) | Implemented & Verified | [Build.hpp](../../include/Void/Build.hpp), [Build.cpp](../../src/Build.cpp) | +| [01 — Bootstrap and declaration SDK](01-bootstrap-sdk.md) | Implemented & Verified | [Build.hpp](../../include/Void/Build.hpp), [Build.cpp](../../sdk/Build.cpp) | | [02 — Native C++ configuration frontend](02-configuration-frontend.md) | Implemented & Verified | [Frontend.cpp](../../src/Config/Frontend.cpp) | | [03 — Targets, usage requirements and action graph](03-targets-action-graph.md) | Implemented & Verified | [Graph.cpp](../../src/Graph/Graph.cpp) | | [04 — Profiles, target selection and toolchains](04-profiles-toolchains.md) | Implemented & Verified | [Driver.cpp](../../src/Toolchain/Driver.cpp) | diff --git a/recipes/SelfHost/VbsSelfHostRecipe.cpp b/recipes/SelfHost/VbsSelfHostRecipe.cpp index 9347f64..fc7afb5 100644 --- a/recipes/SelfHost/VbsSelfHostRecipe.cpp +++ b/recipes/SelfHost/VbsSelfHostRecipe.cpp @@ -38,7 +38,7 @@ add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) { } // 2. Declare the native VoidLibrary module closure (pure C++26, zero CMake). - std::vector void_mods = {"Configuration", "Text", "Unicode", "Async", + std::vector void_mods = {"Configuration", "Text", "Unicode", "Async", "Log", "Algorithms", "Crypto", "Archive"}; if (config.include_tests) { void_mods.push_back("Testing"); @@ -50,8 +50,7 @@ add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) { // 3. VoidBuildSdk (static library). auto sdk = project.static_library("VoidBuildSdk"); sdk.cxx_standard(CxxStandard::Cxx26) - .sources(SourceSet::file((root / "src" / "Build.cpp").string())) - .sources(SourceSet::file((root / "src" / "Util" / "Json.cpp").string())) + .sources(project.glob((root / "sdk").string() + "/*.cpp")) .include_directory((root / "include").string(), Visibility::Public) .compile_option("-freflection", Visibility::Public) .define("VBS_HAS_VOID_UNICODE=1", Visibility::Private) @@ -73,47 +72,11 @@ add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) { .link(void_libs.modules.at("Async"), Visibility::Public) .link(void_libs.modules.at("Algorithms"), Visibility::Public) .link(void_libs.modules.at("Crypto"), Visibility::Public) - .link(void_libs.modules.at("Archive"), Visibility::Public); + .link(void_libs.modules.at("Archive"), Visibility::Public) + .link(void_libs.modules.at("Log"), Visibility::Public); - const std::vector core_sources = { - "src/Util/Sha256.cpp", - "src/Platform/Linux/FileOps.cpp", - "src/Platform/Linux/ProcessSupervisor.cpp", - "src/Toolchain/Driver.cpp", - "src/Snapshot/Snapshot.cpp", - "src/State/StateStore.cpp", - "src/State/RemoteCache.cpp", - "src/Graph/Graph.cpp", - "src/Execution/Scheduler.cpp", - "src/Config/BuildTree.cpp", - "src/Config/Frontend.cpp", - "src/Config/Scaffold.cpp", - "src/Daemon/Daemon.cpp", - "src/Editor/CompDb.cpp", - "src/Watch/Linux/Watcher.cpp", - "src/Package/Toml.cpp", - "src/Package/Solver.cpp", - "src/Package/Lockfile.cpp", - "src/Package/Archive.cpp", - "src/Package/Fetch.cpp", - "src/Package/RegistryClient.cpp", - "src/Package/Resolver.cpp", - "src/Provider/Provider.cpp", - "src/Provider/Translator.cpp", - "src/Install/Installer.cpp", - "src/Bridge/CMakeBridge.cpp", - "src/Modules/ModuleScanner.cpp", - "src/SelfHost/TestRegistryGen.cpp", - "src/Provenance/Sbom.cpp", - "src/Provenance/Signing.cpp", - "src/Provenance/Verification.cpp", - "src/Provenance/TrustedKeys.cpp", - "recipes/VoidLibrary/VoidLibraryRecipe.cpp", - "recipes/SelfHost/VbsSelfHostRecipe.cpp", - }; - for (const auto &rel : core_sources) { - core.sources(SourceSet::file((root / rel).string())); - } + core.sources(project.glob((root / "src").string() + "/**/*.cpp")); + core.sources(project.glob((root / "recipes").string() + "/**/*.cpp")); // 5. Full native `vbs` CLI executable. auto vbs = project.executable("vbs"); @@ -126,15 +89,13 @@ add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) { if (config.include_registry) { auto reg_lib = project.static_library("VoidBuildRegistry"); reg_lib.cxx_standard(CxxStandard::Cxx26) - .sources(SourceSet::file((root / "registry" / "service" / "HttpServer.cpp").string())) - .sources( - SourceSet::file((root / "registry" / "service" / "RegistryService.cpp").string())) + .sources(project.glob((root / "registry" / "service").string() + "/*.cpp")) .include_directory((root / "registry" / "include").string(), Visibility::Public) .link(core, Visibility::Public); auto reg_bin = project.executable("vbs-registry"); reg_bin.cxx_standard(CxxStandard::Cxx26) - .sources(SourceSet::file((root / "registry" / "service" / "Main.cpp").string())) + .sources(SourceSet::file((root / "registry" / "cli" / "Main.cpp").string())) .include_directory(gen_dir.string(), Visibility::Private) .link(reg_lib); } diff --git a/registry/service/Main.cpp b/registry/cli/Main.cpp similarity index 100% rename from registry/service/Main.cpp rename to registry/cli/Main.cpp diff --git a/src/Build.cpp b/sdk/Build.cpp similarity index 100% rename from src/Build.cpp rename to sdk/Build.cpp diff --git a/src/Util/Json.cpp b/sdk/Json.cpp similarity index 100% rename from src/Util/Json.cpp rename to sdk/Json.cpp diff --git a/src/Config/Frontend.cpp b/src/Config/Frontend.cpp index baade1d..ca2692a 100644 --- a/src/Config/Frontend.cpp +++ b/src/Config/Frontend.cpp @@ -474,7 +474,7 @@ compile_descriptor(const FrontendOptions &options) { std::filesystem::is_regular_file(options.sdk_library_path, ec); if (!use_prebuilt_sdk && !options.sdk_source_dir.empty()) { compile_units.push_back(options.sdk_source_dir / "Build.cpp"); - compile_units.push_back(options.sdk_source_dir / "Util" / "Json.cpp"); + compile_units.push_back(options.sdk_source_dir / "Json.cpp"); } std::vector objects; diff --git a/src/Graph/Graph.cpp b/src/Graph/Graph.cpp index 5e44a6b..039ce9b 100644 --- a/src/Graph/Graph.cpp +++ b/src/Graph/Graph.cpp @@ -480,6 +480,22 @@ expand_glob(const std::filesystem::path &project_root, std::string_view pattern) "expand_glob: project root '{}' is not a directory", project_root.string()))}; } + // Patterns may be written relative to the project root or absolute paths anchored at it + // (recipes commonly know the project's absolute location). Match against relative paths. + std::string effective_pattern{pattern}; + { + const std::filesystem::path raw_pattern{std::string{pattern}}; + if (raw_pattern.is_absolute()) { + const auto rel_pattern = raw_pattern.lexically_relative(canonical_root); + if (!rel_pattern.empty() && rel_pattern.native().starts_with("..")) { + return std::unexpected{make_error( + std::format("expand_glob: pattern '{}' escapes project root '{}'", pattern, + canonical_root.string()))}; + } + effective_pattern = rel_pattern.lexically_normal().generic_string(); + } + } + std::vector matches; std::filesystem::recursive_directory_iterator it{ canonical_root, std::filesystem::directory_options::skip_permission_denied, ec}; @@ -493,7 +509,7 @@ expand_glob(const std::filesystem::path &project_root, std::string_view pattern) } if (it->is_regular_file(ec)) { const std::string gen = rel.lexically_normal().generic_string(); - if (match_glob(pattern, gen)) { + if (match_glob(effective_pattern, gen)) { matches.push_back(rel.lexically_normal()); } } diff --git a/src/Main.cpp b/src/Main.cpp index f9840c6..afcf01c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -35,7 +35,11 @@ #include #include #include +#include +#include #include +#include +#include #include #include #include @@ -68,6 +72,60 @@ namespace { using namespace Void::Build; +// ANSI colors are enabled only for a terminal and are disabled by NO_COLOR or --no-color. +bool g_no_color = false; + +bool color_enabled(int fd = 2) noexcept { + if (g_no_color || ::getenv("NO_COLOR") != nullptr) { + return false; + } + return ::isatty(fd) == 1; +} + +std::string colorize_help(std::string_view text) { + if (!color_enabled(1)) { + return std::string{text}; + } + constexpr std::string_view kReset = "\x1b[0m"; + constexpr std::string_view kBold = "\x1b[1m"; + constexpr std::string_view kCyan = "\x1b[36m"; + std::string out; + out.reserve(text.size() + 64); + std::size_t pos = 0; + while (pos <= text.size()) { + const auto nl = text.find('\n', pos); + const auto end = nl == std::string_view::npos ? text.size() : nl; + const std::string_view line = text.substr(pos, end - pos); + const bool section_header = + !line.empty() && line.back() == ':' && line.find_first_not_of(" \t") == 0; + const bool usage = line.starts_with("Usage:"); + const bool indented_entry = line.starts_with(" ") && !section_header && + line.find_first_not_of(' ') != std::string_view::npos && + line.find(" ") != std::string_view::npos; + if (section_header || usage) { + out += kBold; + out += line; + out += kReset; + } else if (indented_entry) { + const auto token_start = line.find_first_not_of(' '); + const auto token_end = line.find(' ', token_start); + out += line.substr(0, token_start); + out += kCyan; + out += line.substr(token_start, token_end - token_start); + out += kReset; + out += line.substr(token_end); + } else { + out += line; + } + if (nl == std::string_view::npos) { + break; + } + out += '\n'; + pos = nl + 1; + } + return out; +} + class ConsoleLogGuard { public: explicit ConsoleLogGuard(Void::Log::Level level) { @@ -76,46 +134,27 @@ class ConsoleLogGuard { // Suppress internal VoidLibrary FileSystem open-miss warnings on cold cache probes. Void::Log::set_module_level("FileSystem", Void::Log::Level::Error); } - reg_id_ = - Void::Log::register_sink([mutex = std::make_shared()]( - Void::Log::Level lvl, std::string_view module, - std::string_view message, const std::source_location &) { - std::lock_guard lock{*mutex}; - switch (lvl) { - case Void::Log::Level::Trace: - std::cerr << "[vbs][TRACE][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Debug: - std::cerr << "[vbs][DEBUG][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Info: - std::cerr << "[vbs][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Warning: - std::cerr << "[vbs][WARN][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Error: - std::cerr << "[vbs][ERROR][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Fatal: - std::cerr << "[vbs][FATAL][" << module << "] " << message << '\n' << std::flush; - break; - case Void::Log::Level::Disabled: - break; - } - }); + logger_ = std::make_unique(); + if (color_enabled()) { + auto formatter = std::make_shared("[{level:,auto}] {message}"); + formatter->set_color_policy(Void::Logging::ColorPolicy::defaults()); + logger_->set_formatter(std::move(formatter)); + } + reg_id_ = Void::Log::register_sink(Void::Log::make_sink(*logger_)); } ~ConsoleLogGuard() { if (reg_id_ != 0) { (void)Void::Log::detach_and_drain(reg_id_); } + logger_.reset(); } ConsoleLogGuard(const ConsoleLogGuard &) = delete; ConsoleLogGuard &operator=(const ConsoleLogGuard &) = delete; private: + std::unique_ptr logger_; Void::Log::RegistrationId reg_id_{0}; }; @@ -179,7 +218,7 @@ SnapshotInputs collect_snapshot_inputs(const Graph::ProjectDescription &desc, } }; - for (const char *d : {"src", "source", "include", "tests"}) { + for (const char *d : {"src", "sdk", "source", "include", "tests"}) { add_dir_if_in_project(root / d); } @@ -2666,7 +2705,8 @@ int main(int argc, char **argv) { auto add_log_flags = [&](Void::Argparse::Parser &p, bool allow_short_v = true) { p.flag("--verbose", allow_short_v ? "-v" : "", "Enable verbose debug logs", verbose) - .flag("--quiet", "-q", "Suppress progress logs (warnings and errors only)", quiet); + .flag("--quiet", "-q", "Suppress progress logs (warnings and errors only)", quiet) + .flag("--no-color", "", "Disable ANSI colors", g_no_color); }; auto configure_build_or_test = [&](Void::Argparse::Parser &p) { @@ -3218,7 +3258,7 @@ int main(int argc, char **argv) { const auto parsed = root.parse_detailed(argc, argv); if (parsed.is_help()) { - std::cout << parsed.message; + std::cout << colorize_help(parsed.message); return 0; } if (parsed.is_error()) { @@ -3234,7 +3274,7 @@ int main(int argc, char **argv) { return 0; } if (parsed.matched_command_path.empty()) { - std::cout << root.help(); + std::cout << colorize_help(root.help()); return 0; } diff --git a/src/Package/Fetch.cpp b/src/Package/Fetch.cpp index f942ddc..79bf11d 100644 --- a/src/Package/Fetch.cpp +++ b/src/Package/Fetch.cpp @@ -202,7 +202,11 @@ materialize_binary_variant(const BinaryCompatibilityKey &key, Void::Result::Result materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &options) { std::error_code ec; - std::filesystem::create_directories(options.cache_dir, ec); + // Cache paths are made absolute so materialized sources stay valid regardless of the + // provider's/consumer's working directory. + const std::filesystem::path cache_dir = + std::filesystem::absolute(options.cache_dir, ec).lexically_normal(); + std::filesystem::create_directories(cache_dir, ec); // 1. Local path source: compute content hash without mutating the external checkout. if (dep.source_kind == DependencySourceKind::Path) { @@ -217,7 +221,7 @@ materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &o } Snapshot::SnapshotOptions sopts; sopts.project_root = canon; - sopts.snapshot_store_dir = options.cache_dir / "path-snapshots"; + sopts.snapshot_store_dir = cache_dir / "path-snapshots"; sopts.materialize = false; // Generated editor metadata is never a build input and may be an out-of-tree symlink. sopts.excluded_names.push_back("compile_commands.json"); @@ -235,9 +239,9 @@ materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &o // 2. Checksummed archive source (local file:// or verified cached tar). if (dep.source_kind == DependencySourceKind::Archive) { - const auto extract_dir = options.cache_dir / "archives" / dep.sha256; + const auto extract_dir = cache_dir / "archives" / dep.sha256; const auto marker = extract_dir / ".vbs_verified"; - const auto lock_path = options.cache_dir / "locks" / (dep.sha256 + ".lock"); + const auto lock_path = cache_dir / "locks" / (dep.sha256 + ".lock"); auto lock = Platform::FileLock::acquire(lock_path, Platform::LockMode::Exclusive); if (!lock) { return std::unexpected{lock.error()}; @@ -252,7 +256,7 @@ materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &o return out; } - const auto downloaded_tar = options.cache_dir / "downloads" / (dep.sha256 + ".tar"); + const auto downloaded_tar = cache_dir / "downloads" / (dep.sha256 + ".tar"); std::filesystem::create_directories(downloaded_tar.parent_path(), ec); if (!std::filesystem::is_regular_file(downloaded_tar, ec)) { @@ -348,9 +352,9 @@ materialize_dependency_source(const DependencyRecord &dep, const FetchOptions &o } const auto git_dir = - options.cache_dir / "git" / (sanitize_key(dep.name) + "_" + dep.revision); + cache_dir / "git" / (sanitize_key(dep.name) + "_" + dep.revision); const auto marker = git_dir / ".vbs_verified_rev"; - const auto lock_path = options.cache_dir / "locks" / ("git_" + dep.revision + ".lock"); + const auto lock_path = cache_dir / "locks" / ("git_" + dep.revision + ".lock"); auto lock = Platform::FileLock::acquire(lock_path, Platform::LockMode::Exclusive); if (!lock) { return std::unexpected{lock.error()}; diff --git a/src/Provider/Provider.cpp b/src/Provider/Provider.cpp index e899cee..e76587e 100644 --- a/src/Provider/Provider.cpp +++ b/src/Provider/Provider.cpp @@ -931,7 +931,7 @@ std::vector parse_void_modules_option(const OptionMap &options) { } } if (mods.empty()) { - mods = {"Configuration", "Text", "Unicode", "Async", + mods = {"Configuration", "Text", "Unicode", "Async", "Log", "Algorithms", "Crypto", "Archive", "Testing"}; } return mods; @@ -955,7 +955,7 @@ collect_native_dep_snapshot_inputs(const Graph::ProjectDescription &desc, root_dirs.insert(norm); } }; - for (const char *d : {"src", "source", "include", "tests"}) { + for (const char *d : {"src", "sdk", "source", "include", "tests"}) { add_dir_if_in_project(root / d); } auto is_gen_ref = [](std::string_view p) { diff --git a/src/Watch/Linux/Watcher.cpp b/src/Watch/Linux/Watcher.cpp index 7a44120..711ce49 100644 --- a/src/Watch/Linux/Watcher.cpp +++ b/src/Watch/Linux/Watcher.cpp @@ -199,7 +199,7 @@ WatchCycleReport run_reconcile_cycle(const WatchLoopOptions &options, std::size_ // 6. Capture input snapshot (content-verified; materialize only for FullBuild execution). std::vector scan_roots; std::error_code ec; - for (const char *d : {"src", "source", "include", "tests"}) { + for (const char *d : {"src", "sdk", "source", "include", "tests"}) { if (std::filesystem::is_directory(options.frontend.project_root / d, ec)) { scan_roots.push_back(options.frontend.project_root / d); } diff --git a/tests/DescribeContracts.cmake b/tests/DescribeContracts.cmake index 0cac379..2a28403 100644 --- a/tests/DescribeContracts.cmake +++ b/tests/DescribeContracts.cmake @@ -32,8 +32,8 @@ foreach(profile IN ITEMS debug release) endif() expect_json(VoidBuildSdk targets 0 name) expect_json(static_library targets 0 kind) - expect_json(file targets 0 sources 0 kind) - expect_json(src/Build.cpp targets 0 sources 0 path) + expect_json(glob targets 0 sources 0 kind) + expect_json(sdk/*.cpp targets 0 sources 0 path) expect_json(public targets 0 include_directories 0 visibility) expect_json(VoidBuildCore targets 1 name) expect_json(static_library targets 1 kind) diff --git a/tests/ExampleContexts.cpp b/tests/ExampleContexts.cpp index 2fa5ee3..a8ed854 100644 --- a/tests/ExampleContexts.cpp +++ b/tests/ExampleContexts.cpp @@ -54,7 +54,7 @@ VOID_TEST(ExampleContexts, example_records_sources_links_and_pin) { Void::Testing::expect_eq(project.targets().size(), std::size_t{13}); Void::Testing::expect_eq(project.targets().at(0).name, std::string{"VoidBuildSdk"}); Void::Testing::expect_eq(project.targets().at(0).sources.at(0).path, - std::string{"src/Build.cpp"}); + std::string{"sdk/*.cpp"}); Void::Testing::expect_eq(project.targets().at(1).name, std::string{"VoidBuildCore"}); Void::Testing::expect_eq(project.targets().at(1).links.at(0).target, std::string{"VoidBuildSdk"}); diff --git a/tests/SelfHostTests.cpp b/tests/SelfHostTests.cpp index b613fdc..ac1846c 100644 --- a/tests/SelfHostTests.cpp +++ b/tests/SelfHostTests.cpp @@ -109,8 +109,8 @@ VOID_TEST(SelfHostTests, strict_native_selfhost_voidlibrary_and_sdk_without_cmak const std::filesystem::path vbs_root{Bootstrap::source_dir}; auto sdk = proj.static_library("VoidBuildSdk"); sdk.cxx_standard(CxxStandard::Cxx26) - .sources(SourceSet::file((vbs_root / "src" / "Build.cpp").string())) - .sources(SourceSet::file((vbs_root / "src" / "Util" / "Json.cpp").string())) + .sources(SourceSet::file((vbs_root / "sdk" / "Build.cpp").string())) + .sources(SourceSet::file((vbs_root / "sdk" / "Json.cpp").string())) .include_directory((vbs_root / "include").string(), Visibility::Public) .compile_option("-freflection", Visibility::Public); @@ -172,8 +172,8 @@ VOID_TEST(SelfHostTests, strict_native_selfhost_voidlibrary_and_sdk_without_cmak Project stage1_pkg_proj{ctx}; auto s1_sdk = stage1_pkg_proj.static_library("VoidBuildSdk"); s1_sdk.cxx_standard(CxxStandard::Cxx26) - .sources(SourceSet::file((vbs_root / "src" / "Build.cpp").string())) - .sources(SourceSet::file((vbs_root / "src" / "Util" / "Json.cpp").string())) + .sources(SourceSet::file((vbs_root / "sdk" / "Build.cpp").string())) + .sources(SourceSet::file((vbs_root / "sdk" / "Json.cpp").string())) .include_directory((vbs_root / "include").string(), Visibility::Public) .compile_option("-freflection", Visibility::Public) .install("lib");