feat(daemon): support member-scoped IDE requests for workspaces
This commit is contained in:
1 parent
d6bbd95ced
commit
359783d2ad
8 files changed
+149
-65
No files matched your search
@@ -107,7 +107,7 @@ All CLI help text (`vbs --help`, `vbs <command> --help`, `vbs compdb --help`, `v
|
||||
- `vbs binaries list|fetch --registry URL --name PKG --version X.Y.Z [--variant ID --output FILE] [--token-env VAR]`
|
||||
- `vbs bridge --request FILE --output FILE` (backend for [cmake/bridge/VbsDeps.cmake](cmake/bridge/VbsDeps.cmake))
|
||||
- `vbs gc [--build-dir DIR] [--max-bytes N]`
|
||||
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|compdb export [--project DIR] [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
|
||||
- `vbs daemon run|status|stop|gc|recover|describe|build|ide query|ide generate|ide poll|ide wait|compdb export [--project DIR] [--member NAME]` [--build-dir DIR] [--socket PATH]` (Unix-socket daemon holding a warm state store and project watcher; `run` serves in the foreground, the rest are client requests)
|
||||
- `vbs gen-tests --input FILE --output-dir DIR`
|
||||
- `vbs-registry --data-dir DIR --web-root DIR [--bind ADDR] [--port PORT] ...`
|
||||
|
||||
|
||||
@@ -145,6 +145,10 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
- Daemon `build` accepts a `member` field for workspace roots (shared root `vbs.lock` via a new `lock_root` option) and builds that member's graph; a workspace build without `member` is rejected explicitly. `DaemonOptions` gained `lock_root` (empty = project root).
|
||||
- `Daemon.describe_and_build_workspace_members` replaces the old workspace-rejection test.
|
||||
|
||||
- **Wave 32 (Member-Scoped Daemon IDE Requests)**:
|
||||
- Extracted `resolve_member_options` (workspace member selection, shared root lock) and applied it to the daemon `ide_query`, `ide_generate`, and `compdb_export` requests; non-workspace roots reject `member`, workspace roots require it.
|
||||
- `vbs daemon ide query|generate` and `vbs daemon compdb export` accept `--member`; the workspace daemon test now covers member-scoped IDE query/generate (`.clangd` in the member directory) and the missing-member error.
|
||||
|
||||
## Remaining future scope
|
||||
|
||||
- **Post-v1 Expansion Roadmap ([21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md) & [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md))**: Live `conan` CLI verification (Track B3), Track C (macOS/Windows ports + dual-profile cross-compilation), Track D3 signing (SBOM, Ed25519 primitives, trusted-key enforcement and distribution, binary-variant signing and distribution materialization, the #52 built-in-backend capability probe, and the VoidLibrary pin bump to `0002e74` done), Track E3 (daemon core, bounded `describe`, build-serving, dependency materialization, daemon-backed IDE metadata, compdb export, IDE config generation, editor watch poll and bounded long-poll done; dedicated external editor plugins remain), and Track E4 (`Void::Net`/`Void::Sqlite` alignment) remain planned scope.
|
||||
|
||||
@@ -38,4 +38,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 29 (RegistryClient binary API + signed CLI) | `publish_binary_variant`/`fetch_binary_variants` in RegistryClient; `vbs publish-binary` CLI with optional signing; registry test extended | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `include/Void/Build/Package/RegistryClient.hpp`, `src/Package/RegistryClient.cpp`, `src/Main.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 30 (`vbs binaries list|fetch`) | CLI over `fetch_binary_variants`: list id/digest/size/signature state; fetch resolves the variant and downloads with SHA-256 verification | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry suite 6/6, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 31 (Daemon workspace support) | Workspace `describe` member summaries; workspace `build` with `member` + shared root lock (`DaemonOptions::lock_root`) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `include/Void/Build/Daemon/Daemon.hpp`, `src/Daemon/Daemon.cpp`, `tests/DaemonTests.cpp`, docs |
|
||||
| Wave 32 (Member-scoped daemon IDE) | `resolve_member_options` shared by daemon IDE query/generate and compdb export; `--member` CLI flags; workspace member IDE coverage | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 13/13, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, docs |
|
||||
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions, E4, live `conan`) | Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
|
||||
@@ -570,6 +570,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
|
||||
- Full CTest: **8 / 8 passed** in 208.57 s.
|
||||
- `clang-format --dry-run --Werror` passes on the changed C++ files.
|
||||
|
||||
## Member-Scoped Daemon IDE Requests (GCC 16.2, pin `0002e74`)
|
||||
|
||||
```sh
|
||||
dev cpp-gcc -c cmake --build build/pinned --parallel 8
|
||||
dev cpp-gcc -c build/pinned/bin/vbs_v1_tests --suite Daemon --no-color
|
||||
dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
|
||||
```
|
||||
|
||||
- Build: exit 0. Daemon suite: **13 / 13 passed** in 45.30 s; the workspace test now also checks
|
||||
that a workspace `ide_query` without `member` fails, and that `member:"app"` IDE query returns
|
||||
the member project root and `ws_app`, while IDE generate writes `packages/app/.clangd`.
|
||||
- Full CTest: **8 / 8 passed** in 211.77 s.
|
||||
- `clang-format --dry-run --Werror` passes on the changed C++ files.
|
||||
|
||||
## Limits and Unrun Checks
|
||||
|
||||
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
|
||||
|
||||
@@ -73,7 +73,7 @@ flowchart LR
|
||||
| --- | --- | --- |
|
||||
| **E1 — Everyday CLI Ergonomics (Implemented in Wave 8)** | `vbs init` project scaffolding, `vbs clean`, `vbs doctor` environment diagnostics, `vbs graph --format dot|json`, and `vbs build --native-foreign`. | End-to-end CLI & integration tests passing in `vbs_cli_contract` and `vbs_v1_tests`. |
|
||||
| **E2 — Multi-Package Workspaces (`workspace.cpp`)** *(verified in Docker GCC 16)* | Shared root `vbs.lock` and `build/.vbs` CAS, `workspace_dependency()` cross-member native linking, and affected-member selection (`vbs build/test --member <pkg>` / `--changed-since <ref>`). | 3-package workspace fixture (shared library + app + tests) builds/tests with one root lockfile; member selection and `--changed-since` verified in `FullV1Tests.workspace_members_shared_build_and_member_selection`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), and `vbs daemon ide wait` adds a bounded long-poll variant. Daemon workspace support now describes members and builds a selected member with the shared root lock. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E3 — IDE Config/Query & Background Daemon** | `build.cpp`/`build.profiles.cpp`/`build-support/` SDK entries in `compile_commands.json` + `vbs ide generate` (`.clangd`, `.vscode/`, `.zed/`, `.idea/customTargets.xml`) & `vbs ide query` (**Implemented & Verified in Wave 10**); Unix-socket daemon core holding a warm `StateStore` + project `DirectoryWatcher` with `vbs daemon run\|status\|stop\|gc\|recover\|describe` (**Implemented & Verified in Wave 14; bounded `describe` added in the post-v1 daemon follow-up**). `describe` returns a bounded graph summary (`target_names` ≤ 128 entries × 200 bytes, `profile` ≤ 128 bytes, 10 s evaluation timeout); `vbs daemon build` executes the lowered graph in-process against the warm state store with bounded `profile`/`targets`/`jobs`, including daemon-side dependency resolution/materialization and provider import via `Package::resolve_and_materialize_dependencies`; `vbs daemon ide query` publishes/selects the profile compilation database and serves the IDE workspace/target metadata JSON over the socket, `vbs daemon compdb export` returns the published compilation-database path and entry count, `vbs daemon ide generate` writes the editor presets over the socket, `vbs daemon ide poll` exposes a bounded editor-extension watch protocol (changed paths, sequence, overflow state), and `vbs daemon ide wait` adds a bounded long-poll variant. Daemon workspace support describes members, builds a selected member with the shared root lock, and serves member-scoped IDE query/generate/compdb requests via `--member`. Dedicated editor extensions remain planned. | `vbs ide` & `build.cpp` syntax-check verified in `FullV1Tests.cpp`; daemon lifecycle/status/gc/shutdown/describe verified in `DaemonTests.cpp` (6/6 under `dev cpp-gcc`); the live `vbs daemon describe` CLI round-trip is verified in `vbs_cli_contract`. |
|
||||
| **E4 — Transport & Storage Upstream Alignment** | Adopt `Void::Net` (`VL-004`/`VL-005`) and `Void::Sqlite` (`VL-011b`) when lightweight/bundled builds become available in minimal Nix toolchains, reducing VBS transport code further. | All `vbs_registry_tests` and `vbs_core_tests` pass on both minimal and full toolchains. |
|
||||
|
||||
---
|
||||
|
||||
+84
-51
@@ -442,6 +442,32 @@ DaemonOptions member_options(const DaemonOptions &options,
|
||||
return member;
|
||||
}
|
||||
|
||||
// Resolves an optional workspace member selector into effective daemon options. Non-workspace
|
||||
// roots reject a member selector; workspace roots require one.
|
||||
Void::Result::Result<DaemonOptions, std::string>
|
||||
resolve_member_options(const DaemonOptions &options, std::string_view member) {
|
||||
if (!Config::is_workspace_root(options.project_root)) {
|
||||
if (!member.empty()) {
|
||||
return std::unexpected{
|
||||
std::format("\"member\" is only valid for workspace roots (got '{}')", member)};
|
||||
}
|
||||
return options;
|
||||
}
|
||||
auto members = evaluate_workspace_members(options);
|
||||
if (!members) {
|
||||
return std::unexpected{members.error()};
|
||||
}
|
||||
if (member.empty()) {
|
||||
return std::unexpected{std::string{"workspace roots require \"member\""}};
|
||||
}
|
||||
const auto match = std::ranges::find_if(
|
||||
*members, [&](const WorkspaceMemberDir &candidate) { return candidate.name == member; });
|
||||
if (match == members->end()) {
|
||||
return std::unexpected{std::format("unknown workspace member '{}'", member)};
|
||||
}
|
||||
return member_options(options, match->path);
|
||||
}
|
||||
|
||||
JsonValue::Array bounded_target_names(const Graph::BuildGraph &graph, bool &truncated) {
|
||||
std::vector<std::string> target_names;
|
||||
target_names.reserve(graph.targets.size());
|
||||
@@ -590,26 +616,14 @@ std::string build_project(const DaemonOptions &options, State::StateStore &state
|
||||
std::optional<CompilerFamily> compiler_override,
|
||||
const std::vector<std::string> &selected_targets, std::size_t jobs,
|
||||
std::string_view selected_member) {
|
||||
DaemonOptions effective = options;
|
||||
std::string member_name;
|
||||
if (Config::is_workspace_root(options.project_root)) {
|
||||
auto members = evaluate_workspace_members(options);
|
||||
if (!members) {
|
||||
return error_response(members.error());
|
||||
}
|
||||
if (selected_member.empty()) {
|
||||
return error_response("build: workspace roots require \"member\"");
|
||||
}
|
||||
const auto match = std::ranges::find_if(*members, [&](const WorkspaceMemberDir &member) {
|
||||
return member.name == selected_member;
|
||||
});
|
||||
if (match == members->end()) {
|
||||
return error_response(
|
||||
std::format("build: unknown workspace member '{}'", selected_member));
|
||||
}
|
||||
effective = member_options(options, match->path);
|
||||
member_name = match->name;
|
||||
auto effective_result = resolve_member_options(options, selected_member);
|
||||
if (!effective_result) {
|
||||
return error_response(std::format("build: {}", effective_result.error()));
|
||||
}
|
||||
const DaemonOptions &effective = *effective_result;
|
||||
const std::string member_name = Config::is_workspace_root(options.project_root)
|
||||
? std::string{selected_member}
|
||||
: std::string{};
|
||||
|
||||
auto evaluated = evaluate_project_graph(effective, profile_name, compiler_override, "build");
|
||||
if (!evaluated) {
|
||||
@@ -691,16 +705,22 @@ std::filesystem::path effective_compdb_path(const DaemonOptions &options,
|
||||
|
||||
// Publishes the compilation database and reports its path and entry count.
|
||||
std::string compdb_export_project(const DaemonOptions &options, std::string_view profile_name,
|
||||
std::optional<CompilerFamily> compiler_override) {
|
||||
auto evaluated = evaluate_project_graph(options, profile_name, compiler_override, "compdb");
|
||||
std::optional<CompilerFamily> compiler_override,
|
||||
std::string_view member) {
|
||||
auto effective_result = resolve_member_options(options, member);
|
||||
if (!effective_result) {
|
||||
return error_response(std::format("compdb: {}", effective_result.error()));
|
||||
}
|
||||
const DaemonOptions &effective = *effective_result;
|
||||
auto evaluated = evaluate_project_graph(effective, profile_name, compiler_override, "compdb");
|
||||
if (!evaluated) {
|
||||
return error_response(evaluated.error());
|
||||
}
|
||||
auto graph = lower_graph(options, *evaluated, {}, "compdb");
|
||||
auto graph = lower_graph(effective, *evaluated, {}, "compdb");
|
||||
if (!graph) {
|
||||
return error_response(graph.error());
|
||||
}
|
||||
auto published = publish_compdb(options, *graph);
|
||||
auto published = publish_compdb(effective, *graph);
|
||||
if (!published) {
|
||||
return error_response(std::format("compdb: {}", published.error()));
|
||||
}
|
||||
@@ -709,7 +729,7 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
|
||||
object.emplace("ok", JsonValue{true});
|
||||
object.emplace("op", JsonValue{std::string{"compdb"}});
|
||||
object.emplace("profile", JsonValue{evaluated->context.name});
|
||||
object.emplace("compdb", JsonValue{effective_compdb_path(options, *published).string()});
|
||||
object.emplace("compdb", JsonValue{effective_compdb_path(effective, *published).string()});
|
||||
object.emplace("entries", JsonValue{static_cast<std::int64_t>(published->entry_count)});
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
@@ -717,31 +737,37 @@ std::string compdb_export_project(const DaemonOptions &options, std::string_view
|
||||
// Publishes the compilation database and writes the requested editor configuration files.
|
||||
std::string ide_generate_project(const DaemonOptions &options, std::string_view profile_name,
|
||||
std::optional<CompilerFamily> compiler_override,
|
||||
std::string_view editor_name, bool force) {
|
||||
std::string_view editor_name, bool force,
|
||||
std::string_view member) {
|
||||
auto kind = Editor::parse_ide_kind(editor_name);
|
||||
if (!kind) {
|
||||
return error_response(kind.error().format());
|
||||
}
|
||||
auto effective_result = resolve_member_options(options, member);
|
||||
if (!effective_result) {
|
||||
return error_response(std::format("ide_generate: {}", effective_result.error()));
|
||||
}
|
||||
const DaemonOptions &effective = *effective_result;
|
||||
auto evaluated =
|
||||
evaluate_project_graph(options, profile_name, compiler_override, "ide_generate");
|
||||
evaluate_project_graph(effective, profile_name, compiler_override, "ide_generate");
|
||||
if (!evaluated) {
|
||||
return error_response(evaluated.error());
|
||||
}
|
||||
auto graph = lower_graph(options, *evaluated, {}, "ide_generate");
|
||||
auto graph = lower_graph(effective, *evaluated, {}, "ide_generate");
|
||||
if (!graph) {
|
||||
return error_response(graph.error());
|
||||
}
|
||||
auto published = publish_compdb(options, *graph);
|
||||
auto published = publish_compdb(effective, *graph);
|
||||
if (!published) {
|
||||
return error_response(std::format("ide_generate: {}", published.error()));
|
||||
}
|
||||
|
||||
const auto frontend = make_frontend_options(options);
|
||||
const auto frontend = make_frontend_options(effective);
|
||||
Editor::IdeConfigOptions ide;
|
||||
ide.project_root = options.project_root;
|
||||
ide.build_root = options.build_root;
|
||||
ide.project_root = effective.project_root;
|
||||
ide.build_root = effective.build_root;
|
||||
ide.sdk_include_dir = frontend.sdk_include_dir;
|
||||
ide.compdb_path = effective_compdb_path(options, *published);
|
||||
ide.compdb_path = effective_compdb_path(effective, *published);
|
||||
ide.editor = *kind;
|
||||
ide.force = force;
|
||||
std::error_code ec;
|
||||
@@ -775,23 +801,30 @@ std::string ide_generate_project(const DaemonOptions &options, std::string_view
|
||||
|
||||
// Publishes the profile compilation database and returns the IDE query metadata JSON.
|
||||
std::string ide_query_project(const DaemonOptions &options, std::string_view profile_name,
|
||||
std::optional<CompilerFamily> compiler_override) {
|
||||
auto evaluated = evaluate_project_graph(options, profile_name, compiler_override, "ide_query");
|
||||
std::optional<CompilerFamily> compiler_override,
|
||||
std::string_view member) {
|
||||
auto effective_result = resolve_member_options(options, member);
|
||||
if (!effective_result) {
|
||||
return error_response(std::format("ide_query: {}", effective_result.error()));
|
||||
}
|
||||
const DaemonOptions &effective = *effective_result;
|
||||
auto evaluated =
|
||||
evaluate_project_graph(effective, profile_name, compiler_override, "ide_query");
|
||||
if (!evaluated) {
|
||||
return error_response(evaluated.error());
|
||||
}
|
||||
auto graph = lower_graph(options, *evaluated, {}, "ide_query");
|
||||
auto graph = lower_graph(effective, *evaluated, {}, "ide_query");
|
||||
if (!graph) {
|
||||
return error_response(graph.error());
|
||||
}
|
||||
|
||||
const auto frontend = make_frontend_options(options);
|
||||
auto published = publish_compdb(options, *graph);
|
||||
const auto frontend = make_frontend_options(effective);
|
||||
auto published = publish_compdb(effective, *graph);
|
||||
if (!published) {
|
||||
return error_response(std::format("ide_query: {}", published.error()));
|
||||
}
|
||||
|
||||
const auto compdb_path = effective_compdb_path(options, *published);
|
||||
const auto compdb_path = effective_compdb_path(effective, *published);
|
||||
std::string query =
|
||||
Editor::format_ide_query_json(*graph, compdb_path, frontend.sdk_include_dir);
|
||||
// The socket protocol is one JSON object per line: the embedded query must not contain
|
||||
@@ -1090,14 +1123,22 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
return {error_response(ex.what()), false};
|
||||
}
|
||||
}
|
||||
std::string member;
|
||||
if (const auto entry = object->find("member"); entry != object->end()) {
|
||||
const auto *value = std::get_if<std::string>(&entry->second.value);
|
||||
if (value == nullptr || value->empty() || value->size() > 128) {
|
||||
return {error_response("\"member\" must be a bounded non-empty string"), false};
|
||||
}
|
||||
member = *value;
|
||||
}
|
||||
if (*name == "describe") {
|
||||
return {describe_project(options, profile_name, compiler_override), false};
|
||||
}
|
||||
if (*name == "ide_query") {
|
||||
return {ide_query_project(options, profile_name, compiler_override), false};
|
||||
return {ide_query_project(options, profile_name, compiler_override, member), false};
|
||||
}
|
||||
if (*name == "compdb_export") {
|
||||
return {compdb_export_project(options, profile_name, compiler_override), false};
|
||||
return {compdb_export_project(options, profile_name, compiler_override, member), false};
|
||||
}
|
||||
if (*name == "ide_generate") {
|
||||
std::string editor_name{"all"};
|
||||
@@ -1116,9 +1157,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
}
|
||||
force = *value;
|
||||
}
|
||||
return {
|
||||
ide_generate_project(options, profile_name, compiler_override, editor_name, force),
|
||||
false};
|
||||
return {ide_generate_project(options, profile_name, compiler_override, editor_name,
|
||||
force, member),
|
||||
false};
|
||||
}
|
||||
|
||||
std::vector<std::string> selected_targets;
|
||||
@@ -1148,14 +1189,6 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
}
|
||||
jobs = static_cast<std::size_t>(*value);
|
||||
}
|
||||
std::string member;
|
||||
if (const auto entry = object->find("member"); entry != object->end()) {
|
||||
const auto *value = std::get_if<std::string>(&entry->second.value);
|
||||
if (value == nullptr || value->empty() || value->size() > 128) {
|
||||
return {error_response("\"member\" must be a bounded non-empty string"), false};
|
||||
}
|
||||
member = *value;
|
||||
}
|
||||
return {build_project(options, state_store, profile_name, compiler_override,
|
||||
selected_targets, jobs, member),
|
||||
false};
|
||||
|
||||
+25
-12
@@ -1469,6 +1469,7 @@ struct DaemonCmdOptions {
|
||||
std::vector<std::string> targets;
|
||||
std::string jobs_arg{"0"};
|
||||
std::string editor_arg{"all"};
|
||||
std::optional<std::string> member_arg;
|
||||
std::string timeout_ms_arg{"2000"};
|
||||
bool force{false};
|
||||
std::string max_bytes_arg{"0"};
|
||||
@@ -1569,24 +1570,30 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
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");
|
||||
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",
|
||||
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
|
||||
: std::string{});
|
||||
} 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));
|
||||
request_json = std::format(
|
||||
R"({{"op":"compdb_export","profile":{}{}}})", Util::json_quote(opts.profile_arg),
|
||||
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
|
||||
: std::string{});
|
||||
} 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));
|
||||
request_json = std::format(
|
||||
R"({{"op":"ide_query","profile":{}{}}})", Util::json_quote(opts.profile_arg),
|
||||
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "build") {
|
||||
std::size_t jobs = 0;
|
||||
const auto [ptr, ec] = std::from_chars(opts.jobs_arg.data(),
|
||||
@@ -2601,15 +2608,19 @@ int main(int argc, char **argv) {
|
||||
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");
|
||||
daemon_compdb_export_cmd
|
||||
.option_default("--profile", "-p", "Profile to export", daemon_opts.profile_arg, "debug")
|
||||
.option("--member", "", "Workspace member (required for workspace roots)",
|
||||
daemon_opts.member_arg);
|
||||
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");
|
||||
daemon_ide_query_cmd
|
||||
.option_default("--profile", "-p", "Profile to query", daemon_opts.profile_arg, "debug")
|
||||
.option("--member", "", "Workspace member (required for workspace roots)",
|
||||
daemon_opts.member_arg);
|
||||
auto &daemon_ide_poll_cmd = daemon_ide_cmd.subcommand(
|
||||
"poll", "Poll pending project file changes (editor extension protocol)");
|
||||
configure_daemon_common(daemon_ide_poll_cmd);
|
||||
@@ -2625,6 +2636,8 @@ int main(int argc, char **argv) {
|
||||
.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")
|
||||
.option("--member", "", "Workspace member (required for workspace roots)",
|
||||
daemon_opts.member_arg)
|
||||
.flag("--force", "", "Overwrite existing IDE configuration files", daemon_opts.force);
|
||||
|
||||
const auto parsed = root.parse_detailed(argc, argv);
|
||||
|
||||
@@ -843,6 +843,17 @@ void build(Void::Build::Project &project) {
|
||||
|
||||
auto build_raw = Void::Build::Daemon::request(socket, R"({"op":"build","member":"app"})",
|
||||
std::chrono::seconds{120});
|
||||
|
||||
auto ide_no_member = request_object(socket, R"({"op":"ide_query"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(ide_no_member.has_value());
|
||||
Void::Testing::expect(!bool_field(*ide_no_member, "ok", true));
|
||||
Void::Testing::expect(str_field(*ide_no_member, "error").find("member") != std::string::npos);
|
||||
|
||||
auto ide_query = Void::Build::Daemon::request(socket, R"({"op":"ide_query","member":"app"})",
|
||||
std::chrono::seconds{120});
|
||||
auto ide_generate = Void::Build::Daemon::request(
|
||||
socket, R"({"op":"ide_generate","member":"app","editor":"clangd","force":true})",
|
||||
std::chrono::seconds{120});
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
@@ -857,5 +868,13 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect_eq(str_field(*object, "member"), std::string{"app"});
|
||||
Void::Testing::expect(std::filesystem::exists(options.build_root / "profiles" / "debug" /
|
||||
"out" / "bin" / "ws_app"));
|
||||
|
||||
Void::Testing::require(ide_query.has_value());
|
||||
Void::Testing::expect(ide_query->find("\"ok\":true") != std::string::npos);
|
||||
Void::Testing::expect(ide_query->find("packages/app") != std::string::npos);
|
||||
Void::Testing::expect(ide_query->find("\"name\":\"ws_app\"") != std::string::npos);
|
||||
Void::Testing::require(ide_generate.has_value());
|
||||
Void::Testing::expect(ide_generate->find("\"ok\":true") != std::string::npos);
|
||||
Void::Testing::expect(std::filesystem::exists(ws / "packages" / "app" / ".clangd"));
|
||||
Void::Testing::expect(!std::filesystem::exists(socket));
|
||||
}
|
||||
Reference in new issue
Block a user