libstore: move Goal::exitCode to WorkResult

the field is simply duplicated between the two, and now that we can
return WorkResults from Worker::run we no longer need both of them.

Change-Id: I82fc47d050b39b7bb7d1656445630d271f6c9830
This commit is contained in:
eldritch horrors 2024-10-05 00:38:35 +02:00
parent fc6291e46d
commit 7ff60b7445
3 changed files with 13 additions and 17 deletions

View file

@ -32,7 +32,7 @@ void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMod
else else
ex = i->ex; ex = i->ex;
} }
if (i->exitCode != Goal::ecSuccess) { if (result.exitCode != Goal::ecSuccess) {
if (auto i2 = dynamic_cast<DerivationGoal *>(i.get())) if (auto i2 = dynamic_cast<DerivationGoal *>(i.get()))
failed.insert(printStorePath(i2->drvPath)); failed.insert(printStorePath(i2->drvPath));
else if (auto i2 = dynamic_cast<PathSubstitutionGoal *>(i.get())) else if (auto i2 = dynamic_cast<PathSubstitutionGoal *>(i.get()))
@ -118,7 +118,7 @@ void Store::ensurePath(const StorePath & path)
}); });
auto [goal, result] = *goals.begin(); auto [goal, result] = *goals.begin();
if (goal->exitCode != Goal::ecSuccess) { if (result.exitCode != Goal::ecSuccess) {
if (goal->ex) { if (goal->ex) {
goal->ex->withExitStatus(worker.failingExitStatus()); goal->ex->withExitStatus(worker.failingExitStatus());
throw std::move(*goal->ex); throw std::move(*goal->ex);
@ -140,7 +140,7 @@ void Store::repairPath(const StorePath & path)
}); });
auto [goal, result] = *goals.begin(); auto [goal, result] = *goals.begin();
if (goal->exitCode != Goal::ecSuccess) { if (result.exitCode != Goal::ecSuccess) {
/* Since substituting the path didn't work, if we have a valid /* Since substituting the path didn't work, if we have a valid
deriver, then rebuild the deriver. */ deriver, then rebuild the deriver. */
auto info = queryPathInfo(path); auto info = queryPathInfo(path);

View file

@ -25,8 +25,6 @@ try {
BOOST_OUTCOME_CO_TRY(auto result, co_await workImpl()); BOOST_OUTCOME_CO_TRY(auto result, co_await workImpl());
trace("done"); trace("done");
assert(!exitCode.has_value());
exitCode = result.exitCode;
ex = result.ex; ex = result.ex;
notify->fulfill(result); notify->fulfill(result);
@ -42,14 +40,17 @@ Goal::waitForGoals(kj::Array<std::pair<GoalPtr, kj::Promise<Result<WorkResult>>>
try { try {
auto left = dependencies.size(); auto left = dependencies.size();
for (auto & [dep, p] : dependencies) { for (auto & [dep, p] : dependencies) {
p = p.then([this, dep, &left](auto _result) { p = p.then([this, dep, &left](auto _result) -> Result<WorkResult> {
BOOST_OUTCOME_TRY(auto result, _result);
left--; left--;
trace(fmt("waitee '%s' done; %d left", dep->name, left)); trace(fmt("waitee '%s' done; %d left", dep->name, left));
if (dep->exitCode != Goal::ecSuccess) ++nrFailed; if (result.exitCode != Goal::ecSuccess) ++nrFailed;
if (dep->exitCode == Goal::ecNoSubstituters) ++nrNoSubstituters; if (result.exitCode == Goal::ecNoSubstituters) ++nrNoSubstituters;
if (dep->exitCode == Goal::ecIncompleteClosure) ++nrIncompleteClosure; if (result.exitCode == Goal::ecIncompleteClosure) ++nrIncompleteClosure;
return _result;
return std::move(result);
}).eagerlyEvaluate(nullptr); }).eagerlyEvaluate(nullptr);
} }
@ -57,11 +58,11 @@ try {
while (auto item = co_await collectDeps.next()) { while (auto item = co_await collectDeps.next()) {
auto & [dep, _result] = *item; auto & [dep, _result] = *item;
BOOST_OUTCOME_CO_TRYV(_result); BOOST_OUTCOME_CO_TRY(auto result, _result);
waiteeDone(dep); waiteeDone(dep);
if (dep->exitCode == ecFailed && !settings.keepGoing) { if (result.exitCode == ecFailed && !settings.keepGoing) {
co_return result::success(); co_return result::success();
} }
} }

View file

@ -82,11 +82,6 @@ struct Goal
*/ */
std::string name; std::string name;
/**
* Whether the goal is finished.
*/
std::optional<ExitCode> exitCode;
/** /**
* Build result. * Build result.
*/ */