feat(profiles): per-dependency overrides, toolchain pin and profile CLI (G3)
VoidBuildSystem CI / 1 · Requirements (push) Successful in 5s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m50s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 3m29s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m7s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m53s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m22s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m22s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 1m57s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 2m0s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 19s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 18s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 7m8s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 7m24s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped

- Dependency::profile(name, DependencyProfileOptions) records per-profile
  compile/link options, defines, LTO and sanitizers. The native provider
  applies the matching override to the dependency's own ProfileContext and
  hashes the overrides into the provider input hash, so changing them
  invalidates cached dependency builds.
- vbs-toolchain.toml pins compiler, minimum version, C/C++ standards and
  sysroot (optional strict); it is loaded once and checked after every
  toolchain probe. Drift warns by default and fails with
  --locked-toolchain or strict = true; malformed pins fail with the TOML
  diagnostic.
- vbs profile list|show|diff lists declared profiles with parents, prints
  a resolved profile (flags, standards, LTO, sanitizers, sysroot) or the
  fields that differ between two.

Verified: dependency_profile_overrides_apply_to_native_builds (a define
from the override is required by the dependency source),
toolchain_pin_detects_and_enforces_drift and
profile_commands_list_show_and_diff pass; vbs_core_tests 8/8; CLI
contracts pass; clang-format clean.
This commit is contained in:
faumaray committed 2026-12-06 20:09:50 +03:00
1 parent f03524628b
commit 3b5d28d7b0
13 files changed
+702 -4

No files matched your search

+144
View File
@@ -5186,3 +5186,147 @@ void build(Void::Build::Project &p) {
Void::Testing::expect(with_feature.has_value() && with_feature->succeeded());
Void::Testing::expect_eq(entry_count(), 1LL);
}
// === G3: per-dependency profile overrides ===
VOID_TEST(FullV1Tests, dependency_profile_overrides_apply_to_native_builds) {
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_dep_profile_"};
const auto dep = tmp / "dep";
const auto with_override = tmp / "with";
const auto without_override = tmp / "without";
write_file(dep / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) { p.static_library("deplib").sources({"src/dep.cpp"}); }
)cpp");
write_file(dep / "src" / "dep.cpp", "#ifndef VBS_DEP_OVERRIDE\n#error \"VBS_DEP_OVERRIDE is "
"required\"\n#endif\nint depfn() { return 1; }\n");
write_file(with_override / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
p.dependency("dep").path("../dep").native_builder({})
.profile("debug", {.compile_options = {"-DVBS_DEP_OVERRIDE=1"}});
p.executable("app").sources({"src/main.cpp"});
}
)cpp");
write_file(without_override / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
p.dependency("dep").path("../dep").native_builder({});
p.executable("app").sources({"src/main.cpp"});
}
)cpp");
for (const auto &project : {with_override, without_override}) {
write_file(project / "src" / "main.cpp", "int main() { return 0; }\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{600};
return Platform::run_supervised(req);
};
auto overridden = run_vbs({"build", "--project", with_override.string(), "--build-dir",
(tmp / "build-with").string(), "--jobs", "2"});
Void::Testing::expect(overridden.has_value() && overridden->succeeded());
if (overridden && !overridden->succeeded()) {
std::cerr << overridden->stderr_data << '\n';
}
auto plain = run_vbs({"build", "--project", without_override.string(), "--build-dir",
(tmp / "build-without").string(), "--jobs", "2"});
Void::Testing::expect(plain.has_value() && !plain->succeeded());
}
// === G3: vbs-toolchain.toml pinning and drift detection ===
VOID_TEST(FullV1Tests, toolchain_pin_detects_and_enforces_drift) {
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_toolchain_pin_"};
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");
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);
};
write_file(proj / "vbs-toolchain.toml", "compiler = \"clang\"\n");
auto warned = run_vbs({"build", "--project", proj.string(), "--build-dir",
(tmp / "build-warn").string(), "--jobs", "2"});
Void::Testing::expect(warned.has_value() && warned->succeeded());
if (warned) {
Void::Testing::expect((warned->stdout_data + warned->stderr_data)
.find("pin drift") != std::string::npos);
}
auto enforced = run_vbs({"build", "--project", proj.string(), "--build-dir",
(tmp / "build-enforced").string(), "--jobs", "2",
"--locked-toolchain"});
Void::Testing::expect(enforced.has_value() && enforced->exit_code == 1);
if (enforced) {
Void::Testing::expect(enforced->stderr_data.find("toolchain pin") != std::string::npos);
}
write_file(proj / "vbs-toolchain.toml", "compiler = \"gcc\"\nversion = \"16\"\n");
auto matching = run_vbs({"build", "--project", proj.string(), "--build-dir",
(tmp / "build-match").string(), "--jobs", "2",
"--locked-toolchain"});
Void::Testing::expect(matching.has_value() && matching->succeeded());
write_file(proj / "vbs-toolchain.toml", "compiler = [\n");
auto malformed = run_vbs({"build", "--project", proj.string(), "--build-dir",
(tmp / "build-bad").string()});
Void::Testing::expect(malformed.has_value() && !malformed->succeeded());
}
// === G3: vbs profile list / show / diff ===
VOID_TEST(FullV1Tests, profile_commands_list_show_and_diff) {
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_profiles_cmd_"};
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");
write_file(proj / "build.profiles.cpp", R"cpp(#include <Void/Build.hpp>
void profiles(Void::Build::Profiles &p) {
p = Void::Build::default_profiles();
p.inherit("fast", "release", {"-DFAST_MODE=1"});
}
)cpp");
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);
};
auto list = run_vbs({"profile", "list", "--project", proj.string()});
Void::Testing::expect(list.has_value() && list->succeeded());
if (list) {
Void::Testing::expect(list->stdout_data.find("fast parent=release") != std::string::npos);
Void::Testing::expect(list->stdout_data.find("debug") != std::string::npos);
}
auto show = run_vbs({"profile", "show", "release", "--project", proj.string()});
Void::Testing::expect(show.has_value() && show->succeeded());
if (show) {
Void::Testing::expect(show->stdout_data.find("name: release") != std::string::npos);
Void::Testing::expect(show->stdout_data.find("compiler: gcc") != std::string::npos);
}
auto diff = run_vbs({"profile", "diff", "debug", "fast", "--project", proj.string()});
Void::Testing::expect(diff.has_value() && diff->succeeded());
if (diff) {
Void::Testing::expect(diff->stdout_data.find("compile_options:") != std::string::npos);
Void::Testing::expect(diff->stdout_data.find("FAST_MODE") != std::string::npos);
}
auto missing = run_vbs({"profile", "show", "nope", "--project", proj.string()});
Void::Testing::expect(missing.has_value() && missing->exit_code == 2);
}