feat(daemon): materialize project dependencies for daemon build requests
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 58s

This commit is contained in:
faumaray committed 2026-12-03 19:32:06 +03:00
1 parent 42172a24f8
commit f5c0c9f09d
12 files changed
+580 -287

No files matched your search

+67
View File
@@ -368,6 +368,73 @@ void build(Void::Build::Project &project) {
Void::Testing::expect(!std::filesystem::exists(socket));
}
VOID_TEST(Daemon, build_materializes_path_dependency) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());
const auto options = make_options(temp->path());
const auto helper = temp->path() / "helper";
std::filesystem::create_directories(helper);
{
std::ofstream descriptor{helper / "build.cpp"};
descriptor << R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &project) {
project.static_library("helper")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"helper.cpp"});
}
)cpp";
Void::Testing::require(descriptor.good());
}
{
std::ofstream source{helper / "helper.cpp"};
source << "int helper_value() { return 3; }\n";
Void::Testing::require(source.good());
}
{
std::ofstream descriptor{options.project_root / "build.cpp"};
descriptor << "#include <Void/Build.hpp>\n"
"void build(Void::Build::Project &project) {\n"
" auto dep = project.dependency(\"helper\")\n"
" .path(\"" +
helper.string() +
"\")\n"
" .native_builder();\n"
" auto app = project.executable(\"app\");\n"
" app.cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
" .sources({\"main.cpp\"})\n"
" .link(dep.target(\"helper\"));\n"
"}\n";
Void::Testing::require(descriptor.good());
}
{
std::ofstream source{options.project_root / "main.cpp"};
source << "int helper_value();\nint main() { return helper_value() == 3 ? 0 : 1; }\n";
Void::Testing::require(source.good());
}
auto server = Void::Build::Daemon::DaemonServer::create(options);
Void::Testing::require(server.has_value());
const auto socket = server->socket_path();
Void::Result::Result<void, Void::Result::Error> run_result;
std::jthread worker{[&] { run_result = server->run(); }};
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
auto build = request_object(socket, R"({"op":"build"})", std::chrono::seconds{120});
Void::Testing::require(build.has_value());
Void::Testing::expect(bool_field(*build, "ok"));
Void::Testing::expect(int_field(*build, "dependencies") >= 1);
Void::Testing::expect(
std::filesystem::exists(options.build_root / "profiles" / "debug" / "out" / "bin" / "app"));
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
Void::Testing::expect(shutdown.has_value());
worker.join();
Void::Testing::expect(run_result.has_value());
}
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
Void::Testing::require(temp.has_value());