feat(daemon): resolve and materialize dependencies on request
This commit is contained in:
1 parent
3832ec1db4
commit
ad3f4725ef
8 files changed
+141
-23
No files matched your search
@@ -173,7 +173,7 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
|
||||
- Added the `compdb_entries` daemon request (`vbs daemon compdb entries [--file SUFFIX] [--limit N]`): reads the active published compilation database (selection state or root alias), returns bounded projected entries (`file`, `directory`, `output`, `command`, bounded `arguments`), reports `total`/`returned`, and errors explicitly when nothing is published.
|
||||
- Added `Daemon.compdb_entries_queries_published_database` (unpublished → error, then all entries, a `main.cpp` filter with `limit:1`, and an invalid limit) and a CLI help contract; Daemon suite is now 18 cases.
|
||||
|
||||
- **Wave 40 (Authenticated Binary-Variant Downloads)**:\n - `download_binary_artifact` now accepts `RegistryAuth` and sends the bearer token, so private registry binary artifacts can be fetched; `BinaryFetchOptions` gained `bearer_token` and `materialize_binary_variant` forwards it; `vbs binaries fetch` passes the configured token.\n - Added `RegistryTests.private_binary_variant_download_requires_auth`: anonymous download of a private binary → 401, authenticated client download and signed materialization succeed.\n\n- **Wave 41 (Yanked Binary Variants in Listing)**:\n - `fetch_binary_variants` gained `include_yanked` (default false, so selection/materialization still never sees yanked variants); `vbs binaries list` opts in and marks yanked entries while `binaries fetch` keeps the filtered view.\n - Extended the registry binary-variant test to assert the yanked variant is returned with `yanked=true` only when requested.\n\n- **Wave 42 (Registry Binary-Variant Listing Endpoint)**:\n - Added `GET /api/v1/packages/<name>/<version>/binaries` returning the release's binary variants (`variant_id`, `sha256`, `size_bytes`, `yanked`, optional signature/public key) under normal read permissions; `RegistryClient::fetch_binary_variants` now queries this endpoint directly instead of parsing package detail JSON.\n - The registry binary-variant test asserts the listing endpoint returns the published variant with `yanked:false`.\n\n- **Wave 43 (Workspace Members Request)**:\n - Added the `workspace_members` daemon request (`vbs daemon workspace members`): lists declared workspace members (`name`, canonical `path`) without evaluating member build descriptions; non-workspace roots return `workspace:false` with an empty list.\n - Added `Daemon.workspace_members_lists_declared_members` and a CLI help contract; Daemon suite is now 19 cases.\n\n- **Wave 44 (IDE Configs Request)**:\n - Added the `ide_configs` daemon request (`vbs daemon ide configs`): reports presence of `.clangd`, `.vscode/tasks.json`, `.zed/tasks.json`, and `.idea/customTargets.xml` so editor extensions can see what is configured.\n - Added `Daemon.ide_configs_reports_generated_files` (absent before generation, present after `ide_generate`) and a CLI help contract; Daemon suite is now 20 cases.\n\n- **Wave 45 (Compdb Generations Request)**:\n - Added the `compdb_generations` daemon request (`vbs daemon compdb generations --profile`): lists immutable editor generations (bounded 128) with active flag, per-generation entry counts, and the per-profile status/diagnostic record; profile names are validated against `[A-Za-z0-9._-]` to prevent traversal.\n - Added `Daemon.compdb_generations_lists_history_and_active_generation` (empty before export, then a valid generation with entries and an active selection; invalid profile rejected) and a CLI help contract; Daemon suite is now 21 cases.\n\n- **Wave 46 (Registry Package Search Pagination)**:\n - `GET /api/v1/packages` now supports bounded `limit` (0-500, default 100) and `offset` (0-1,000,000) pagination with a `total`/`limit`/`offset` envelope; malformed values return 400.\n - The registry RBAC test asserts a `limit=1` page contains exactly one package and that `limit=501` is rejected.\n\n- **Wave 47 (Registry Release Detail Endpoint)**:\n - Added `GET /api/v1/packages/<name>/<version>` returning release metadata (digest, size, yank state, publisher/epoch, optional signature/public key, binary variant summaries) under normal read permissions; unknown packages/releases return 404.\n - The registry binary-variant test asserts the release detail includes the version and published binary variant, and that an unknown version returns 404.\n\n## Remaining future scope
|
||||
- **Wave 40 (Authenticated Binary-Variant Downloads)**:\n - `download_binary_artifact` now accepts `RegistryAuth` and sends the bearer token, so private registry binary artifacts can be fetched; `BinaryFetchOptions` gained `bearer_token` and `materialize_binary_variant` forwards it; `vbs binaries fetch` passes the configured token.\n - Added `RegistryTests.private_binary_variant_download_requires_auth`: anonymous download of a private binary → 401, authenticated client download and signed materialization succeed.\n\n- **Wave 41 (Yanked Binary Variants in Listing)**:\n - `fetch_binary_variants` gained `include_yanked` (default false, so selection/materialization still never sees yanked variants); `vbs binaries list` opts in and marks yanked entries while `binaries fetch` keeps the filtered view.\n - Extended the registry binary-variant test to assert the yanked variant is returned with `yanked=true` only when requested.\n\n- **Wave 42 (Registry Binary-Variant Listing Endpoint)**:\n - Added `GET /api/v1/packages/<name>/<version>/binaries` returning the release's binary variants (`variant_id`, `sha256`, `size_bytes`, `yanked`, optional signature/public key) under normal read permissions; `RegistryClient::fetch_binary_variants` now queries this endpoint directly instead of parsing package detail JSON.\n - The registry binary-variant test asserts the listing endpoint returns the published variant with `yanked:false`.\n\n- **Wave 43 (Workspace Members Request)**:\n - Added the `workspace_members` daemon request (`vbs daemon workspace members`): lists declared workspace members (`name`, canonical `path`) without evaluating member build descriptions; non-workspace roots return `workspace:false` with an empty list.\n - Added `Daemon.workspace_members_lists_declared_members` and a CLI help contract; Daemon suite is now 19 cases.\n\n- **Wave 44 (IDE Configs Request)**:\n - Added the `ide_configs` daemon request (`vbs daemon ide configs`): reports presence of `.clangd`, `.vscode/tasks.json`, `.zed/tasks.json`, and `.idea/customTargets.xml` so editor extensions can see what is configured.\n - Added `Daemon.ide_configs_reports_generated_files` (absent before generation, present after `ide_generate`) and a CLI help contract; Daemon suite is now 20 cases.\n\n- **Wave 45 (Compdb Generations Request)**:\n - Added the `compdb_generations` daemon request (`vbs daemon compdb generations --profile`): lists immutable editor generations (bounded 128) with active flag, per-generation entry counts, and the per-profile status/diagnostic record; profile names are validated against `[A-Za-z0-9._-]` to prevent traversal.\n - Added `Daemon.compdb_generations_lists_history_and_active_generation` (empty before export, then a valid generation with entries and an active selection; invalid profile rejected) and a CLI help contract; Daemon suite is now 21 cases.\n\n- **Wave 46 (Registry Package Search Pagination)**:\n - `GET /api/v1/packages` now supports bounded `limit` (0-500, default 100) and `offset` (0-1,000,000) pagination with a `total`/`limit`/`offset` envelope; malformed values return 400.\n - The registry RBAC test asserts a `limit=1` page contains exactly one package and that `limit=501` is rejected.\n\n- **Wave 47 (Registry Release Detail Endpoint)**:\n - Added `GET /api/v1/packages/<name>/<version>` returning release metadata (digest, size, yank state, publisher/epoch, optional signature/public key, binary variant summaries) under normal read permissions; unknown packages/releases return 404.\n - The registry binary-variant test asserts the release detail includes the version and published binary variant, and that an unknown version returns 404.\n\n- **Wave 48 (Daemon Deps Request)**:\n - Added the `deps` daemon request (`vbs daemon deps [--profile] [--member]`): evaluates the project, merges TOML/declared dependencies, resolves and materializes them with the pinned lock, registry environment, and trusted keys, then returns the lock context key and per-entry metadata (`alias`, `source_kind`, `package_name`, `version`, `sha256`, `signed`). Shared dependency-merge and resolve-option helpers were extracted for reuse by the build path.\n - Extended `Daemon.build_materializes_path_dependency` to assert a `deps` response with the `helper` path entry before building, plus a CLI help contract.\n\n## 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.
|
||||
|
||||
|
||||
@@ -54,4 +54,5 @@ Base HEAD: `fe0d1a6`
|
||||
| Wave 45 (Compdb generations request) | `compdb_generations` daemon request + `vbs daemon compdb generations --profile`: generation history, active id, status/entry counts, validated profile names | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 21/21, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, docs |
|
||||
| Wave 46 (Registry search pagination) | `GET /api/v1/packages?limit&offset` with total envelope and 400 validation | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `registry/service/RegistryService.cpp`, `tests/RegistryTests.cpp`, docs |
|
||||
| Wave 47 (Registry release detail) | `GET /api/v1/packages/<name>/<version>` with metadata + binary summaries | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Registry 7/7, full CTest 8/8) | `registry/service/RegistryService.cpp`, `tests/RegistryTests.cpp`, docs |
|
||||
| Wave 48 (Daemon deps request) | `deps` daemon request + `vbs daemon deps --profile --member`: resolve/materialize and return the lock context entries; shared merge/resolve helpers | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Daemon 21/21, full CTest 8/8) | `src/Daemon/Daemon.cpp`, `src/Main.cpp`, `tests/DaemonTests.cpp`, `tests/CliContracts.cmake`, 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) |
|
||||
@@ -799,6 +799,20 @@ dev cpp-gcc -c ctest --test-dir build/pinned --output-on-failure
|
||||
- Full CTest: **8 / 8 passed** in 230.82 s.
|
||||
- `clang-format --dry-run --Werror` passes on the changed C++ files.
|
||||
|
||||
## Daemon Deps Request (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: **21 / 21 passed** in 44.29 s; `build_materializes_path_dependency`
|
||||
now first sends `{"op":"deps"}` and asserts an entry with `alias:"helper"`, `source_kind:"path"`,
|
||||
and a non-empty digest before building.
|
||||
- Full CTest: **8 / 8 passed** in 236.07 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), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, registry package search supports bounded pagination, and releases expose a version-specific detail endpoint. Daemon workspace support describes members, builds all members in order (or 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`. |
|
||||
| **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), `vbs daemon ide wait` adds a bounded long-poll variant, `vbs daemon ide status` reports the active editor selection and compdb state, `vbs daemon compdb use` switches the active editor profile under the selection lock, `vbs daemon graph` exports the target dependency graph (DOT/JSON), `vbs daemon test` builds and runs declared test targets, `vbs daemon compdb entries` serves bounded per-file compile arguments to editor extensions, `vbs daemon workspace members` lists workspace members cheaply, `vbs daemon ide configs` reports which editor configuration files exist, `vbs daemon compdb generations` lists editor generation history with the active selection, `vbs daemon deps` resolves/materializes dependencies over the socket, registry package search supports bounded pagination, and releases expose a version-specific detail endpoint. Daemon workspace support describes members, builds all members in order (or 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. |
|
||||
|
||||
---
|
||||
|
||||
+97
-21
@@ -515,40 +515,33 @@ lower_graph(const DaemonOptions &options, const EvaluatedProject &evaluated,
|
||||
return std::move(*graph);
|
||||
}
|
||||
|
||||
// Resolves, materializes, and imports the project's declared dependencies into typed target
|
||||
// interfaces. Returns the number of materialized sources.
|
||||
Void::Result::Result<std::size_t, std::string> materialize_project_dependencies(
|
||||
const DaemonOptions &options, State::StateStore &state, const EvaluatedProject &evaluated,
|
||||
std::size_t jobs,
|
||||
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> &imported_targets) {
|
||||
const auto &description = evaluated.description;
|
||||
if (description.dependencies.empty() && description.dependency_files.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Void::Result::Result<std::vector<Package::NormalizedDependency>, std::string>
|
||||
merged_project_dependencies(const Graph::ProjectDescription &description,
|
||||
const std::filesystem::path &project_root) {
|
||||
std::vector<Package::NormalizedDependency> toml_deps;
|
||||
for (const auto &dep_file : description.dependency_files) {
|
||||
const auto path = std::filesystem::path{dep_file}.is_absolute()
|
||||
? std::filesystem::path{dep_file}
|
||||
: (options.project_root / dep_file);
|
||||
: (project_root / dep_file);
|
||||
auto loaded = Package::load_dependencies_toml(path);
|
||||
if (!loaded) {
|
||||
return std::unexpected{std::format("build: {}", loaded.error().format())};
|
||||
return std::unexpected{loaded.error().format()};
|
||||
}
|
||||
toml_deps.insert(toml_deps.end(), loaded->begin(), loaded->end());
|
||||
}
|
||||
auto merged = Package::merge_dependencies(description.dependencies, toml_deps);
|
||||
if (!merged) {
|
||||
return std::unexpected{std::format("build: {}", merged.error().format())};
|
||||
}
|
||||
if (merged->empty()) {
|
||||
return 0;
|
||||
return std::unexpected{merged.error().format()};
|
||||
}
|
||||
return *merged;
|
||||
}
|
||||
|
||||
Void::Result::Result<Package::ResolveOptions, std::string>
|
||||
make_resolve_options(const DaemonOptions &options) {
|
||||
const auto lock_root = options.lock_root.empty() ? options.project_root : options.lock_root;
|
||||
auto pinned_lock = Package::load_pinned_lock(lock_root / "vbs.lock");
|
||||
if (!pinned_lock) {
|
||||
return std::unexpected{std::format("build: {}", pinned_lock.error().format())};
|
||||
return std::unexpected{pinned_lock.error().format()};
|
||||
}
|
||||
Package::ResolveOptions resolve_options;
|
||||
resolve_options.project_root = options.project_root;
|
||||
@@ -566,11 +559,90 @@ Void::Result::Result<std::size_t, std::string> materialize_project_dependencies(
|
||||
auto trusted_keys =
|
||||
Provenance::load_trusted_keys({}, options.project_root, trusted_environment_value);
|
||||
if (!trusted_keys) {
|
||||
return std::unexpected{std::format("build: {}", trusted_keys.error().format())};
|
||||
return std::unexpected{trusted_keys.error().format()};
|
||||
}
|
||||
resolve_options.trusted_public_keys = std::move(*trusted_keys);
|
||||
return resolve_options;
|
||||
}
|
||||
|
||||
// Resolves and materializes declared dependencies without building, returning the lock context.
|
||||
std::string deps_project(const DaemonOptions &options, std::string_view profile_name,
|
||||
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("deps: {}", effective_result.error()));
|
||||
}
|
||||
const DaemonOptions &effective = *effective_result;
|
||||
auto evaluated = evaluate_project_graph(effective, profile_name, compiler_override, "deps");
|
||||
if (!evaluated) {
|
||||
return error_response(evaluated.error());
|
||||
}
|
||||
|
||||
JsonValue::Object object;
|
||||
object.emplace("ok", JsonValue{true});
|
||||
object.emplace("op", JsonValue{std::string{"deps"}});
|
||||
object.emplace("profile", JsonValue{evaluated->context.name});
|
||||
object.emplace("context_key",
|
||||
JsonValue{Package::make_lock_context_key(evaluated->context, "target")});
|
||||
|
||||
auto merged = merged_project_dependencies(evaluated->description, effective.project_root);
|
||||
if (!merged) {
|
||||
return error_response(std::format("deps: {}", merged.error()));
|
||||
}
|
||||
if (!merged->empty()) {
|
||||
auto resolve_options = make_resolve_options(effective);
|
||||
if (!resolve_options) {
|
||||
return error_response(std::format("deps: {}", resolve_options.error()));
|
||||
}
|
||||
auto resolved = Package::resolve_and_materialize_dependencies(evaluated->context, *merged,
|
||||
*resolve_options);
|
||||
if (!resolved) {
|
||||
return error_response(std::format("deps: {}", resolved.error().format()));
|
||||
}
|
||||
JsonValue::Array entries;
|
||||
for (const auto &entry : resolved->lock_context.entries) {
|
||||
JsonValue::Object item;
|
||||
item.emplace("alias", JsonValue{entry.alias});
|
||||
item.emplace("source_kind", JsonValue{entry.source_kind});
|
||||
item.emplace("package_name", JsonValue{entry.package_name});
|
||||
item.emplace("version", JsonValue{entry.version});
|
||||
item.emplace("sha256", JsonValue{entry.sha256});
|
||||
item.emplace("signed",
|
||||
JsonValue{entry.signature.has_value() && entry.public_key.has_value()});
|
||||
entries.emplace_back(std::move(item));
|
||||
}
|
||||
object.emplace("entries", JsonValue{std::move(entries)});
|
||||
} else {
|
||||
object.emplace("entries", JsonValue{JsonValue::Array{}});
|
||||
}
|
||||
return serialize_response(JsonValue{std::move(object)});
|
||||
}
|
||||
|
||||
// Resolves, materializes, and imports the project's declared dependencies into typed target
|
||||
// interfaces. Returns the number of materialized sources.
|
||||
Void::Result::Result<std::size_t, std::string> materialize_project_dependencies(
|
||||
const DaemonOptions &options, State::StateStore &state, const EvaluatedProject &evaluated,
|
||||
std::size_t jobs,
|
||||
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> &imported_targets) {
|
||||
const auto &description = evaluated.description;
|
||||
if (description.dependencies.empty() && description.dependency_files.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto merged = merged_project_dependencies(description, options.project_root);
|
||||
if (!merged) {
|
||||
return std::unexpected{std::format("build: {}", merged.error())};
|
||||
}
|
||||
if (merged->empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto resolve_options = make_resolve_options(options);
|
||||
if (!resolve_options) {
|
||||
return std::unexpected{std::format("build: {}", resolve_options.error())};
|
||||
}
|
||||
auto resolved =
|
||||
Package::resolve_and_materialize_dependencies(evaluated.context, *merged, resolve_options);
|
||||
Package::resolve_and_materialize_dependencies(evaluated.context, *merged, *resolve_options);
|
||||
if (!resolved) {
|
||||
return std::unexpected{std::format("build: {}", resolved.error().format())};
|
||||
}
|
||||
@@ -1690,7 +1762,8 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
return {serialize_response(JsonValue{std::move(object)}), false};
|
||||
}
|
||||
if (*name == "describe" || *name == "build" || *name == "test" || *name == "ide_query" ||
|
||||
*name == "ide_generate" || *name == "compdb_export" || *name == "graph") {
|
||||
*name == "ide_generate" || *name == "compdb_export" || *name == "graph" ||
|
||||
*name == "deps") {
|
||||
std::string profile_name{"debug"};
|
||||
if (const auto entry = object->find("profile"); entry != object->end()) {
|
||||
const auto *value = std::get_if<std::string>(&entry->second.value);
|
||||
@@ -1734,6 +1807,9 @@ DaemonServer::Impl::DispatchResult DaemonServer::Impl::dispatch(std::string_view
|
||||
if (*name == "compdb_export") {
|
||||
return {compdb_export_project(options, profile_name, compiler_override, member), false};
|
||||
}
|
||||
if (*name == "deps") {
|
||||
return {deps_project(options, profile_name, compiler_override, member), false};
|
||||
}
|
||||
if (*name == "graph") {
|
||||
std::string graph_format{"dot"};
|
||||
if (const auto entry = object->find("format"); entry != object->end()) {
|
||||
|
||||
@@ -1569,6 +1569,11 @@ int execute_daemon_command(std::string_view sub, const DaemonCmdOptions &opts) {
|
||||
request_json = R"({"op":"workspace_members"})";
|
||||
} else if (sub == "ide_configs") {
|
||||
request_json = R"({"op":"ide_configs"})";
|
||||
} else if (sub == "deps") {
|
||||
request_json = std::format(
|
||||
R"({{"op":"deps","profile":{}{}}})", Util::json_quote(opts.profile_arg),
|
||||
opts.member_arg ? std::format(",\"member\":{}", Util::json_quote(*opts.member_arg))
|
||||
: std::string{});
|
||||
} else if (sub == "compdb_generations") {
|
||||
if (opts.profile_arg.empty()) {
|
||||
std::cerr << "vbs daemon compdb generations: --profile must not be empty\n";
|
||||
@@ -2678,6 +2683,13 @@ int main(int argc, char **argv) {
|
||||
.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_deps_cmd =
|
||||
daemon_cmd.subcommand("deps", "Resolve and materialize dependencies via the daemon");
|
||||
configure_daemon_common(daemon_deps_cmd);
|
||||
daemon_deps_cmd
|
||||
.option_default("--profile", "-p", "Profile to resolve", daemon_opts.profile_arg, "debug")
|
||||
.option("--member", "", "Workspace member (required for workspace roots)",
|
||||
daemon_opts.member_arg);
|
||||
auto &daemon_workspace_cmd =
|
||||
daemon_cmd.subcommand("workspace", "Workspace metadata served by the daemon");
|
||||
auto &daemon_workspace_members_cmd =
|
||||
|
||||
@@ -68,6 +68,7 @@ check_process(0 "Usage: vbs daemon test .*--profile.*--target.*--jobs" "" daemon
|
||||
check_process(0 "Usage: vbs daemon workspace members " "" daemon workspace members --help)
|
||||
check_process(0 "Usage: vbs daemon ide configs " "" daemon ide configs --help)
|
||||
check_process(0 "Usage: vbs daemon compdb generations .*--profile" "" daemon compdb generations --help)
|
||||
check_process(0 "Usage: vbs daemon deps .*--profile" "" daemon deps --help)
|
||||
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
|
||||
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
|
||||
|
||||
|
||||
@@ -422,6 +422,20 @@ void build(Void::Build::Project &project) {
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
auto deps = request_object(socket, R"({"op":"deps"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(deps.has_value());
|
||||
Void::Testing::expect(bool_field(*deps, "ok"));
|
||||
Void::Testing::expect_eq(str_field(*deps, "op"), std::string{"deps"});
|
||||
const auto *dep_entries = field(*deps, "entries");
|
||||
Void::Testing::require(dep_entries != nullptr);
|
||||
const auto *dep_array = std::get_if<JsonValue::Array>(&dep_entries->value);
|
||||
Void::Testing::require(dep_array != nullptr && !dep_array->empty());
|
||||
const auto *first_dep = std::get_if<JsonObject>(&dep_array->front().value);
|
||||
Void::Testing::require(first_dep != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*first_dep, "alias"), std::string{"helper"});
|
||||
Void::Testing::expect_eq(str_field(*first_dep, "source_kind"), std::string{"path"});
|
||||
Void::Testing::expect(!str_field(*first_dep, "sha256").empty());
|
||||
|
||||
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"));
|
||||
|
||||
Reference in new issue
Block a user