Implement VoidBuildSystem v1 (Plans 01-19) with VoidLibrary integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s

This commit is contained in:
faumaray committed 2026-11-26 20:45:54 +03:00
1 parent 3cac890ce9
commit ab64147f9d
114 files changed
+23777 -1392

No files matched your search

+74 -61
View File
@@ -1,15 +1,16 @@
#include <Void/Build.hpp>
#include <Void/Data/StrictJson.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <vbs/build.hpp>
#include <limits>
#include <optional>
#include <type_traits>
namespace {
vbs::ProfileContext context() {
return vbs::default_profiles().resolve("debug", vbs::CompilerFamily::gcc, "linux", "x86_64");
Void::Build::ProfileContext context() {
return Void::Build::default_profiles().resolve("debug", Void::Build::CompilerFamily::Gcc,
"linux", "x86_64");
}
constexpr auto revision = "9931c5ffc4844a5e09e1b1db35b3d29c5097c3a5";
using Json = Void::Json::Strict::Value;
@@ -23,59 +24,64 @@ std::string text(const Json &value) { return std::get<std::string>(value.value);
} // namespace
Void::Testing::Test default_profiles_and_overrides() {
const auto profiles = vbs::default_profiles();
const auto debug = profiles.resolve("debug", vbs::CompilerFamily::clang, "linux", "aarch64");
const auto release = profiles.resolve("release", vbs::CompilerFamily::gcc, "linux", "x86_64");
const auto profiles = Void::Build::default_profiles();
const auto debug =
profiles.resolve("debug", Void::Build::CompilerFamily::Clang, "linux", "aarch64");
const auto release =
profiles.resolve("release", Void::Build::CompilerFamily::Gcc, "linux", "x86_64");
Void::Testing::expect_eq(profiles.records().size(), std::size_t{2});
Void::Testing::expect(debug.compiler == vbs::CompilerFamily::clang);
Void::Testing::expect(debug.compiler == Void::Build::CompilerFamily::Clang);
Void::Testing::expect_eq(debug.architecture, std::string{"aarch64"});
Void::Testing::expect_eq(debug.compile_options.at(0), std::string{"-O0"});
Void::Testing::expect_eq(release.compile_options.at(0), std::string{"-O3"});
}
Void::Testing::Test rejects_invalid_profiles() {
auto profiles = vbs::default_profiles();
auto profiles = Void::Build::default_profiles();
Void::Testing::expect_throw<std::invalid_argument>([&] { profiles.add("debug"); });
Void::Testing::expect_throw<std::invalid_argument>([&] { profiles.add(""); });
Void::Testing::expect_throw<std::invalid_argument>([&] { profiles.add("bad", {""}); });
Void::Testing::expect_throw<std::invalid_argument>([&] {
(void)profiles.resolve("unknown", Void::Build::CompilerFamily::Gcc, "linux", "x86_64");
});
Void::Testing::expect_throw<std::invalid_argument>(
[&] { (void)profiles.resolve("unknown", vbs::CompilerFamily::gcc, "linux", "x86_64"); });
Void::Testing::expect_throw<std::invalid_argument>([] { (void)vbs::parse_compiler("msvc"); });
[] { (void)Void::Build::parse_compiler("msvc"); });
Void::Testing::expect_throw<std::invalid_argument>(
[&] { (void)profiles.resolve("debug", vbs::CompilerFamily::gcc, "", "x86_64"); });
[&] { (void)profiles.resolve("debug", Void::Build::CompilerFamily::Gcc, "", "x86_64"); });
}
Void::Testing::Test declaration_records_and_visibility() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto library = project.static_library("library");
library.sources({"one.cpp", "two.cpp"})
.include_directory("include", vbs::Visibility::public_)
.include_directory("include", Void::Build::Visibility::Public)
.compile_option("-Wall");
auto executable = project.executable("app");
executable.link(library).link(library, vbs::Visibility::interface_);
Void::Testing::expect(library.record().kind == vbs::TargetKind::static_library);
executable.link(library).link(library, Void::Build::Visibility::Interface);
Void::Testing::expect(library.record().kind == Void::Build::TargetKind::StaticLibrary);
Void::Testing::expect_eq(library.record().sources.size(), std::size_t{2});
Void::Testing::expect(library.record().include_directories.at(0).visibility ==
vbs::Visibility::public_);
Void::Testing::expect(executable.record().links.at(0).visibility == vbs::Visibility::private_);
Void::Build::Visibility::Public);
Void::Testing::expect(executable.record().links.at(0).visibility ==
Void::Build::Visibility::Private);
Void::Testing::expect(executable.record().links.at(1).visibility ==
vbs::Visibility::interface_);
Void::Build::Visibility::Interface);
}
Void::Testing::Test sources_are_symbolic() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto target = project.executable("symbolic");
target.sources({"missing/../literal.cpp"}).sources(project.glob("nonexistent/**/*.cpp"));
Void::Testing::expect_eq(target.record().sources.at(0).path,
std::string{"missing/../literal.cpp"});
Void::Testing::expect(target.record().sources.at(0).kind == vbs::SourceKind::file);
Void::Testing::expect(target.record().sources.at(1).kind == vbs::SourceKind::glob);
Void::Testing::expect(target.record().sources.at(0).kind == Void::Build::SourceKind::File);
Void::Testing::expect(target.record().sources.at(1).kind == Void::Build::SourceKind::Glob);
Void::Testing::expect_eq(target.record().sources.at(1).path,
std::string{"nonexistent/**/*.cpp"});
}
Void::Testing::Test handles_survive_record_growth() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto library = project.static_library("first");
auto dependency = project.dependency("original");
const auto imported = dependency.target("Original::Library");
@@ -83,7 +89,7 @@ Void::Testing::Test handles_survive_record_growth() {
(void)project.executable("target" + std::to_string(i));
(void)project.dependency("dependency" + std::to_string(i));
}
dependency.git("https://example.invalid/library.git", vbs::Commit{revision}).cmake();
dependency.git("https://example.invalid/library.git", Void::Build::Commit{revision}).cmake();
library.compile_option("-Wextra");
auto app = project.executable("last");
app.link(library).link(imported);
@@ -95,8 +101,8 @@ Void::Testing::Test handles_survive_record_growth() {
}
Void::Testing::Test rejects_cross_project_links() {
vbs::Project first{context()};
vbs::Project second{context()};
Void::Build::Project first{context()};
Void::Build::Project second{context()};
auto app = first.executable("app");
auto other = second.static_library("other");
auto imported = second.dependency("remote").target("Remote::Library");
@@ -106,18 +112,18 @@ Void::Testing::Test rejects_cross_project_links() {
}
Void::Testing::Test rejects_expired_handles_and_owner_moves() {
static_assert(!std::is_move_constructible_v<vbs::Project>);
static_assert(!std::is_copy_constructible_v<vbs::Project>);
std::optional<vbs::Target> target;
std::optional<vbs::Dependency> dependency;
std::optional<vbs::ImportedTarget> imported;
static_assert(!std::is_move_constructible_v<Void::Build::Project>);
static_assert(!std::is_copy_constructible_v<Void::Build::Project>);
std::optional<Void::Build::Target> target;
std::optional<Void::Build::Dependency> dependency;
std::optional<Void::Build::ImportedTarget> imported;
{
vbs::Project project{context()};
Void::Build::Project project{context()};
target = project.executable("expired");
dependency = project.dependency("expired");
imported = dependency->target("Expired::Target");
}
vbs::Project replacement{context()};
Void::Build::Project replacement{context()};
auto app = replacement.executable("new");
Void::Testing::expect_throw<std::logic_error>([&] { target->compile_option("-g"); });
Void::Testing::expect_throw<std::logic_error>([&] { dependency->cmake(); });
@@ -127,7 +133,7 @@ Void::Testing::Test rejects_expired_handles_and_owner_moves() {
}
Void::Testing::Test rejects_empty_and_duplicate_identifiers() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto app = project.executable("app");
auto dep = project.dependency("dep");
Void::Testing::expect_throw<std::invalid_argument>(
@@ -138,50 +144,51 @@ Void::Testing::Test rejects_empty_and_duplicate_identifiers() {
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)dep.target(""); });
Void::Testing::expect_throw<std::invalid_argument>([&] { app.include_directory(""); });
Void::Testing::expect_throw<std::invalid_argument>([&] { app.compile_option(""); });
Void::Testing::expect_throw<std::invalid_argument>([] { (void)vbs::SourceSet::file(""); });
Void::Testing::expect_throw<std::invalid_argument>(
[] { (void)Void::Build::SourceSet::file(""); });
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)project.glob(""); });
}
Void::Testing::Test rejects_contradictory_providers() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto git = project.dependency("git");
git.git("https://example.invalid/repo", vbs::Commit{revision}).cmake();
git.git("https://example.invalid/repo", Void::Build::Commit{revision}).cmake();
Void::Testing::expect_throw<std::invalid_argument>([&] { git.package("pkg", "^1"); });
Void::Testing::expect_throw<std::invalid_argument>(
[&] { git.git("url", vbs::Commit{revision}); });
[&] { git.git("url", Void::Build::Commit{revision}); });
Void::Testing::expect_throw<std::invalid_argument>([&] { git.cmake(); });
auto package = project.dependency("package");
package.package("pkg", "^1");
Void::Testing::expect_throw<std::invalid_argument>(
[&] { package.git("url", vbs::Commit{revision}); });
[&] { package.git("url", Void::Build::Commit{revision}); });
Void::Testing::expect_throw<std::invalid_argument>([&] { package.cmake(); });
auto builder = project.dependency("builder");
builder.cmake();
Void::Testing::expect_throw<std::invalid_argument>([&] { builder.package("pkg", "^1"); });
Void::Testing::expect_throw<std::invalid_argument>(
[&] { builder.git("url", vbs::Commit{"main"}); });
[&] { builder.git("url", Void::Build::Commit{"main"}); });
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)project.to_json(); });
}
Void::Testing::Test json_schema_types_and_escaping() {
vbs::Project project{context()};
Void::Build::Project project{context()};
std::string escaped = "quote\" slash\\ newline\n\r\t";
for (char c = 0; c < 32; ++c)
escaped += c;
auto dep = project.dependency("dependency");
dep.git("https://example.invalid/\"repo", vbs::Commit{revision})
dep.git("https://example.invalid/\"repo", Void::Build::Commit{revision})
.cmake({{"string", escaped},
{"literal", "text"},
{"bool", false},
{"integer", -42},
{"maximum", std::numeric_limits<std::int64_t>::max()}});
auto library = project.static_library("library");
library.sources(vbs::SourceSet::file(escaped))
library.sources(Void::Build::SourceSet::file(escaped))
.sources(project.glob("src/**/*.cpp"))
.include_directory("include", vbs::Visibility::public_)
.include_directory("include", Void::Build::Visibility::Public)
.link(dep.target("Remote::Library"));
auto app = project.executable("app");
app.link(library, vbs::Visibility::public_).compile_option(escaped);
app.link(library, Void::Build::Visibility::Public).compile_option(escaped);
project.dependency("package").package("org/pkg", ">=1.2 <2");
const auto json = project.to_json();
Void::Testing::expect_eq(json, project.to_json());
@@ -215,9 +222,11 @@ Void::Testing::Test json_preserves_valid_utf8() {
// Boundary scalar values for every UTF-8 width, including either side of surrogates.
const std::string unicode = "ASCII \xc2\x80\xdf\xbf\xe0\xa0\x80\xed\x9f\xbf"
"\xee\x80\x80\xef\xbf\xbf\xf0\x90\x80\x80\xf4\x8f\xbf\xbf";
vbs::Project project{context()};
project.executable(unicode).sources(vbs::SourceSet::file(unicode));
project.dependency("unicode").git("url", vbs::Commit{revision}).cmake({{unicode, unicode}});
Void::Build::Project project{context()};
project.executable(unicode).sources(Void::Build::SourceSet::file(unicode));
project.dependency("unicode")
.git("url", Void::Build::Commit{revision})
.cmake({{unicode, unicode}});
const auto json = project.to_json();
Void::Testing::expect(json.find(unicode) != std::string::npos);
const auto parsed = Void::Json::Strict::parse(json);
@@ -240,35 +249,39 @@ Void::Testing::Test json_rejects_malformed_utf8() {
"\xff"};
for (const auto &bytes : invalid) {
const auto malformed = "prefix" + bytes + "suffix";
vbs::Project named{context()};
Void::Build::Project named{context()};
(void)named.executable(bytes);
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)named.to_json(); });
vbs::Project sourced{context()};
sourced.executable("source").sources(vbs::SourceSet::file(malformed));
Void::Build::Project sourced{context()};
sourced.executable("source").sources(Void::Build::SourceSet::file(malformed));
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)sourced.to_json(); });
vbs::Project keyed{context()};
keyed.dependency("key").git("url", vbs::Commit{revision}).cmake({{malformed, true}});
Void::Build::Project keyed{context()};
keyed.dependency("key")
.git("url", Void::Build::Commit{revision})
.cmake({{malformed, true}});
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)keyed.to_json(); });
vbs::Project valued{context()};
valued.dependency("value").git("url", vbs::Commit{revision}).cmake({{"option", malformed}});
Void::Build::Project valued{context()};
valued.dependency("value")
.git("url", Void::Build::Commit{revision})
.cmake({{"option", malformed}});
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)valued.to_json(); });
auto profile = context();
profile.compile_options.push_back(malformed);
vbs::Project configured{profile};
Void::Build::Project configured{profile};
Void::Testing::expect_throw<std::invalid_argument>([&] { (void)configured.to_json(); });
}
}
Void::Testing::Test independent_projects_and_contexts() {
auto initial = context();
vbs::Project first{initial};
Void::Build::Project first{initial};
initial.name = "mutated";
vbs::Project second{
vbs::default_profiles().resolve("release", vbs::CompilerFamily::clang, "linux", "aarch64")};
Void::Build::Project second{Void::Build::default_profiles().resolve(
"release", Void::Build::CompilerFamily::Clang, "linux", "aarch64")};
first.executable("first").compile_option("-g");
Void::Testing::expect_eq(first.context().name, std::string{"debug"});
Void::Testing::expect_eq(second.context().name, std::string{"release"});
@@ -277,12 +290,12 @@ Void::Testing::Test independent_projects_and_contexts() {
}
Void::Testing::Test rejects_option_errors_without_mutation() {
vbs::Project project{context()};
Void::Build::Project project{context()};
auto dep = project.dependency("library");
Void::Testing::expect_throw<std::invalid_argument>([&] { dep.cmake({{"", true}}); });
Void::Testing::expect(dep.record().builder.empty());
Void::Testing::expect_throw<std::invalid_argument>(
[] { (void)vbs::OptionValue{std::numeric_limits<std::uint64_t>::max()}; });
dep.cmake({{"enabled", true}}).git("url", vbs::Commit{revision});
[] { (void)Void::Build::OptionValue{std::numeric_limits<std::uint64_t>::max()}; });
dep.cmake({{"enabled", true}}).git("url", Void::Build::Commit{revision});
Void::Testing::expect_eq(dep.record().options.size(), std::size_t{1});
}