diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 15 | ||||
-rw-r--r-- | src/libstore/misc.cc | 5 | ||||
-rw-r--r-- | src/libstore/misc.hh | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 20ed2de39005..6e0a2b97bff0 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1072,7 +1072,7 @@ void DerivationGoal::haveDerivation() /* We are first going to try to create the invalid output paths through substitutes. If that doesn't work, we'll build them. */ - if (settings.useSubstitutes) + if (settings.useSubstitutes && !willBuildLocally(drv)) foreach (PathSet::iterator, i, invalidOutputs) addWaitee(worker.makeSubstitutionGoal(*i, repair)); @@ -1273,6 +1273,12 @@ static bool canBuildLocally(const string & platform) } +bool willBuildLocally(Derivation & drv) +{ + return drv.env["preferLocalBuild"] == "1" && canBuildLocally(drv.platform); +} + + void DerivationGoal::tryToBuild() { trace("trying to build"); @@ -1337,11 +1343,10 @@ void DerivationGoal::tryToBuild() /* Don't do a remote build if the derivation has the attribute `preferLocalBuild' set. */ - bool preferLocalBuild = - drv.env["preferLocalBuild"] == "1" && canBuildLocally(drv.platform); + bool buildLocally = willBuildLocally(drv); /* Is the build hook willing to accept this job? */ - if (!preferLocalBuild) { + if (!buildLocally) { switch (tryBuildHook()) { case rpAccept: /* Yes, it has started doing so. Wait until we get @@ -1364,7 +1369,7 @@ void DerivationGoal::tryToBuild() derivation prefers to be done locally, do it even if maxBuildJobs is 0. */ unsigned int curBuilds = worker.getNrLocalBuilds(); - if (curBuilds >= settings.maxBuildJobs && !(preferLocalBuild && curBuilds == 0)) { + if (curBuilds >= settings.maxBuildJobs && !(buildLocally && curBuilds == 0)) { worker.waitForBuildSlot(shared_from_this()); outputLocks.unlock(); return; diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 74ff26b9cc5c..1bf3f9378245 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -120,7 +120,8 @@ void queryMissing(StoreAPI & store, const PathSet & targets, if (invalid.empty()) continue; todoDrv.insert(*i); - if (settings.useSubstitutes) query.insert(invalid.begin(), invalid.end()); + if (settings.useSubstitutes && !willBuildLocally(drv)) + query.insert(invalid.begin(), invalid.end()); } else { @@ -143,7 +144,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets, PathSet outputs; bool mustBuild = false; - if (settings.useSubstitutes) { + if (settings.useSubstitutes && !willBuildLocally(drv)) { foreach (DerivationOutputs::iterator, j, drv.outputs) { if (!wantOutput(j->first, i2.second)) continue; if (!store.isValidPath(j->second.path)) { diff --git a/src/libstore/misc.hh b/src/libstore/misc.hh index b4bd9ed8a49f..6f90ebe5e442 100644 --- a/src/libstore/misc.hh +++ b/src/libstore/misc.hh @@ -32,5 +32,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets, PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown, unsigned long long & downloadSize, unsigned long long & narSize); +bool willBuildLocally(Derivation & drv); + } |