mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 23:02:27 +00:00
Move primeCache() to Worker::run()
We need the missing path info to communicate the worker's remaining goals to the progress bar.
This commit is contained in:
parent
5927624473
commit
3b7e00ce22
@ -40,9 +40,8 @@ struct InitialOutput {
|
|||||||
std::optional<InitialOutputStatus> known;
|
std::optional<InitialOutputStatus> known;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DerivationGoal : public Goal
|
struct DerivationGoal : public Goal
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
/* Whether to use an on-disk .drv file. */
|
/* Whether to use an on-disk .drv file. */
|
||||||
bool useDerivation;
|
bool useDerivation;
|
||||||
|
|
||||||
@ -246,7 +245,6 @@ private:
|
|||||||
|
|
||||||
friend struct RestrictedStore;
|
friend struct RestrictedStore;
|
||||||
|
|
||||||
public:
|
|
||||||
DerivationGoal(const StorePath & drvPath,
|
DerivationGoal(const StorePath & drvPath,
|
||||||
const StringSet & wantedOutputs, Worker & worker,
|
const StringSet & wantedOutputs, Worker & worker,
|
||||||
BuildMode buildMode = bmNormal);
|
BuildMode buildMode = bmNormal);
|
||||||
@ -264,17 +262,11 @@ public:
|
|||||||
|
|
||||||
void work() override;
|
void work() override;
|
||||||
|
|
||||||
StorePath getDrvPath()
|
|
||||||
{
|
|
||||||
return drvPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add wanted outputs to an already existing derivation goal. */
|
/* Add wanted outputs to an already existing derivation goal. */
|
||||||
void addWantedOutputs(const StringSet & outputs);
|
void addWantedOutputs(const StringSet & outputs);
|
||||||
|
|
||||||
BuildResult getResult() { return result; }
|
BuildResult getResult() { return result; }
|
||||||
|
|
||||||
private:
|
|
||||||
/* The states. */
|
/* The states. */
|
||||||
void getDerivation();
|
void getDerivation();
|
||||||
void loadDerivation();
|
void loadDerivation();
|
||||||
@ -318,8 +310,6 @@ private:
|
|||||||
/* Run the builder's process. */
|
/* Run the builder's process. */
|
||||||
void runChild();
|
void runChild();
|
||||||
|
|
||||||
friend int childEntry(void *);
|
|
||||||
|
|
||||||
/* Check that the derivation outputs all exist and register them
|
/* Check that the derivation outputs all exist and register them
|
||||||
as valid. */
|
as valid. */
|
||||||
void registerOutputs();
|
void registerOutputs();
|
||||||
|
@ -5,25 +5,10 @@
|
|||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
static void primeCache(Store & store, const std::vector<StorePathWithOutputs> & paths)
|
|
||||||
{
|
|
||||||
StorePathSet willBuild, willSubstitute, unknown;
|
|
||||||
uint64_t downloadSize, narSize;
|
|
||||||
store.queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
|
||||||
|
|
||||||
if (!willBuild.empty() && 0 == settings.maxBuildJobs && getMachines().empty())
|
|
||||||
throw Error(
|
|
||||||
"%d derivations need to be built, but neither local builds ('--max-jobs') "
|
|
||||||
"nor remote builds ('--builders') are enabled", willBuild.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LocalStore::buildPaths(const std::vector<StorePathWithOutputs> & drvPaths, BuildMode buildMode)
|
void LocalStore::buildPaths(const std::vector<StorePathWithOutputs> & drvPaths, BuildMode buildMode)
|
||||||
{
|
{
|
||||||
Worker worker(*this);
|
Worker worker(*this);
|
||||||
|
|
||||||
primeCache(*this, drvPaths);
|
|
||||||
|
|
||||||
Goals goals;
|
Goals goals;
|
||||||
for (auto & path : drvPaths) {
|
for (auto & path : drvPaths) {
|
||||||
if (path.path.isDerivation())
|
if (path.path.isDerivation())
|
||||||
@ -44,9 +29,8 @@ void LocalStore::buildPaths(const std::vector<StorePathWithOutputs> & drvPaths,
|
|||||||
ex = i->ex;
|
ex = i->ex;
|
||||||
}
|
}
|
||||||
if (i->exitCode != Goal::ecSuccess) {
|
if (i->exitCode != Goal::ecSuccess) {
|
||||||
DerivationGoal * i2 = dynamic_cast<DerivationGoal *>(i.get());
|
if (auto i2 = dynamic_cast<DerivationGoal *>(i.get())) failed.insert(i2->drvPath);
|
||||||
if (i2) failed.insert(i2->getDrvPath());
|
else if (auto i2 = dynamic_cast<SubstitutionGoal *>(i.get())) failed.insert(i2->storePath);
|
||||||
else failed.insert(dynamic_cast<SubstitutionGoal *>(i.get())->getStorePath());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +68,6 @@ void LocalStore::ensurePath(const StorePath & path)
|
|||||||
/* If the path is already valid, we're done. */
|
/* If the path is already valid, we're done. */
|
||||||
if (isValidPath(path)) return;
|
if (isValidPath(path)) return;
|
||||||
|
|
||||||
primeCache(*this, {{path}});
|
|
||||||
|
|
||||||
Worker worker(*this);
|
Worker worker(*this);
|
||||||
GoalPtr goal = worker.makeSubstitutionGoal(path);
|
GoalPtr goal = worker.makeSubstitutionGoal(path);
|
||||||
Goals goals = {goal};
|
Goals goals = {goal};
|
||||||
|
@ -8,11 +8,8 @@ namespace nix {
|
|||||||
|
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
||||||
class SubstitutionGoal : public Goal
|
struct SubstitutionGoal : public Goal
|
||||||
{
|
{
|
||||||
friend class Worker;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/* The store path that should be realised through a substitute. */
|
/* The store path that should be realised through a substitute. */
|
||||||
StorePath storePath;
|
StorePath storePath;
|
||||||
|
|
||||||
@ -56,7 +53,6 @@ private:
|
|||||||
/* Content address for recomputing store path */
|
/* Content address for recomputing store path */
|
||||||
std::optional<ContentAddress> ca;
|
std::optional<ContentAddress> ca;
|
||||||
|
|
||||||
public:
|
|
||||||
SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
|
SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
|
||||||
~SubstitutionGoal();
|
~SubstitutionGoal();
|
||||||
|
|
||||||
@ -82,8 +78,6 @@ public:
|
|||||||
/* Callback used by the worker to write to the log. */
|
/* Callback used by the worker to write to the log. */
|
||||||
void handleChildOutput(int fd, const string & data) override;
|
void handleChildOutput(int fd, const string & data) override;
|
||||||
void handleEOF(int fd) override;
|
void handleEOF(int fd) override;
|
||||||
|
|
||||||
StorePath getStorePath() { return storePath; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,26 @@ void Worker::waitForAWhile(GoalPtr goal)
|
|||||||
|
|
||||||
void Worker::run(const Goals & _topGoals)
|
void Worker::run(const Goals & _topGoals)
|
||||||
{
|
{
|
||||||
for (auto & i : _topGoals) topGoals.insert(i);
|
std::vector<nix::StorePathWithOutputs> topPaths;
|
||||||
|
|
||||||
|
for (auto & i : _topGoals) {
|
||||||
|
topGoals.insert(i);
|
||||||
|
if (auto goal = dynamic_cast<DerivationGoal *>(i.get())) {
|
||||||
|
topPaths.push_back({goal->drvPath, goal->wantedOutputs});
|
||||||
|
} else if (auto goal = dynamic_cast<SubstitutionGoal *>(i.get())) {
|
||||||
|
topPaths.push_back({goal->storePath});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call queryMissing() efficiently query substitutes. */
|
||||||
|
StorePathSet willBuild, willSubstitute, unknown;
|
||||||
|
uint64_t downloadSize, narSize;
|
||||||
|
store.queryMissing(topPaths, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||||
|
|
||||||
|
if (!willBuild.empty() && 0 == settings.maxBuildJobs && getMachines().empty())
|
||||||
|
throw Error(
|
||||||
|
"%d derivations need to be built, but neither local builds ('--max-jobs') "
|
||||||
|
"nor remote builds ('--builders') are enabled", willBuild.size());
|
||||||
|
|
||||||
debug("entered goal loop");
|
debug("entered goal loop");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user