feat(daemon): export the profile compilation database over the Unix socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 16s

This commit is contained in:
faumaray committed 2026-12-03 20:30:19 +03:00
1 parent 8001d98bb7
commit 72f4237af2
9 files changed
+153 -21

No files matched your search

+21 -3
View File
@@ -1443,6 +1443,13 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
}
request_json =
std::format(R"({{"op":"describe","profile":{}}})", Util::json_quote(opts.profile_arg));
} else if (sub == "compdb_export") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon compdb export: --profile must not be empty\n";
return 2;
}
request_json = std::format(R"({{"op":"compdb_export","profile":{}}})",
Util::json_quote(opts.profile_arg));
} else if (sub == "ide_query") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon ide query: --profile must not be empty\n";
@@ -1474,9 +1481,10 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
// Describe evaluates the whole project graph (descriptor compile, toolchain probe, lowering),
// which can exceed the 2 s default; the daemon bounds evaluation at 10 s.
const auto request_timeout = sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
: sub == "describe" ? std::chrono::milliseconds{15000}
: sub == "ide_query" ? std::chrono::milliseconds{30000}
: std::chrono::milliseconds{2000};
: sub == "describe" ? std::chrono::milliseconds{15000}
: (sub == "ide_query" || sub == "compdb_export")
? std::chrono::milliseconds{30000}
: std::chrono::milliseconds{2000};
auto response = Daemon::request(socket_path, request_json, request_timeout);
if (!response) {
std::cerr << "vbs daemon: " << response.error().message() << '\n';
@@ -2419,6 +2427,13 @@ int main(int argc, char **argv) {
.option_many("--target", "-t", "Target to build", daemon_opts.targets)
.option_default("--jobs", "-j", "Maximum parallel jobs (0 = hardware concurrency)",
daemon_opts.jobs_arg, "0");
auto &daemon_compdb_cmd =
daemon_cmd.subcommand("compdb", "Editor compilation database served by the daemon");
auto &daemon_compdb_export_cmd =
daemon_compdb_cmd.subcommand("export", "Publish the profile compilation database");
configure_daemon_common(daemon_compdb_export_cmd);
daemon_compdb_export_cmd.option_default("--profile", "-p", "Profile to export",
daemon_opts.profile_arg, "debug");
auto &daemon_ide_cmd = daemon_cmd.subcommand("ide", "Editor/IDE metadata served by the daemon");
configure_daemon_common(daemon_ide_cmd);
auto &daemon_ide_query_cmd =
@@ -2522,6 +2537,9 @@ int main(int argc, char **argv) {
if (daemon_sub == "ide" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "query") {
daemon_sub = "ide_query";
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "export") {
daemon_sub = "compdb_export";
}
return execute_daemon_command(daemon_sub, daemon_opts);
}