libstore: add build result to Goal::Finished

it just makes sense to have it too, rather than just the pass/fail
information we keep so far. once we turn goals into something more
promise-shaped it'll also help detangle the current data flow mess

Change-Id: I915cf04d177cad849ea7a5833215d795326f1946
This commit is contained in:
eldritch horrors 2024-08-30 19:01:30 +02:00
parent a385c5935a
commit d75df91f74
4 changed files with 9 additions and 5 deletions

View file

@ -1550,6 +1550,7 @@ Goal::Finished DerivationGoal::done(
return Finished{
.exitCode = buildResult.success() ? ecSuccess : ecFailed,
.result = buildResult,
.ex = ex ? std::make_shared<Error>(std::move(*ex)) : nullptr,
.permanentFailure = buildResult.status == BuildResult::PermanentFailure,
.timedOut = buildResult.status == BuildResult::TimedOut,

View file

@ -1,4 +1,5 @@
#include "drv-output-substitution-goal.hh"
#include "build-result.hh"
#include "finally.hh"
#include "worker.hh"
#include "substitution-goal.hh"
@ -27,7 +28,7 @@ Goal::WorkResult DrvOutputSubstitutionGoal::init(bool inBuildSlot)
/* If the derivation already exists, were done */
if (worker.store.queryRealisation(id)) {
return Finished{ecSuccess};
return Finished{ecSuccess, std::move(buildResult)};
}
subs = settings.useSubstitutes ? getDefaultSubstituters() : std::list<ref<Store>>();
@ -56,7 +57,7 @@ Goal::WorkResult DrvOutputSubstitutionGoal::tryNext(bool inBuildSlot)
/* Hack: don't indicate failure if there were no substituters.
In that case the calling derivation should just do a
build. */
return Finished{substituterFailed ? ecFailed : ecNoSubstituters};
return Finished{substituterFailed ? ecFailed : ecNoSubstituters, std::move(buildResult)};
}
sub = subs.front();
@ -133,7 +134,8 @@ Goal::WorkResult DrvOutputSubstitutionGoal::outPathValid(bool inBuildSlot)
if (nrFailed > 0) {
debug("The output path of the derivation output '%s' could not be substituted", id.to_string());
return Finished{
nrNoSubstituters > 0 || nrIncompleteClosure > 0 ? ecIncompleteClosure : ecFailed
nrNoSubstituters > 0 || nrIncompleteClosure > 0 ? ecIncompleteClosure : ecFailed,
std::move(buildResult),
};
}
@ -144,7 +146,7 @@ Goal::WorkResult DrvOutputSubstitutionGoal::outPathValid(bool inBuildSlot)
Goal::WorkResult DrvOutputSubstitutionGoal::finished()
{
trace("finished");
return Finished{ecSuccess};
return Finished{ecSuccess, std::move(buildResult)};
}
std::string DrvOutputSubstitutionGoal::key()

View file

@ -125,6 +125,7 @@ public:
};
struct [[nodiscard]] Finished {
ExitCode exitCode;
BuildResult result;
std::shared_ptr<Error> ex;
bool permanentFailure = false;
bool timedOut = false;

View file

@ -41,7 +41,7 @@ Goal::Finished PathSubstitutionGoal::done(
debug(*errorMsg);
buildResult.errorMsg = *errorMsg;
}
return Finished{result};
return Finished{result, std::move(buildResult)};
}