129 lines
6.0 KiB
C++
129 lines
6.0 KiB
C++
#pragma once
|
|
|
|
#include <Void/Build/Execution/Scheduler.hpp>
|
|
#include <Void/Build/Graph/Graph.hpp>
|
|
#include <Void/Build/Provider/Provider.hpp>
|
|
#include <Void/Build/Snapshot/Snapshot.hpp>
|
|
#include <Void/Build/State/StateStore.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 TranslationPolicy {
|
|
RequireNative,
|
|
FallbackToForeignBuild,
|
|
};
|
|
|
|
enum class TranslationStatus {
|
|
Supported,
|
|
Unsupported,
|
|
};
|
|
|
|
struct UnsupportedConstruct {
|
|
std::string target_name;
|
|
std::string construct_kind;
|
|
std::string detail;
|
|
};
|
|
|
|
struct TranslationAuditReport {
|
|
TranslationStatus status{TranslationStatus::Supported};
|
|
std::vector<std::string> supported_targets;
|
|
std::vector<UnsupportedConstruct> unsupported;
|
|
std::string summary;
|
|
|
|
[[nodiscard]] bool is_supported() const noexcept {
|
|
return status == TranslationStatus::Supported && unsupported.empty();
|
|
}
|
|
};
|
|
|
|
struct TranslatedCMakeGraph {
|
|
TranslationAuditReport audit;
|
|
Graph::BuildGraph graph;
|
|
std::map<std::string, Graph::ImportedTargetInterface, std::less<>> exported_targets;
|
|
};
|
|
|
|
struct TranslationResolution {
|
|
bool executed_natively{false};
|
|
TranslationAuditReport audit;
|
|
ProviderExport exported;
|
|
std::optional<Execution::ExecutionReport> native_execution;
|
|
};
|
|
|
|
// Configures CMake ONLY (writing File API codemodel-v2 query; never invokes `cmake --build`)
|
|
// and returns the configured File API reply directory.
|
|
[[nodiscard]] Void::Result::Result<std::filesystem::path, Void::Result::Error>
|
|
configure_cmake_for_translation(const ProviderRequest &request,
|
|
const std::filesystem::path &configure_dir,
|
|
std::stop_token stop = {});
|
|
|
|
// Audits a configured CMake File API codemodel against Plan 20/21's bounded native subset:
|
|
// C and C++ STATIC_LIBRARY / SHARED_LIBRARY / OBJECT_LIBRARY / EXECUTABLE targets,
|
|
// C++20 CXX_MODULES fileSets, and hermetic build.ninja CUSTOM_COMMAND generators / UTILITY
|
|
// targets whose declared outputs remain inside `configure_dir`. Any unsupported construct
|
|
// (console pools, .util-only/side-effect rules, out-of-tree writes, PCH, non-C/C++ languages,
|
|
// or untracked link fragments) is reported explicitly and never silently dropped.
|
|
[[nodiscard]] Void::Result::Result<TranslationAuditReport, Void::Result::Error>
|
|
audit_cmake_codemodel(const std::filesystem::path &configure_dir);
|
|
|
|
// Translates an audited CMake codemodel into a native VBS BuildGraph whose actions execute
|
|
// through VBS's Toolchain driver, CAS StateStore, depfile tracking, and ProcessSupervisor.
|
|
[[nodiscard]] Void::Result::Result<TranslatedCMakeGraph, Void::Result::Error>
|
|
translate_cmake_to_native_graph(const ProviderRequest &request,
|
|
const std::filesystem::path &configure_dir,
|
|
const std::filesystem::path &native_build_root,
|
|
const Snapshot::InputSnapshot *snapshot = nullptr);
|
|
|
|
// End-to-end Plan 20 Slice 1 resolver: configures CMake, audits completeness, and either
|
|
// executes the translated native BuildGraph via VBS Execution::execute_graph (without
|
|
// running `cmake --build`), fails with explicit unsupported-construct diagnostics
|
|
// (RequireNative), or delegates cleanly to the v1 foreign CMake provider
|
|
// (FallbackToForeignBuild).
|
|
[[nodiscard]] Void::Result::Result<TranslationResolution, Void::Result::Error>
|
|
resolve_cmake_with_translation(const ProviderRequest &request, State::StateStore &state,
|
|
TranslationPolicy policy = TranslationPolicy::FallbackToForeignBuild,
|
|
std::stop_token stop = {});
|
|
|
|
// Configures Meson ONLY (`meson setup`, never `meson compile`) and returns `meson-info/`.
|
|
[[nodiscard]] Void::Result::Result<std::filesystem::path, Void::Result::Error>
|
|
configure_meson_for_translation(const ProviderRequest &request,
|
|
const std::filesystem::path &configure_dir,
|
|
std::stop_token stop = {});
|
|
|
|
// Audits a configured Meson `meson-info/intro-targets.json` against Plan 20/21's bounded native
|
|
// subset: C and C++ `static library`, `shared library`, `executable`, and hermetic `custom`
|
|
// targets / `generated_sources` backed by build.ninja CUSTOM_COMMAND rules without `run`
|
|
// targets, `console: true` pools, out-of-tree writes, non-C/C++ languages, or untracked links.
|
|
[[nodiscard]] Void::Result::Result<TranslationAuditReport, Void::Result::Error>
|
|
audit_meson_introspection(const std::filesystem::path &configure_dir);
|
|
|
|
// Translates an audited Meson project directly into a native VBS BuildGraph (zero `meson compile`).
|
|
[[nodiscard]] Void::Result::Result<TranslatedCMakeGraph, Void::Result::Error>
|
|
translate_meson_to_native_graph(const ProviderRequest &request,
|
|
const std::filesystem::path &configure_dir,
|
|
const std::filesystem::path &native_build_root,
|
|
const Snapshot::InputSnapshot *snapshot = nullptr);
|
|
|
|
// End-to-end Plan 20 Slice 2A resolver for Meson dependencies.
|
|
[[nodiscard]] Void::Result::Result<TranslationResolution, Void::Result::Error>
|
|
resolve_meson_with_translation(const ProviderRequest &request, State::StateStore &state,
|
|
TranslationPolicy policy = TranslationPolicy::FallbackToForeignBuild,
|
|
std::stop_token stop = {});
|
|
|
|
// Unified Plan 20 dispatcher: translates `cmake` and `meson` dependencies natively under `policy`,
|
|
// and delegates other builders cleanly to `resolve_foreign_provider`.
|
|
[[nodiscard]] Void::Result::Result<TranslationResolution, Void::Result::Error>
|
|
resolve_foreign_with_translation(
|
|
const ProviderRequest &request, State::StateStore &state,
|
|
TranslationPolicy policy = TranslationPolicy::FallbackToForeignBuild,
|
|
std::stop_token stop = {});
|
|
|
|
} // namespace Void::Build::Provider
|