feat(daemon): generate editor configuration files over the Unix socket
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 38s

This commit is contained in:
faumaray committed 2026-12-03 20:38:09 +03:00
1 parent 72f4237af2
commit e15e2cb2b4
9 files changed
+189 -9

No files matched your search

+28 -5
View File
@@ -1364,6 +1364,8 @@ struct DaemonCmdOptions {
std::string profile_arg{"debug"};
std::vector<std::string> targets;
std::string jobs_arg{"0"};
std::string editor_arg{"all"};
bool force{false};
std::string max_bytes_arg{"0"};
std::string max_requests_arg{"0"};
};
@@ -1443,6 +1445,15 @@ 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 == "ide_generate") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon ide generate: --profile must not be empty\n";
return 2;
}
request_json =
std::format(R"({{"op":"ide_generate","profile":{},"editor":{},"force":{}}})",
Util::json_quote(opts.profile_arg), Util::json_quote(opts.editor_arg),
opts.force ? "true" : "false");
} else if (sub == "compdb_export") {
if (opts.profile_arg.empty()) {
std::cerr << "vbs daemon compdb export: --profile must not be empty\n";
@@ -1480,11 +1491,12 @@ 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" || sub == "compdb_export")
? std::chrono::milliseconds{30000}
: std::chrono::milliseconds{2000};
const auto request_timeout =
sub == "build" ? std::chrono::milliseconds{std::chrono::hours{1}}
: sub == "describe" ? std::chrono::milliseconds{15000}
: (sub == "ide_query" || sub == "ide_generate" || 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';
@@ -2441,6 +2453,14 @@ int main(int argc, char **argv) {
configure_daemon_common(daemon_ide_query_cmd);
daemon_ide_query_cmd.option_default("--profile", "-p", "Profile to query",
daemon_opts.profile_arg, "debug");
auto &daemon_ide_generate_cmd =
daemon_ide_cmd.subcommand("generate", "Write editor configuration files");
configure_daemon_common(daemon_ide_generate_cmd);
daemon_ide_generate_cmd
.option_default("--profile", "-p", "Profile to evaluate", daemon_opts.profile_arg, "debug")
.option_default("--editor", "-e", "Editor preset (all|clangd|vscode|clion|zed)",
daemon_opts.editor_arg, "all")
.flag("--force", "", "Overwrite existing IDE configuration files", daemon_opts.force);
const auto parsed = root.parse_detailed(argc, argv);
if (parsed.is_help()) {
@@ -2537,6 +2557,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 == "ide" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "generate") {
daemon_sub = "ide_generate";
} else if (daemon_sub == "compdb" && parsed.matched_command_path.size() > 2 &&
parsed.matched_command_path[2] == "export") {
daemon_sub = "compdb_export";