feat: add Plan 20 Slice 2A Meson native translation, DX CLI (init/clean/doctor/graph/--native-foreign), and expansion roadmap
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
This commit is contained in:
1 parent
d3d2666965
commit
fe0d1a6483
12 files changed
+1317
-41
No files matched your search
@@ -853,4 +853,569 @@ resolve_cmake_with_translation(const ProviderRequest &request, State::StateStore
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::string meson_option_value(const OptionValue &v) {
|
||||
return std::visit(
|
||||
[](const auto &inner) -> std::string {
|
||||
using T = std::remove_cvref_t<decltype(inner)>;
|
||||
if constexpr (std::same_as<T, std::string>) {
|
||||
return inner;
|
||||
} else if constexpr (std::same_as<T, bool>) {
|
||||
return inner ? "true" : "false";
|
||||
} else {
|
||||
return std::to_string(inner);
|
||||
}
|
||||
},
|
||||
v.value);
|
||||
}
|
||||
|
||||
std::vector<std::string> get_str_array(const JsonVal::Object &obj, const std::string &k) {
|
||||
std::vector<std::string> out;
|
||||
const auto *v = find_key(obj, k);
|
||||
if (!v) {
|
||||
return out;
|
||||
}
|
||||
if (const auto *arr = std::get_if<JsonVal::Array>(&v->value)) {
|
||||
for (const auto &item : *arr) {
|
||||
if (const auto *s = std::get_if<std::string>(&item.value)) {
|
||||
out.push_back(*s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
struct ParsedMesonTarget {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string type;
|
||||
std::vector<std::filesystem::path> filenames;
|
||||
std::vector<std::filesystem::path> sources;
|
||||
std::vector<std::pair<std::filesystem::path, bool>> includes;
|
||||
std::vector<std::string> defines;
|
||||
std::vector<std::string> compile_options;
|
||||
std::vector<std::string> link_options;
|
||||
CxxStandard cxx_standard{CxxStandard::Default};
|
||||
std::vector<std::string> dep_ids;
|
||||
};
|
||||
|
||||
struct ParsedMesonModel {
|
||||
TranslationAuditReport audit;
|
||||
std::map<std::string, ParsedMesonTarget, std::less<>> targets_by_id;
|
||||
std::vector<std::string> target_order;
|
||||
};
|
||||
|
||||
Void::Result::Result<ParsedMesonModel, Void::Result::Error>
|
||||
load_and_audit_meson(const std::filesystem::path &configure_dir) {
|
||||
const auto intro_targets = configure_dir / "meson-info" / "intro-targets.json";
|
||||
auto parsed = parse_json_file(intro_targets);
|
||||
if (!parsed) {
|
||||
return std::unexpected{
|
||||
make_error(Void::System::SystemErrorCode::not_found,
|
||||
std::format("Meson introspection file missing or invalid at '{}'",
|
||||
intro_targets.string()))};
|
||||
}
|
||||
const auto *arr = std::get_if<JsonVal::Array>(&parsed->value);
|
||||
if (!arr) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::invalid_argument,
|
||||
"Meson intro-targets.json root must be an array")};
|
||||
}
|
||||
|
||||
ParsedMesonModel out;
|
||||
auto add_unsupported = [&](std::string target_name, std::string kind, std::string detail) {
|
||||
out.audit.status = TranslationStatus::Unsupported;
|
||||
out.audit.unsupported.push_back(
|
||||
UnsupportedConstruct{std::move(target_name), std::move(kind), std::move(detail)});
|
||||
};
|
||||
|
||||
// Map known output filenames (relative & absolute) -> target id for link edge recovery.
|
||||
std::map<std::string, std::string, std::less<>> artifact_to_id;
|
||||
|
||||
for (const auto &tv : *arr) {
|
||||
const auto *to = std::get_if<JsonVal::Object>(&tv.value);
|
||||
if (!to) {
|
||||
continue;
|
||||
}
|
||||
ParsedMesonTarget pt;
|
||||
pt.id = get_str(*to, "id");
|
||||
pt.name = get_str(*to, "name");
|
||||
pt.type = get_str(*to, "type");
|
||||
if (pt.id.empty()) {
|
||||
pt.id = pt.name;
|
||||
}
|
||||
|
||||
if (pt.type == "custom" || pt.type == "run") {
|
||||
add_unsupported(
|
||||
pt.name, "custom_target",
|
||||
std::format("Meson target '{}' has type '{}' (custom/run targets cannot be "
|
||||
"faithfully translated from intro-targets.json)",
|
||||
pt.name, pt.type));
|
||||
continue;
|
||||
}
|
||||
if (pt.type != "static library" && pt.type != "shared library" && pt.type != "executable") {
|
||||
add_unsupported(
|
||||
pt.name, "unsupported_target_type",
|
||||
std::format("Meson target '{}' has unsupported type '{}'", pt.name, pt.type));
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto &fn : get_str_array(*to, "filename")) {
|
||||
const std::filesystem::path abs_fn = std::filesystem::path{fn}.lexically_normal();
|
||||
pt.filenames.push_back(abs_fn);
|
||||
artifact_to_id[abs_fn.string()] = pt.id;
|
||||
artifact_to_id[abs_fn.filename().string()] = pt.id;
|
||||
const auto rel = abs_fn.lexically_relative(configure_dir);
|
||||
if (!rel.empty() && !rel.string().starts_with("..")) {
|
||||
artifact_to_id[rel.generic_string()] = pt.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto *ts = find_key(*to, "target_sources")) {
|
||||
if (const auto *tsarr = std::get_if<JsonVal::Array>(&ts->value)) {
|
||||
for (const auto &tsv : *tsarr) {
|
||||
const auto *tso = std::get_if<JsonVal::Object>(&tsv.value);
|
||||
if (!tso) {
|
||||
continue;
|
||||
}
|
||||
const auto lang = get_str(*tso, "language");
|
||||
const auto srcs = get_str_array(*tso, "sources");
|
||||
const auto gen_srcs = get_str_array(*tso, "generated_sources");
|
||||
if (!gen_srcs.empty()) {
|
||||
add_unsupported(
|
||||
pt.name, "generated_source",
|
||||
std::format("Meson target '{}' depends on {} generated source(s) "
|
||||
"(first: '{}')",
|
||||
pt.name, gen_srcs.size(), gen_srcs.front()));
|
||||
}
|
||||
if (!srcs.empty() && lang != "cpp") {
|
||||
add_unsupported(
|
||||
pt.name, "unsupported_language",
|
||||
std::format("Meson target '{}' compiles language '{}' (bounded subset "
|
||||
"supports cpp only)",
|
||||
pt.name, lang));
|
||||
}
|
||||
for (const auto &s : srcs) {
|
||||
pt.sources.push_back(std::filesystem::path{s}.lexically_normal());
|
||||
}
|
||||
|
||||
const auto params = get_str_array(*tso, "parameters");
|
||||
for (std::size_t i = 0; i < params.size(); ++i) {
|
||||
const auto &p = params[i];
|
||||
if (p.starts_with("-I") && p.size() > 2) {
|
||||
std::filesystem::path ip{p.substr(2)};
|
||||
if (!ip.is_absolute()) {
|
||||
ip = (configure_dir / ip).lexically_normal();
|
||||
}
|
||||
if (!std::ranges::contains(pt.includes, std::pair{ip, false})) {
|
||||
pt.includes.emplace_back(ip, false);
|
||||
}
|
||||
} else if (p == "-I" && i + 1 < params.size()) {
|
||||
std::filesystem::path ip{params[++i]};
|
||||
if (!ip.is_absolute()) {
|
||||
ip = (configure_dir / ip).lexically_normal();
|
||||
}
|
||||
if (!std::ranges::contains(pt.includes, std::pair{ip, false})) {
|
||||
pt.includes.emplace_back(ip, false);
|
||||
}
|
||||
} else if (p == "-isystem" && i + 1 < params.size()) {
|
||||
std::filesystem::path ip{params[++i]};
|
||||
if (!ip.is_absolute()) {
|
||||
ip = (configure_dir / ip).lexically_normal();
|
||||
}
|
||||
if (!std::ranges::contains(pt.includes, std::pair{ip, true})) {
|
||||
pt.includes.emplace_back(ip, true);
|
||||
}
|
||||
} else if (p.starts_with("-D") && p.size() > 2) {
|
||||
const std::string def = p.substr(2);
|
||||
if (!std::ranges::contains(pt.defines, def)) {
|
||||
pt.defines.push_back(def);
|
||||
}
|
||||
} else if (p == "-D" && i + 1 < params.size()) {
|
||||
const std::string def = params[++i];
|
||||
if (!std::ranges::contains(pt.defines, def)) {
|
||||
pt.defines.push_back(def);
|
||||
}
|
||||
} else if (p == "-std=c++17" || p == "-std=gnu++17") {
|
||||
pt.cxx_standard = CxxStandard::Cxx17;
|
||||
} else if (p == "-std=c++20" || p == "-std=gnu++20") {
|
||||
pt.cxx_standard = CxxStandard::Cxx20;
|
||||
} else if (p == "-std=c++23" || p == "-std=gnu++23") {
|
||||
pt.cxx_standard = CxxStandard::Cxx23;
|
||||
} else if (p == "-std=c++26" || p == "-std=gnu++26") {
|
||||
pt.cxx_standard = CxxStandard::Cxx26;
|
||||
} else if (p == "-fPIC" || p == "-fpic" ||
|
||||
p == "-fdiagnostics-color=always" || p == "-pipe" ||
|
||||
p == "-D_FILE_OFFSET_BITS=64") {
|
||||
continue;
|
||||
} else if (p == "-pthread") {
|
||||
if (!std::ranges::contains(pt.compile_options, p)) {
|
||||
pt.compile_options.push_back(p);
|
||||
}
|
||||
if (!std::ranges::contains(pt.link_options, p)) {
|
||||
pt.link_options.push_back(p);
|
||||
}
|
||||
} else if (!p.empty() && p[0] == '-') {
|
||||
if (!std::ranges::contains(pt.compile_options, p)) {
|
||||
pt.compile_options.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.audit.supported_targets.push_back(pt.name);
|
||||
out.target_order.push_back(pt.id);
|
||||
out.targets_by_id[pt.id] = std::move(pt);
|
||||
}
|
||||
|
||||
// Recover internal target link edges cleanly from Meson's configured `build.ninja`
|
||||
// (`build <target_rel>: cpp_LINKER ... | <dep_lib>` + `LINK_ARGS = ...`).
|
||||
if (auto ninja_text = Void::FileSystem::read_file(configure_dir / "build.ninja"); ninja_text) {
|
||||
std::string cur_target_id;
|
||||
std::size_t pos = 0;
|
||||
while (pos < ninja_text->size()) {
|
||||
const auto nl = ninja_text->find('\n', pos);
|
||||
std::string_view line = std::string_view{*ninja_text}.substr(
|
||||
pos, nl == std::string_view::npos ? std::string_view::npos : nl - pos);
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.remove_suffix(1);
|
||||
}
|
||||
pos = (nl == std::string_view::npos) ? ninja_text->size() : (nl + 1);
|
||||
|
||||
if (line.starts_with("build ")) {
|
||||
cur_target_id.clear();
|
||||
const auto colon = line.find(':');
|
||||
if (colon != std::string_view::npos) {
|
||||
const auto outs_part = line.substr(6, colon - 6);
|
||||
for (const auto &tok : split_shell_tokens(outs_part)) {
|
||||
if (const auto ait = artifact_to_id.find(tok);
|
||||
ait != artifact_to_id.end()) {
|
||||
cur_target_id = ait->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cur_target_id.empty()) {
|
||||
auto &pt = out.targets_by_id.at(cur_target_id);
|
||||
const auto rhs = line.substr(colon + 1);
|
||||
for (const auto &tok : split_shell_tokens(rhs)) {
|
||||
if (const auto ait = artifact_to_id.find(tok);
|
||||
ait != artifact_to_id.end() && ait->second != cur_target_id) {
|
||||
if (!std::ranges::contains(pt.dep_ids, ait->second)) {
|
||||
pt.dep_ids.push_back(ait->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!cur_target_id.empty() && line.starts_with(" LINK_ARGS = ")) {
|
||||
auto &pt = out.targets_by_id.at(cur_target_id);
|
||||
const auto args_part = line.substr(13);
|
||||
for (const auto &tok : split_shell_tokens(args_part)) {
|
||||
if (tok.empty() || tok == "-Wl,--as-needed" || tok == "-Wl,--no-undefined" ||
|
||||
tok == "-Wl,--start-group" || tok == "-Wl,--end-group" ||
|
||||
tok == "-Wl,--allow-shlib-undefined" || tok.starts_with("-Wl,-rpath") ||
|
||||
tok.starts_with("-Wl,-soname") || tok == "-shared" || tok == "-fPIC") {
|
||||
continue;
|
||||
}
|
||||
if (is_safe_system_link_flag(tok)) {
|
||||
if (!std::ranges::contains(pt.link_options, tok)) {
|
||||
pt.link_options.push_back(tok);
|
||||
}
|
||||
} else if (const auto ait = artifact_to_id.find(tok);
|
||||
ait != artifact_to_id.end()) {
|
||||
if (ait->second != cur_target_id &&
|
||||
!std::ranges::contains(pt.dep_ids, ait->second)) {
|
||||
pt.dep_ids.push_back(ait->second);
|
||||
}
|
||||
} else if (tok.ends_with(".a") || tok.ends_with(".so") ||
|
||||
tok.starts_with("-l")) {
|
||||
add_unsupported(
|
||||
pt.name, "unsupported_link_fragment",
|
||||
std::format("Meson target '{}' has untranslated link argument '{}'",
|
||||
pt.name, tok));
|
||||
}
|
||||
}
|
||||
} else if (line.empty()) {
|
||||
cur_target_id.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (out.audit.is_supported()) {
|
||||
out.audit.summary = std::format("all {} Meson target(s) fit the bounded native subset",
|
||||
out.audit.supported_targets.size());
|
||||
} else {
|
||||
out.audit.summary = std::format("{} unsupported construct(s) detected across Meson project",
|
||||
out.audit.unsupported.size());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
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) {
|
||||
auto meson_bin = Platform::resolve_executable("meson");
|
||||
if (!meson_bin) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::not_found,
|
||||
"Meson translation requires 'meson' in PATH")};
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
std::filesystem::remove_all(configure_dir, ec);
|
||||
std::filesystem::create_directories(configure_dir.parent_path(), ec);
|
||||
|
||||
Void::Log::info("Translate", "Configuring Meson dependency '{}' for native graph audit...",
|
||||
request.dependency.name);
|
||||
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = *meson_bin;
|
||||
req.arguments = {"setup", configure_dir.string(), request.source.source_dir.string()};
|
||||
const std::string btype =
|
||||
(request.profile.name == "release" || request.profile.name == "Release") ? "release"
|
||||
: "debug";
|
||||
req.arguments.push_back("-Dbuildtype=" + btype);
|
||||
for (const auto &[k, v] : request.dependency.options) {
|
||||
req.arguments.push_back("-D" + k + "=" + meson_option_value(v));
|
||||
}
|
||||
req.environment.set_vars["CXX"] = request.toolchain.cxx_compiler.string();
|
||||
req.timeout = std::chrono::seconds{180};
|
||||
auto proc = Platform::run_supervised(req, stop);
|
||||
if (!proc || !proc->succeeded()) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("Meson setup failed for '{}':\n{}", request.dependency.name,
|
||||
proc ? (proc->stderr_data + proc->stdout_data) : proc.error().message()))};
|
||||
}
|
||||
return configure_dir / "meson-info";
|
||||
}
|
||||
|
||||
Void::Result::Result<TranslationAuditReport, Void::Result::Error>
|
||||
audit_meson_introspection(const std::filesystem::path &configure_dir) {
|
||||
auto loaded = load_and_audit_meson(configure_dir);
|
||||
if (!loaded) {
|
||||
return std::unexpected{loaded.error()};
|
||||
}
|
||||
return std::move(loaded->audit);
|
||||
}
|
||||
|
||||
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) {
|
||||
auto loaded = load_and_audit_meson(configure_dir);
|
||||
if (!loaded) {
|
||||
return std::unexpected{loaded.error()};
|
||||
}
|
||||
if (!loaded->audit.is_supported()) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::unsupported,
|
||||
format_unsupported_diagnostics(loaded->audit))};
|
||||
}
|
||||
|
||||
Graph::ProjectDescription desc;
|
||||
desc.profile = request.profile;
|
||||
desc.profile.compile_options.clear();
|
||||
desc.profile.defines.clear();
|
||||
|
||||
for (const auto &tid : loaded->target_order) {
|
||||
const auto &pt = loaded->targets_by_id.at(tid);
|
||||
TargetRecord tr;
|
||||
tr.name = pt.name;
|
||||
if (pt.type == "static library") {
|
||||
tr.kind = TargetKind::StaticLibrary;
|
||||
} else if (pt.type == "shared library") {
|
||||
tr.kind = TargetKind::SharedLibrary;
|
||||
} else {
|
||||
tr.kind = TargetKind::Executable;
|
||||
}
|
||||
tr.cxx_standard = pt.cxx_standard;
|
||||
|
||||
for (const auto &src : pt.sources) {
|
||||
tr.sources.push_back(SourceRecord{SourceKind::File, src.string()});
|
||||
}
|
||||
for (const auto &[inc, is_sys] : pt.includes) {
|
||||
tr.include_directories.push_back(
|
||||
IncludeDirectory{inc.string(), Visibility::Public, is_sys});
|
||||
}
|
||||
for (const auto &def : pt.defines) {
|
||||
tr.defines.push_back(ScopedOption{def, Visibility::Public});
|
||||
}
|
||||
for (const auto &opt : pt.compile_options) {
|
||||
tr.compile_options.push_back(opt);
|
||||
tr.scoped_compile_options.push_back(ScopedOption{opt, Visibility::Private});
|
||||
}
|
||||
for (const auto &lo : pt.link_options) {
|
||||
tr.link_options.push_back(ScopedOption{lo, Visibility::Public});
|
||||
}
|
||||
for (const auto &dep_id : pt.dep_ids) {
|
||||
const auto &dep_target = loaded->targets_by_id.at(dep_id);
|
||||
tr.links.push_back(
|
||||
LinkRecord{LinkKind::Local, dep_target.name, {}, Visibility::Public});
|
||||
}
|
||||
desc.targets.push_back(std::move(tr));
|
||||
}
|
||||
|
||||
Graph::GraphLowerOptions gopts{
|
||||
request.source.source_dir, native_build_root, snapshot, {}, 32768};
|
||||
auto graph = Graph::lower_project_graph(desc, request.toolchain, gopts);
|
||||
if (!graph) {
|
||||
return std::unexpected{graph.error()};
|
||||
}
|
||||
|
||||
TranslatedCMakeGraph result;
|
||||
result.audit = std::move(loaded->audit);
|
||||
|
||||
std::map<std::string, const Graph::ResolvedTargetSummary *, std::less<>> summary_by_name;
|
||||
for (const auto &s : graph->targets) {
|
||||
summary_by_name[s.name] = &s;
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
for (const auto &tid : loaded->target_order) {
|
||||
const auto &pt = loaded->targets_by_id.at(tid);
|
||||
const auto sit = summary_by_name.find(pt.name);
|
||||
if (sit == summary_by_name.end()) {
|
||||
continue;
|
||||
}
|
||||
Graph::ImportedTargetInterface iface;
|
||||
iface.dependency_name = request.dependency.name;
|
||||
iface.target_name = pt.name;
|
||||
iface.include_dirs = pt.includes;
|
||||
if (std::filesystem::is_directory(request.source.source_dir / "include", ec)) {
|
||||
const auto inc = (request.source.source_dir / "include").lexically_normal();
|
||||
if (!std::ranges::contains(iface.include_dirs, std::pair{inc, false})) {
|
||||
iface.include_dirs.emplace_back(inc, false);
|
||||
}
|
||||
}
|
||||
iface.defines = pt.defines;
|
||||
iface.link_options = pt.link_options;
|
||||
|
||||
if (!sit->second->primary_outputs.empty()) {
|
||||
const auto &primary = sit->second->primary_outputs.front();
|
||||
if (pt.type == "static library") {
|
||||
iface.static_libraries.push_back(primary);
|
||||
} else if (pt.type == "shared library") {
|
||||
iface.shared_libraries.push_back(primary);
|
||||
iface.runtime_files.push_back(primary);
|
||||
}
|
||||
}
|
||||
result.exported_targets[pt.name] = iface;
|
||||
result.exported_targets[request.dependency.name + "::" + pt.name] = std::move(iface);
|
||||
}
|
||||
|
||||
result.graph = std::move(*graph);
|
||||
return result;
|
||||
}
|
||||
|
||||
Void::Result::Result<TranslationResolution, Void::Result::Error>
|
||||
resolve_meson_with_translation(const ProviderRequest &request, State::StateStore &state,
|
||||
TranslationPolicy policy, std::stop_token stop) {
|
||||
if (request.dependency.builder != "meson") {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::invalid_argument,
|
||||
std::format("resolve_meson_with_translation requires builder='meson', got '{}'",
|
||||
request.dependency.builder))};
|
||||
}
|
||||
|
||||
const auto sw = Void::Time::Stopwatch::started();
|
||||
const std::string input_hash = compute_provider_input_hash(request);
|
||||
const auto slot_dir =
|
||||
request.provider_build_root /
|
||||
("translate_meson_" + request.dependency.name + "_" + input_hash.substr(0, 16));
|
||||
const auto cfg_dir = slot_dir / "meson-setup";
|
||||
const auto native_build_root = slot_dir / "native-build";
|
||||
|
||||
auto info_dir = configure_meson_for_translation(request, cfg_dir, stop);
|
||||
if (!info_dir) {
|
||||
return std::unexpected{info_dir.error()};
|
||||
}
|
||||
|
||||
auto audit = audit_meson_introspection(cfg_dir);
|
||||
if (!audit) {
|
||||
return std::unexpected{audit.error()};
|
||||
}
|
||||
|
||||
if (!audit->is_supported()) {
|
||||
if (policy == TranslationPolicy::RequireNative) {
|
||||
return std::unexpected{make_error(Void::System::SystemErrorCode::unsupported,
|
||||
format_unsupported_diagnostics(*audit))};
|
||||
}
|
||||
Void::Log::warn("Translate",
|
||||
"Meson dependency '{}' has unsupported constructs ({}); falling back to "
|
||||
"foreign Meson provider",
|
||||
request.dependency.name, audit->summary);
|
||||
auto fallback = resolve_foreign_provider(request, stop);
|
||||
if (!fallback) {
|
||||
return std::unexpected{fallback.error()};
|
||||
}
|
||||
TranslationResolution res;
|
||||
res.executed_natively = false;
|
||||
res.audit = std::move(*audit);
|
||||
res.exported = std::move(*fallback);
|
||||
return res;
|
||||
}
|
||||
|
||||
auto translated = translate_meson_to_native_graph(request, cfg_dir, native_build_root, nullptr);
|
||||
if (!translated) {
|
||||
return std::unexpected{translated.error()};
|
||||
}
|
||||
|
||||
Void::Log::info("Translate",
|
||||
"Executing Meson dependency '{}' natively ({} actions, 0 meson compile)...",
|
||||
request.dependency.name, translated->graph.actions.size());
|
||||
|
||||
auto exec = Execution::execute_graph(translated->graph, state, {}, stop);
|
||||
if (!exec) {
|
||||
return std::unexpected{exec.error()};
|
||||
}
|
||||
if (!exec->succeeded) {
|
||||
return std::unexpected{make_error(
|
||||
Void::System::SystemErrorCode::io_error,
|
||||
std::format("native execution of translated Meson dependency '{}' failed: {}",
|
||||
request.dependency.name, exec->diagnostic))};
|
||||
}
|
||||
|
||||
Void::Log::info("Translate",
|
||||
"Native Meson translation '{}' finished in {}ms ({} executed, {} cached)",
|
||||
request.dependency.name, sw.elapsed_as<std::chrono::milliseconds>().count(),
|
||||
exec->executed_count, exec->cached_count);
|
||||
|
||||
ProviderExport exp;
|
||||
exp.dependency_name = request.dependency.name;
|
||||
exp.builder = "meson-native-translated";
|
||||
exp.input_identity_hash = input_hash;
|
||||
exp.from_cache = (exec->executed_count == 0);
|
||||
exp.targets = std::move(translated->exported_targets);
|
||||
|
||||
TranslationResolution res;
|
||||
res.executed_natively = true;
|
||||
res.audit = std::move(translated->audit);
|
||||
res.exported = std::move(exp);
|
||||
res.native_execution = std::move(*exec);
|
||||
return res;
|
||||
}
|
||||
|
||||
Void::Result::Result<TranslationResolution, Void::Result::Error>
|
||||
resolve_foreign_with_translation(const ProviderRequest &request, State::StateStore &state,
|
||||
TranslationPolicy policy, std::stop_token stop) {
|
||||
if (request.dependency.builder == "cmake") {
|
||||
return resolve_cmake_with_translation(request, state, policy, stop);
|
||||
}
|
||||
if (request.dependency.builder == "meson") {
|
||||
return resolve_meson_with_translation(request, state, policy, stop);
|
||||
}
|
||||
auto fb = resolve_foreign_provider(request, stop);
|
||||
if (!fb) {
|
||||
return std::unexpected{fb.error()};
|
||||
}
|
||||
TranslationResolution res;
|
||||
res.executed_natively = false;
|
||||
res.audit.status = TranslationStatus::Unsupported;
|
||||
res.audit.summary = "builder '" + request.dependency.builder + "' uses foreign provider";
|
||||
res.exported = std::move(*fb);
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace Void::Build::Provider
|
||||
Reference in new issue
Block a user