[M6] preserve every probe's scratch under last-failure/<pkg>/

This commit is contained in:
2026-05-15 13:43:16 +00:00
parent c46f3aa1f0
commit 8b396bcd0f
6 changed files with 79 additions and 72 deletions

View File

@@ -160,14 +160,17 @@ auto cmd_build(const fs::path& project_root, bool no_build, bool release,
return cmd_build(root, /*no_build=*/false, /*release=*/false,
/*target=*/std::nullopt, effective_overlay);
};
const auto scratch_root =
std::filesystem::temp_directory_path() /
std::format("cargoxx-discover-{}", std::random_device{}());
auto disc = resolver::discover(name, version, components,
effective_overlay, scratch_root, build_fn);
const auto scratch_root = resolver::last_failure_dir(name);
std::error_code ec;
std::filesystem::remove_all(scratch_root, ec);
std::filesystem::create_directories(scratch_root, ec);
auto disc = resolver::discover(name, version, components,
effective_overlay, scratch_root, build_fn);
if (!disc) {
std::cerr << std::format(
"note: every probe attempt's scratch project is preserved at\n"
" {}/ — re-run cmake inside any subdir to reproduce.\n",
scratch_root.string());
return std::unexpected(disc.error());
}
return {};