Files
Build-System/include/Void/Build/Provider/Provider.hpp
T
2026-11-27 06:51:43 +03:00

60 lines
2.2 KiB
C++

#pragma once
#include <Void/Build.hpp>
#include <Void/Build/Graph/Graph.hpp>
#include <Void/Build/Package/Fetch.hpp>
#include <Void/Build/State/StateStore.hpp>
#include <Void/Build/Toolchain/Driver.hpp>
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <filesystem>
#include <map>
#include <optional>
#include <stop_token>
#include <string>
#include <vector>
namespace Void::Build::Provider {
enum class ProviderMode { FullBuild, MetadataOnly };
struct ProviderRequest {
DependencyRecord dependency;
Package::MaterializedSource source;
ProfileContext profile;
Toolchain::ToolchainCapabilities toolchain;
std::filesystem::path provider_build_root; // Isolated per source/profile/hash
ProviderMode mode{ProviderMode::FullBuild};
// Explicit typed interface overrides for foreign projects with incomplete metadata.
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> explicit_overrides;
// Optional VBS SDK/state context used by native (`builder == "native"`) dependencies.
std::filesystem::path sdk_include_dir{};
std::filesystem::path sdk_source_dir{};
std::optional<std::filesystem::path> sdk_library_path{};
State::StateStore *shared_state{nullptr};
std::size_t jobs{0};
};
struct ProviderExport {
std::string dependency_name;
std::string builder;
std::string input_identity_hash;
bool from_cache{false};
bool stale_needs_build{false};
std::string stale_diagnostic;
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> targets;
};
// Computes complete provider input identity (source content hash, builder, options,
// toolchain identity, profile options) so timestamp-preserved edits always invalidate!
[[nodiscard]] std::string compute_provider_input_hash(const ProviderRequest &request);
// Runs or reads cached CMake / Meson / Conan2 foreign provider metadata (Plan 13).
// In MetadataOnly mode: strictly reads ONLY validated cached provider-export.json;
// NEVER invokes cmake, meson, or conan! Returns stale_needs_build=true on mismatch/miss.
[[nodiscard]] Void::Result::Result<ProviderExport, Void::Result::Error>
resolve_foreign_provider(const ProviderRequest &request, std::stop_token stop = {});
} // namespace Void::Build::Provider