feat(daemon,platform): add Unix-socket daemon core, split Linux platform backends, and fix CMake feature-carrier translation
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s

This commit is contained in:
faumaray committed 2026-12-03 16:10:25 +03:00
1 parent 55ea305528
commit 0bde74f739
20 files changed
+1194 -21

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <memory>
#include <stop_token>
#include <string>
#include <string_view>
namespace Void::Build::Daemon {
struct DaemonOptions {
std::filesystem::path project_root;
std::filesystem::path build_root;
std::filesystem::path socket_path; // empty => build_root/".vbs/vbs-daemon.sock"
std::chrono::milliseconds poll_interval{200};
std::size_t max_requests{0}; // 0 => unlimited
};
struct DaemonStatus {
std::uint64_t pid{};
std::uint64_t uptime_ms{};
std::size_t recorded_actions{};
std::size_t watched_directories{};
std::uint64_t watch_events{};
std::string last_event_path;
std::uint64_t sequence{};
};
// Bounded single-threaded Unix-domain-socket daemon holding a warm StateStore and
// InotifyWatcher for the project root (Track E3). Requests are one JSON object per
// line; responses are one JSON object per line.
class DaemonServer {
public:
~DaemonServer();
DaemonServer(const DaemonServer &) = delete;
DaemonServer &operator=(const DaemonServer &) = delete;
DaemonServer(DaemonServer &&) noexcept;
DaemonServer &operator=(DaemonServer &&) noexcept;
[[nodiscard]] static Void::Result::Result<DaemonServer, Void::Result::Error>
create(DaemonOptions options);
// Serves until `stop` is requested, a `shutdown` request arrives, or max_requests is hit.
[[nodiscard]] Void::Result::Result<void, Void::Result::Error> run(std::stop_token stop = {});
[[nodiscard]] const std::filesystem::path &socket_path() const noexcept;
[[nodiscard]] DaemonStatus status() const;
private:
struct Impl;
explicit DaemonServer(std::unique_ptr<Impl> impl) noexcept;
std::unique_ptr<Impl> impl_;
};
// Sends one newline-delimited JSON request and returns the response line.
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
request(const std::filesystem::path &socket_path, std::string_view request_json,
std::chrono::milliseconds timeout = std::chrono::milliseconds{2000});
} // namespace Void::Build::Daemon
+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include <string_view>
namespace Void::Build::Platform {
// The host operating system this build of VoidBuildSystem runs on.
enum class HostOs { Linux, MacOS, Windows, Unknown };
[[nodiscard]] constexpr HostOs host_os() noexcept {
#if defined(__linux__)
return HostOs::Linux;
#elif defined(__APPLE__)
return HostOs::MacOS;
#elif defined(_WIN32)
return HostOs::Windows;
#else
return HostOs::Unknown;
#endif
}
[[nodiscard]] constexpr std::string_view host_os_name(HostOs os) noexcept {
switch (os) {
case HostOs::Linux:
return "Linux";
case HostOs::MacOS:
return "macOS";
case HostOs::Windows:
return "Windows";
case HostOs::Unknown:
break;
}
return "Unknown";
}
// macOS/Windows ports are planned (Track C2/C3); the process and file backends
// currently support Linux hosts only.
[[nodiscard]] constexpr bool host_supported() noexcept { return host_os() == HostOs::Linux; }
} // namespace Void::Build::Platform