feat(daemon): serve IDE workspace and compdb metadata over the Unix socket
This commit is contained in:
1 parent
e97f3905e5
commit
118c0dc860
9 files changed
+152
-8
No files matched your search
+23
-3
@@ -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 == "ide_query") {
|
||||
if (opts.profile_arg.empty()) {
|
||||
std::cerr << "vbs daemon ide query: --profile must not be empty\n";
|
||||
return 2;
|
||||
}
|
||||
request_json =
|
||||
std::format(R"({{"op":"ide_query","profile":{}}})", Util::json_quote(opts.profile_arg));
|
||||
} else if (sub == "build") {
|
||||
std::size_t jobs = 0;
|
||||
const auto [ptr, ec] = std::from_chars(opts.jobs_arg.data(),
|
||||
@@ -1467,8 +1474,9 @@ 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}
|
||||
: std::chrono::milliseconds{2000};
|
||||
: sub == "describe" ? std::chrono::milliseconds{15000}
|
||||
: sub == "ide_query" ? 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';
|
||||
@@ -2411,6 +2419,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_ide_cmd = daemon_cmd.subcommand("ide", "Editor/IDE metadata served by the daemon");
|
||||
configure_daemon_common(daemon_ide_cmd);
|
||||
auto &daemon_ide_query_cmd =
|
||||
daemon_ide_cmd.subcommand("query", "Emit IDE workspace/target/compdb metadata JSON");
|
||||
configure_daemon_common(daemon_ide_query_cmd);
|
||||
daemon_ide_query_cmd.option_default("--profile", "-p", "Profile to query",
|
||||
daemon_opts.profile_arg, "debug");
|
||||
|
||||
const auto parsed = root.parse_detailed(argc, argv);
|
||||
if (parsed.is_help()) {
|
||||
@@ -2503,7 +2518,12 @@ int main(int argc, char **argv) {
|
||||
return execute_ide_command(parsed.matched_command_path.at(1), ide_opts);
|
||||
}
|
||||
if (cmd == "daemon") {
|
||||
return execute_daemon_command(parsed.matched_command_path.at(1), daemon_opts);
|
||||
std::string daemon_sub = parsed.matched_command_path.at(1);
|
||||
if (daemon_sub == "ide" && parsed.matched_command_path.size() > 2 &&
|
||||
parsed.matched_command_path[2] == "query") {
|
||||
daemon_sub = "ide_query";
|
||||
}
|
||||
return execute_daemon_command(daemon_sub, daemon_opts);
|
||||
}
|
||||
|
||||
std::cerr << "vbs: unhandled subcommand '" << cmd << "'\n";
|
||||
|
||||
Reference in new issue
Block a user