aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-08-25 13:41:56 +0200
committereldritch horrors <pennae@lix.systems>2024-08-30 10:18:28 +0000
commita5c1e73fa8e004a93e37254a3582ba91048c4550 (patch)
tree7788396907f8108a413eec22623ee01737cfb54d /src/libstore/build/worker.cc
parentbb161a96cf1171a5c4ed3661a0f2f5a93ac10804 (diff)
libstore: add "is dependency" info to goal
whether goal errors are reported via the `ex` member or just printed to the log depends on whether the goal is a toplevel goal or a dependency. if goals are aware of this themselves we can move error printing out of the worker loop, and since a running worker can only be used by running goals it's totally sufficient to keep a `Worker::running` flag for this Change-Id: I6b5cbe6eccee1afa5fde80653c4b968554ddd16f
Diffstat (limited to 'src/libstore/build/worker.cc')
-rw-r--r--src/libstore/build/worker.cc45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc
index 1b4633e64..9e548cc16 100644
--- a/src/libstore/build/worker.cc
+++ b/src/libstore/build/worker.cc
@@ -1,5 +1,6 @@
#include "charptr-cast.hh"
#include "worker.hh"
+#include "finally.hh"
#include "substitution-goal.hh"
#include "drv-output-substitution-goal.hh"
#include "local-derivation-goal.hh"
@@ -59,22 +60,38 @@ std::shared_ptr<DerivationGoal> Worker::makeDerivationGoalCommon(
std::shared_ptr<DerivationGoal> Worker::makeDerivationGoal(const StorePath & drvPath,
const OutputsSpec & wantedOutputs, BuildMode buildMode)
{
- return makeDerivationGoalCommon(drvPath, wantedOutputs, [&]() -> std::shared_ptr<DerivationGoal> {
- return !dynamic_cast<LocalStore *>(&store)
- ? std::make_shared<DerivationGoal>(drvPath, wantedOutputs, *this, buildMode)
- : LocalDerivationGoal::makeLocalDerivationGoal(drvPath, wantedOutputs, *this, buildMode);
- });
+ return makeDerivationGoalCommon(
+ drvPath,
+ wantedOutputs,
+ [&]() -> std::shared_ptr<DerivationGoal> {
+ return !dynamic_cast<LocalStore *>(&store)
+ ? std::make_shared<DerivationGoal>(
+ drvPath, wantedOutputs, *this, running, buildMode
+ )
+ : LocalDerivationGoal::makeLocalDerivationGoal(
+ drvPath, wantedOutputs, *this, running, buildMode
+ );
+ }
+ );
}
std::shared_ptr<DerivationGoal> Worker::makeBasicDerivationGoal(const StorePath & drvPath,
const BasicDerivation & drv, const OutputsSpec & wantedOutputs, BuildMode buildMode)
{
- return makeDerivationGoalCommon(drvPath, wantedOutputs, [&]() -> std::shared_ptr<DerivationGoal> {
- return !dynamic_cast<LocalStore *>(&store)
- ? std::make_shared<DerivationGoal>(drvPath, drv, wantedOutputs, *this, buildMode)
- : LocalDerivationGoal::makeLocalDerivationGoal(drvPath, drv, wantedOutputs, *this, buildMode);
- });
+ return makeDerivationGoalCommon(
+ drvPath,
+ wantedOutputs,
+ [&]() -> std::shared_ptr<DerivationGoal> {
+ return !dynamic_cast<LocalStore *>(&store)
+ ? std::make_shared<DerivationGoal>(
+ drvPath, drv, wantedOutputs, *this, running, buildMode
+ )
+ : LocalDerivationGoal::makeLocalDerivationGoal(
+ drvPath, drv, wantedOutputs, *this, running, buildMode
+ );
+ }
+ );
}
@@ -83,7 +100,7 @@ std::shared_ptr<PathSubstitutionGoal> Worker::makePathSubstitutionGoal(const Sto
std::weak_ptr<PathSubstitutionGoal> & goal_weak = substitutionGoals[path];
auto goal = goal_weak.lock(); // FIXME
if (!goal) {
- goal = std::make_shared<PathSubstitutionGoal>(path, *this, repair, ca);
+ goal = std::make_shared<PathSubstitutionGoal>(path, *this, running, repair, ca);
goal_weak = goal;
wakeUp(goal);
}
@@ -96,7 +113,7 @@ std::shared_ptr<DrvOutputSubstitutionGoal> Worker::makeDrvOutputSubstitutionGoal
std::weak_ptr<DrvOutputSubstitutionGoal> & goal_weak = drvOutputSubstitutionGoals[id];
auto goal = goal_weak.lock(); // FIXME
if (!goal) {
- goal = std::make_shared<DrvOutputSubstitutionGoal>(id, *this, repair, ca);
+ goal = std::make_shared<DrvOutputSubstitutionGoal>(id, *this, running, repair, ca);
goal_weak = goal;
wakeUp(goal);
}
@@ -313,6 +330,10 @@ void Worker::run(const Goals & _topGoals)
{
std::vector<nix::DerivedPath> topPaths;
+ assert(!running);
+ running = true;
+ Finally const _stop([&] { running = false; });
+
for (auto & i : _topGoals) {
topGoals.insert(i);
if (auto goal = dynamic_cast<DerivationGoal *>(i.get())) {