Implement VoidBuildSystem v1 (Plans 01-19) with VoidLibrary integration
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
This commit is contained in:
1 parent
3cac890ce9
commit
ab64147f9d
114 files changed
+23777
-1392
No files matched your search
@@ -0,0 +1,130 @@
|
||||
#include "VbsSelfHostRecipe.hpp"
|
||||
|
||||
#include <Void/Build/Platform/FileOps.hpp>
|
||||
#include <Void/System/Types.hpp>
|
||||
#include <VoidLibrary/VoidLibraryRecipe.hpp>
|
||||
|
||||
#include <format>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Build::Recipes {
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error>
|
||||
add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config) {
|
||||
// 1. Emit stage-isolated BootstrapConfig.hpp inside stage_build_dir/generated/
|
||||
// (never reusing CMake bootstrap generated headers!).
|
||||
const auto gen_dir = config.stage_build_dir / "generated";
|
||||
const auto cfg_hpp = gen_dir / "Void" / "Build" / "BootstrapConfig.hpp";
|
||||
const std::string cfg_content =
|
||||
std::format("#pragma once\n"
|
||||
"#include <string_view>\n"
|
||||
"namespace Void::Build::Bootstrap {{\n"
|
||||
"inline constexpr std::string_view version = \"{}\";\n"
|
||||
"inline constexpr std::string_view os = \"{}\";\n"
|
||||
"inline constexpr std::string_view architecture = \"{}\";\n"
|
||||
"inline constexpr std::string_view source_dir = \"{}\";\n"
|
||||
"inline constexpr std::string_view binary_dir = \"{}\";\n"
|
||||
"inline constexpr std::string_view sdk_include_dir = \"{}\";\n"
|
||||
"inline constexpr std::string_view sdk_source_dir = \"{}\";\n"
|
||||
"}}\n",
|
||||
config.version, project.context().os, project.context().architecture,
|
||||
config.vbs_source_dir.lexically_normal().string(),
|
||||
config.stage_build_dir.lexically_normal().string(),
|
||||
(config.vbs_source_dir / "include").lexically_normal().string(),
|
||||
(config.vbs_source_dir / "src").lexically_normal().string());
|
||||
|
||||
if (auto w = Platform::atomic_write_file(cfg_hpp, cfg_content, false); !w) {
|
||||
return std::unexpected{w.error()};
|
||||
}
|
||||
|
||||
// 2. Declare the native VoidLibrary module closure (pure C++26, zero CMake).
|
||||
std::vector<std::string> void_mods = {"Configuration", "Text", "Unicode", "Async",
|
||||
"Algorithms"};
|
||||
if (config.include_tests) {
|
||||
void_mods.push_back("Testing");
|
||||
}
|
||||
auto void_libs = add_void_library_native(project, config.void_source_dir, void_mods);
|
||||
|
||||
const auto root = config.vbs_source_dir.lexically_normal();
|
||||
|
||||
// 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()))
|
||||
.include_directory((root / "include").string(), Visibility::Public)
|
||||
.compile_option("-freflection", Visibility::Public)
|
||||
.define("VBS_HAS_VOID_UNICODE=1", Visibility::Private)
|
||||
.link(void_libs.modules.at("Unicode"), Visibility::Private);
|
||||
|
||||
// 4. VoidBuildCore (static library containing every native VBS engine module).
|
||||
auto core = project.static_library("VoidBuildCore");
|
||||
core.cxx_standard(CxxStandard::Cxx26)
|
||||
.include_directory((root / "include").string(), Visibility::Public)
|
||||
.include_directory((root / "recipes").string(), Visibility::Public)
|
||||
.compile_option("-freflection", Visibility::Public)
|
||||
.link(sdk, Visibility::Public)
|
||||
.link(void_libs.modules.at("Configuration"), Visibility::Public)
|
||||
.link(void_libs.modules.at("Text"), Visibility::Public)
|
||||
.link(void_libs.modules.at("Unicode"), Visibility::Public)
|
||||
.link(void_libs.modules.at("Async"), Visibility::Public)
|
||||
.link(void_libs.modules.at("Algorithms"), Visibility::Public);
|
||||
|
||||
const std::vector<std::string> core_sources = {
|
||||
"src/Util/Sha256.cpp",
|
||||
"src/Platform/FileOps.cpp",
|
||||
"src/Platform/ProcessSupervisor.cpp",
|
||||
"src/Toolchain/Driver.cpp",
|
||||
"src/Snapshot/Snapshot.cpp",
|
||||
"src/State/StateStore.cpp",
|
||||
"src/Graph/Graph.cpp",
|
||||
"src/Execution/Scheduler.cpp",
|
||||
"src/Config/Frontend.cpp",
|
||||
"src/Editor/CompDb.cpp",
|
||||
"src/Watch/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/Provider/Provider.cpp",
|
||||
"src/Install/Installer.cpp",
|
||||
"src/Bridge/CMakeBridge.cpp",
|
||||
"src/Modules/ModuleScanner.cpp",
|
||||
"src/SelfHost/TestRegistryGen.cpp",
|
||||
"recipes/VoidLibrary/VoidLibraryRecipe.cpp",
|
||||
"recipes/SelfHost/VbsSelfHostRecipe.cpp",
|
||||
};
|
||||
for (const auto &rel : core_sources) {
|
||||
core.sources(SourceSet::file((root / rel).string()));
|
||||
}
|
||||
|
||||
// 5. Full native `vbs` CLI executable.
|
||||
auto vbs = project.executable("vbs");
|
||||
vbs.cxx_standard(CxxStandard::Cxx26)
|
||||
.sources(SourceSet::file((root / "src" / "Main.cpp").string()))
|
||||
.include_directory(gen_dir.string(), Visibility::Private)
|
||||
.link(core);
|
||||
|
||||
// 6. Optional `VoidBuildRegistry` + `vbs-registry` server executable.
|
||||
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()))
|
||||
.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()))
|
||||
.include_directory(gen_dir.string(), Visibility::Private)
|
||||
.link(reg_lib);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Recipes
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Build.hpp>
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace Void::Build::Recipes {
|
||||
|
||||
struct VbsSelfHostConfig {
|
||||
std::filesystem::path vbs_source_dir;
|
||||
std::filesystem::path void_source_dir;
|
||||
std::filesystem::path stage_build_dir;
|
||||
std::string version{"0.1.0"};
|
||||
bool include_registry{true};
|
||||
bool include_tests{false};
|
||||
};
|
||||
|
||||
// Declares the COMPLETE native VoidBuildSystem target graph (VoidLibrary native closure +
|
||||
// VoidBuildSdk + VoidBuildCore + optional VoidBuildRegistry + generated BootstrapConfig.hpp +
|
||||
// vbs + optional vbs-registry) purely as native Void::Build targets — ZERO CMake! (Plan 18).
|
||||
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
|
||||
add_vbs_selfhost_native(Project &project, const VbsSelfHostConfig &config);
|
||||
|
||||
} // namespace Void::Build::Recipes
|
||||
@@ -0,0 +1,113 @@
|
||||
#include "VoidLibraryRecipe.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Void::Build::Recipes {
|
||||
namespace {
|
||||
|
||||
struct ModuleDef {
|
||||
std::vector<std::string> internal_deps;
|
||||
bool needs_threads{false};
|
||||
};
|
||||
|
||||
const std::map<std::string, ModuleDef, std::less<>> &known_modules() {
|
||||
static const std::map<std::string, ModuleDef, std::less<>> kDefs = {
|
||||
{"Core", {{}, false}},
|
||||
{"Functional", {{}, false}},
|
||||
{"Math", {{}, false}},
|
||||
{"Algorithms", {{"Core", "Math"}, false}},
|
||||
{"Memory", {{"Core"}, false}},
|
||||
{"Time", {{}, false}},
|
||||
{"Text", {{}, false}},
|
||||
{"Unicode", {{"Core", "Text"}, false}},
|
||||
{"LogState", {{}, false}},
|
||||
{"Data", {{"Core", "Math", "Time"}, false}},
|
||||
{"System", {{"Functional", "Time", "LogState"}, true}},
|
||||
{"Async", {{"Functional", "Time", "LogState"}, true}},
|
||||
{"Configuration", {{"Core", "Functional", "System", "Data", "Time", "LogState"}, true}},
|
||||
{"Testing", {{"Core", "Functional", "Time", "LogState", "Configuration", "Text"}, true}},
|
||||
};
|
||||
return kDefs;
|
||||
}
|
||||
|
||||
std::vector<std::string> collect_sources(const std::filesystem::path &src_dir) {
|
||||
std::vector<std::string> files;
|
||||
std::error_code ec;
|
||||
if (!std::filesystem::is_directory(src_dir, ec)) {
|
||||
return files;
|
||||
}
|
||||
for (const auto &ent : std::filesystem::recursive_directory_iterator(src_dir, ec)) {
|
||||
if (ent.is_regular_file(ec) && ent.path().extension() == ".cpp") {
|
||||
files.push_back(ent.path().lexically_normal().string());
|
||||
}
|
||||
}
|
||||
std::ranges::sort(files);
|
||||
return files;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
VoidLibraryTargets add_void_library_native(Project &project,
|
||||
const std::filesystem::path &void_source_dir,
|
||||
const std::vector<std::string> &enabled_modules) {
|
||||
const auto &defs = known_modules();
|
||||
|
||||
// Compute transitive module closure in deterministic topological order.
|
||||
std::set<std::string> visited;
|
||||
std::vector<std::string> topo;
|
||||
auto visit = [&](auto &&self, const std::string &mod) -> void {
|
||||
if (!visited.insert(mod).second) {
|
||||
return;
|
||||
}
|
||||
const auto it = defs.find(mod);
|
||||
if (it == defs.end()) {
|
||||
throw std::invalid_argument{"VoidLibraryRecipe: unsupported native module '" + mod +
|
||||
"'"};
|
||||
}
|
||||
for (const auto &dep : it->second.internal_deps) {
|
||||
self(self, dep);
|
||||
}
|
||||
topo.push_back(mod);
|
||||
};
|
||||
for (const auto &mod : enabled_modules) {
|
||||
visit(visit, mod);
|
||||
}
|
||||
|
||||
const auto include_dir = (void_source_dir / "include").lexically_normal().string();
|
||||
VoidLibraryTargets result;
|
||||
|
||||
for (const auto &mod : topo) {
|
||||
const auto &def = defs.at(mod);
|
||||
const auto srcs = collect_sources(void_source_dir / "src" / mod);
|
||||
const std::string target_name = "Void_" + mod;
|
||||
|
||||
Target tgt = srcs.empty() ? project.header_only_library(target_name)
|
||||
: project.static_library(target_name);
|
||||
tgt.cxx_standard(CxxStandard::Cxx26)
|
||||
.include_directory(include_dir, Visibility::Public)
|
||||
.compile_option("-freflection", Visibility::Public);
|
||||
|
||||
for (const auto &s : srcs) {
|
||||
tgt.sources(SourceSet::file(s));
|
||||
}
|
||||
for (const auto &dep : def.internal_deps) {
|
||||
tgt.link(result.modules.at(dep), Visibility::Public);
|
||||
}
|
||||
if (def.needs_threads) {
|
||||
tgt.link_option("-pthread", Visibility::Public);
|
||||
}
|
||||
if (mod == "Testing") {
|
||||
tgt.define("VOID_HAS_CONFIGURATION", Visibility::Public)
|
||||
.define("VOID_HAS_TEXT", Visibility::Public);
|
||||
}
|
||||
result.modules.emplace(mod, tgt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Recipes
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Build.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Build::Recipes {
|
||||
|
||||
// Pure native VBS recipe for VoidLibrary (pinned commit 9931c5ffc4844a5e09e1b1db35b3d29c5097c3a5).
|
||||
// Translates VoidLibrary's module closure directly into native VBS targets without invoking
|
||||
// CMake or modifying the VoidLibrary source checkout (Plan 18).
|
||||
struct VoidLibraryTargets {
|
||||
std::map<std::string, Target, std::less<>> modules;
|
||||
};
|
||||
|
||||
[[nodiscard]] VoidLibraryTargets
|
||||
add_void_library_native(Project &project, const std::filesystem::path &void_source_dir,
|
||||
const std::vector<std::string> &enabled_modules = {
|
||||
"Configuration", "Text", "Unicode", "Async", "Testing"});
|
||||
|
||||
} // namespace Void::Build::Recipes
|
||||
Reference in new issue
Block a user