feat(perf,cli): shared per-user caches, generated completions and man pages
VoidBuildSystem CI / 1 · Requirements (push) Successful in 9s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m45s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m34s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m34s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m50s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 22s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 24s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 5m41s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m36s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m2s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 6m8s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Successful in 3m12s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 3m17s
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 1 · Requirements (push) Successful in 9s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m45s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m34s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m34s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 4m50s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 22s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 24s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 5m41s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m36s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m2s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 6m8s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Successful in 3m12s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Successful in 3m17s
VoidBuildSystem CI / 5 · Release (push) Skipped
Cold builds in a fresh build directory now reuse content-addressed artifacts from $XDG_CACHE_HOME/vbs (or ~/.cache/vbs): the compiled build descriptor and the toolchain capability probes. Keys already cover the compiler identity, the SDK, the generated driver source and every configuration source, and the descriptor's discovered headers are re-verified on every run, so sharing cannot change a result; VBS_SHARED_CACHE=0 keeps a build directory self-contained. Measured on a 20-source fixture (Debug vbs): cold 3897 ms -> 755 ms in a fresh build directory, warm 153 ms (config 1986 -> 128 ms, toolchain 562 -> 6.5 ms). `vbs completions --shell bash|zsh|fish` and `vbs man [--output DIR]` generate shell completion scripts and roff man pages from the live parser tree by running `vbs <path> --help`, so they cannot drift from the CLI (86 man pages). Verified: new FullV1Tests cases for the shared cache and for completions/man (including `bash -n` on the generated script) pass, and the CLI contract suite passes.
This commit is contained in:
1 parent
2dec3e9259
commit
9da1387031
9 files changed
+945
-6
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user