Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
84 lines
3.0 KiB
C++
84 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include <vls/modules/ModuleGraph.hpp>
|
|
|
|
#include <compare>
|
|
#include <cstddef>
|
|
#include <expected>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <stop_token>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace vls::modules {
|
|
|
|
// Identity of one private module artifact. Compatibility covers frontend,
|
|
// target ABI, stdlib and flags; context names the producer; inputs binds the
|
|
// exact command, source and textual closure; kind distinguishes CMI/object.
|
|
struct ArtifactKey {
|
|
std::string compatibility, context, inputs, kind;
|
|
auto operator<=>(const ArtifactKey &) const = default;
|
|
[[nodiscard]] std::string identity() const;
|
|
};
|
|
|
|
struct ArtifactEntry {
|
|
ArtifactKey key;
|
|
std::filesystem::path path;
|
|
std::string sha256;
|
|
};
|
|
|
|
// An immutable, completely published generation. Readers retain it while
|
|
// eviction removes only generations no reader references.
|
|
class ArtifactGeneration {
|
|
public:
|
|
[[nodiscard]] const std::string &id() const noexcept { return id_; }
|
|
[[nodiscard]] const std::filesystem::path &root() const noexcept { return root_; }
|
|
[[nodiscard]] std::optional<ArtifactEntry> find(const ArtifactKey &key) const;
|
|
|
|
private:
|
|
friend class ArtifactCache;
|
|
ArtifactGeneration(std::string id, std::filesystem::path root,
|
|
std::map<ArtifactKey, ArtifactEntry> entries)
|
|
: id_(std::move(id)), root_(std::move(root)), entries_(std::move(entries)) {}
|
|
std::string id_;
|
|
std::filesystem::path root_;
|
|
std::map<ArtifactKey, ArtifactEntry> entries_;
|
|
};
|
|
|
|
// Private artifact cache. Publication is all-or-nothing and content addressed;
|
|
// a failed publication leaves no generation behind.
|
|
class ArtifactCache {
|
|
public:
|
|
explicit ArtifactCache(std::filesystem::path root, std::size_t retained = 2);
|
|
~ArtifactCache();
|
|
ArtifactCache(const ArtifactCache &) = delete;
|
|
ArtifactCache &operator=(const ArtifactCache &) = delete;
|
|
|
|
[[nodiscard]] std::expected<std::shared_ptr<const ArtifactGeneration>, std::string>
|
|
publish(const std::map<ArtifactKey, std::filesystem::path> &artifacts);
|
|
[[nodiscard]] std::shared_ptr<const ArtifactGeneration> current() const;
|
|
// Removes unreferenced generations beyond the retained limit.
|
|
std::size_t collect();
|
|
[[nodiscard]] std::size_t generations() const;
|
|
|
|
private:
|
|
struct State;
|
|
std::shared_ptr<State> state_;
|
|
};
|
|
|
|
// Produces one artifact per planned unit in dependency order. Any failure or
|
|
// cancellation removes the staging directory and publishes nothing.
|
|
using ArtifactWork = std::function<std::expected<std::filesystem::path, std::string>(
|
|
std::stop_token, const Build::ContextKey &, const std::filesystem::path &output)>;
|
|
|
|
[[nodiscard]] std::expected<std::shared_ptr<const ArtifactGeneration>, std::string>
|
|
produce_module_artifacts(const ModulePlan &plan, ArtifactCache &cache,
|
|
const std::filesystem::path &staging, ArtifactWork work,
|
|
std::stop_token stop = std::stop_token{});
|
|
|
|
} // namespace vls::modules
|