mirror of
https://github.com/NixOS/nix.git
synced 2025-12-05 00:21:01 +01:00
Use std::variant to enforce BuildResult invariants
There is now a clean separation between successful and failing build results.
This commit is contained in:
parent
43550e8edb
commit
e731c43eae
29 changed files with 568 additions and 397 deletions
|
|
@ -598,16 +598,15 @@ std::vector<KeyedBuildResult> RemoteStore::buildPathsWithResults(
|
|||
[&](const DerivedPath::Opaque & bo) {
|
||||
results.push_back(
|
||||
KeyedBuildResult{
|
||||
{
|
||||
.status = BuildResult::Substituted,
|
||||
},
|
||||
{.inner{BuildResult::Success{
|
||||
.status = BuildResult::Success::Substituted,
|
||||
}}},
|
||||
/* .path = */ bo,
|
||||
});
|
||||
},
|
||||
[&](const DerivedPath::Built & bfd) {
|
||||
KeyedBuildResult res{
|
||||
{.status = BuildResult::Built},
|
||||
/* .path = */ bfd,
|
||||
BuildResult::Success success{
|
||||
.status = BuildResult::Success::Built,
|
||||
};
|
||||
|
||||
OutputPathMap outputs;
|
||||
|
|
@ -627,9 +626,9 @@ std::vector<KeyedBuildResult> RemoteStore::buildPathsWithResults(
|
|||
auto realisation = queryRealisation(outputId);
|
||||
if (!realisation)
|
||||
throw MissingRealisation(outputId);
|
||||
res.builtOutputs.emplace(output, *realisation);
|
||||
success.builtOutputs.emplace(output, *realisation);
|
||||
} else {
|
||||
res.builtOutputs.emplace(
|
||||
success.builtOutputs.emplace(
|
||||
output,
|
||||
Realisation{
|
||||
.id = outputId,
|
||||
|
|
@ -638,7 +637,11 @@ std::vector<KeyedBuildResult> RemoteStore::buildPathsWithResults(
|
|||
}
|
||||
}
|
||||
|
||||
results.push_back(res);
|
||||
results.push_back(
|
||||
KeyedBuildResult{
|
||||
{.inner = std::move(success)},
|
||||
/* .path = */ bfd,
|
||||
});
|
||||
}},
|
||||
path.raw());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue