Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d80649b8c | ||
|
|
e44612b505 | ||
|
|
9f0fa67f56 |
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# Native VoidBuildSystem build for VoidLibrary.
|
||||
# Template: adapt runner labels and toolchain packages to the actual CI runner.
|
||||
name: VoidLibrary (VBS)
|
||||
on:
|
||||
push:
|
||||
branches: [main, build-vbs]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
vbs-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install toolchain and system libraries
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y cmake ninja-build g++ libssl-dev libboost-all-dev \
|
||||
libsqlite3-dev libsodium-dev liblua5.4-dev
|
||||
|
||||
- name: Bootstrap VoidBuildSystem
|
||||
run: |
|
||||
git clone --depth 1 https://git.faumaray.com/Void/Build-System.git /tmp/vbs-src
|
||||
cmake -S /tmp/vbs-src -B /tmp/vbs-build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build /tmp/vbs-build --parallel 4 --target vbs
|
||||
|
||||
- name: Native build
|
||||
run: /tmp/vbs-build/bin/vbs build --project . --build-dir build-vbs --jobs 4
|
||||
|
||||
- name: Native smoke test
|
||||
run: /tmp/vbs-build/bin/vbs test --project . --build-dir build-vbs --target void_smoke --jobs 4
|
||||
|
||||
- name: Install check
|
||||
run: |
|
||||
/tmp/vbs-build/bin/vbs install --project . --build-dir build-vbs \
|
||||
--prefix "$PWD/dist" --package-name VoidLibrary --package-version 0.1.0
|
||||
test -d dist/include/Void
|
||||
test -n "$(ls dist/lib/*.a | head -1)"
|
||||
@@ -0,0 +1,171 @@
|
||||
#include "VoidLibraryModules.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}},
|
||||
{"Crypto", {{"Functional"}, false}},
|
||||
{"Archive", {{"Functional", "Time", "System"}, false}},
|
||||
{"Configuration", {{"Core", "Functional", "System", "Data", "Time", "LogState"}, true}},
|
||||
{"Log", {{"Async", "Core", "Data", "Functional", "Memory", "Time", "LogState"}, true}},
|
||||
{"Testing",
|
||||
{{"Core", "Functional", "Time", "LogState", "Async", "Configuration", "Text"}, true}},
|
||||
{"Containers", {{"Core", "Memory"}, false}},
|
||||
{"Binary", {{"Functional", "Memory"}, false}},
|
||||
{"IO", {{"Core", "Functional", "Time", "Memory", "Async"}, false}},
|
||||
{"Service", {{"Core", "Functional", "Time", "Async", "LogState"}, false}},
|
||||
{"ObservabilityHooks", {{}, false}},
|
||||
{"Resilience", {{"Functional", "Time", "ObservabilityHooks"}, false}},
|
||||
{"Storage", {{"Core", "Functional", "Time", "Memory", "Binary", "IO", "Async"}, false}},
|
||||
{"IPC",
|
||||
{{"Core", "Functional", "Memory", "Time", "Binary", "Async", "IO", "Resilience"},
|
||||
false}},
|
||||
{"Fsm", {{"Async", "Core", "Data", "Functional", "Time", "Log", "Service"}, false}},
|
||||
// External dependencies (linked by the embedding build): OpenSSL/Boost for Net,
|
||||
// SQLite3 for Sqlite.
|
||||
{"Net", {{"Functional", "Text"}, true}},
|
||||
{"Sqlite", {{"Functional", "Time"}, false}},
|
||||
{"ConfigurationAsync", {{"Configuration", "SystemAsync", "Async", "Time", "Functional", "LogState"}, false}},
|
||||
{"CryptoAsync", {{"Crypto", "IO", "Async", "Time", "Functional"}, true}},
|
||||
{"Discovery", {{"Core", "Functional", "Time", "Async"}, false}},
|
||||
{"DiscoveryRpc", {{"Discovery", "RPC"}, false}},
|
||||
{"FunctionalCoreFormatting", {{"Functional", "Core"}, false}},
|
||||
{"IPC", {{"Core", "Functional", "Memory", "Time", "Binary", "Async", "IO", "Resilience"}, false}},
|
||||
{"LogConfig", {{"Log", "Configuration", "Functional"}, false}},
|
||||
{"MCP", {{"Functional", "Data"}, false}},
|
||||
{"Messaging", {{"Core", "Functional", "Binary", "Time", "Async"}, false}},
|
||||
{"MessagingRpc", {{"Messaging", "RPC"}, false}},
|
||||
{"MessagingStorage", {{"Messaging", "Storage"}, false}},
|
||||
{"Observability", {{"ObservabilityHooks", "Core", "Functional", "Time", "Memory"}, false}},
|
||||
{"Plugin", {{"Core", "Functional", "System", "Data", "Time", "Async", "LogState", "Text", "Service"}, false}},
|
||||
{"RPC", {{"Core", "Functional", "Binary", "Data", "Time", "Async", "Net"}, false}},
|
||||
{"ResilienceAsync", {{"Resilience", "Async", "Functional", "Time", "ObservabilityHooks"}, false}},
|
||||
{"Runtime", {{"Core", "Functional", "Time", "Memory", "Algorithms", "Async", "IO"}, false}},
|
||||
{"Scheduler", {{"Core", "Functional", "Time", "Async"}, false}},
|
||||
{"SchedulerStorage", {{"Scheduler", "Storage"}, false}},
|
||||
{"Script", {{}, false}},
|
||||
{"Security", {{"Functional", "Time"}, false}},
|
||||
{"SecurityAsync", {{"Security", "Async", "Time", "Resilience", "Functional"}, true}},
|
||||
{"ServicePlugin", {{"Service", "Plugin", "LogState"}, false}},
|
||||
{"ShortUrl", {{"Service", "Time"}, false}},
|
||||
{"ShortUrlRemote", {{"ShortUrl", "Net", "Data"}, false}},
|
||||
{"ShortUrlStorage", {{"ShortUrl", "Storage", "Security"}, false}},
|
||||
{"SqliteAsync", {{"Sqlite", "Async", "Time", "Functional"}, false}},
|
||||
{"Stacktrace", {{"Functional", "Time", "LogState"}, true}},
|
||||
{"SystemAsync", {{"System", "Async", "IO", "Time", "Functional", "LogState"}, true}},
|
||||
{"Testing", {{"Core", "Functional", "Time", "LogState", "Stacktrace", "Log", "Async", "Configuration", "Text"}, false}},
|
||||
{"TestingMock", {{"Core", "Testing", "Functional"}, false}},
|
||||
{"Update", {{"Archive", "Crypto", "Data", "Functional", "System", "Text", "Time"}, false}},
|
||||
};
|
||||
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);
|
||||
if (project.context().compiler == CompilerFamily::Gcc) {
|
||||
tgt.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 == "Crypto") {
|
||||
tgt.define("VOID_CRYPTO_HAS_OPENSSL=0", Visibility::Public);
|
||||
}
|
||||
if (mod == "Archive") {
|
||||
tgt.define("VOID_ARCHIVE_HAS_LIBARCHIVE=0", Visibility::Public);
|
||||
}
|
||||
if (mod == "Testing") {
|
||||
tgt.define("VOID_HAS_ASYNC", Visibility::Public)
|
||||
.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 0002e74a7da94a756f55a4a5574d20b77736c185).
|
||||
// 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
|
||||
@@ -0,0 +1,52 @@
|
||||
// Native VoidBuildSystem description for VoidLibrary itself (migration trial).
|
||||
// The module closure is declared in build-support/vl/VoidLibraryModules.{hpp,cpp}.
|
||||
#include "build-support/vl/VoidLibraryModules.hpp"
|
||||
|
||||
void build(Void::Build::Project &project) {
|
||||
const auto &ctx = project.context();
|
||||
(void)ctx;
|
||||
|
||||
auto libs = Void::Build::Recipes::add_void_library_native(
|
||||
project, ".",
|
||||
{"Algorithms", "Archive", "Async", "Binary", "Configuration", "ConfigurationAsync", "Containers", "Core", "Data", "Discovery", "DiscoveryRpc", "Fsm", "Functional", "FunctionalCoreFormatting", "IO", "IPC", "Log", "LogConfig", "LogState", "MCP", "Math", "Memory", "Messaging", "MessagingRpc", "MessagingStorage", "Observability", "ObservabilityHooks", "Plugin", "RPC", "Resilience", "ResilienceAsync", "Runtime", "Scheduler", "SchedulerStorage", "Service", "ServicePlugin", "ShortUrl", "ShortUrlRemote", "ShortUrlStorage", "SqliteAsync", "Storage", "Testing", "TestingMock", "Text", "Time", "Unicode", "Update", "Net", "Sqlite", "Security", "SecurityAsync", "Script", "Stacktrace", "SystemAsync", "CryptoAsync" });
|
||||
|
||||
// System libraries for the externally dependent modules (provided by the shell).
|
||||
if (auto it = libs.modules.find("Net"); it != libs.modules.end()) {
|
||||
it->second.link_option("-lssl", Void::Build::Visibility::Public)
|
||||
.link_option("-lcrypto", Void::Build::Visibility::Public)
|
||||
.link_option("-lboost_url", Void::Build::Visibility::Public)
|
||||
.link_option("-ldl", Void::Build::Visibility::Public);
|
||||
}
|
||||
if (auto it = libs.modules.find("Sqlite"); it != libs.modules.end()) {
|
||||
it->second.link_option("-lsqlite3", Void::Build::Visibility::Public);
|
||||
}
|
||||
for (const char *secure : {"Security", "SecurityAsync"}) {
|
||||
if (auto it = libs.modules.find(secure); it != libs.modules.end()) {
|
||||
it->second.link_option("-lsodium", Void::Build::Visibility::Public);
|
||||
}
|
||||
}
|
||||
if (auto it = libs.modules.find("Script"); it != libs.modules.end()) {
|
||||
it->second.link_option("-llua", Void::Build::Visibility::Public);
|
||||
}
|
||||
if (auto it = libs.modules.find("Stacktrace"); it != libs.modules.end()) {
|
||||
it->second.link_option("-lboost_stacktrace_addr2line", Void::Build::Visibility::Public)
|
||||
.link_option("-ldl", Void::Build::Visibility::Public);
|
||||
}
|
||||
|
||||
// Install/packaging rules: module archives, public headers and license metadata.
|
||||
for (auto &[name, target] : libs.modules) {
|
||||
if (target.record().kind == Void::Build::TargetKind::HeaderOnly) {
|
||||
continue;
|
||||
}
|
||||
target.install("lib");
|
||||
}
|
||||
project.install_directory("include", "include");
|
||||
project.install_file("README.md", "share/doc/VoidLibrary");
|
||||
|
||||
// Smoke test exercising the native VoidLibrary closure through VBS.
|
||||
auto smoke = project.test("void_smoke");
|
||||
smoke.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"tests/vl/smoke.cpp"})
|
||||
.link(libs.modules.at("Testing"))
|
||||
.link(libs.modules.at("Configuration"));
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <Void/Build.hpp>
|
||||
|
||||
// VoidLibrary native profiles: debug (default) and release, plus an optimized
|
||||
// "relwithdebinfo" variant useful for sanitizer and benchmark runs.
|
||||
void profiles(Void::Build::Profiles &descriptions) {
|
||||
descriptions = Void::Build::default_profiles();
|
||||
descriptions.add("relwithdebinfo", {"-O2", "-g"});
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <Void/Configuration/Env.hpp>
|
||||
|
||||
int main() {
|
||||
const auto value = Void::Configuration::get_env_or("VBS_VOID_MIGRATION_SMOKE", "fallback");
|
||||
return value == "fallback" ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user