Skip to content

Commit

Permalink
Merge branch 'lots-of-buildable' into indexed-store-path-outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Mar 6, 2021
2 parents 8d36d96 + 1f5a011 commit cece11c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
4 changes: 1 addition & 3 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,8 @@ Value & EvalState::getBuiltin(const string & name)

std::optional<EvalState::Doc> EvalState::getDoc(Value & v)
{
if (v.isPrimOp() || v.isPrimOpApp()) {
if (v.isPrimOp()) {
auto v2 = &v;
while (v2->isPrimOpApp())
v2 = v2->primOpApp.left;
if (v2->primOp->doc)
return Doc {
.pos = noPos,
Expand Down
41 changes: 18 additions & 23 deletions src/libstore/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,53 @@ void Store::computeFSClosure(const StorePathSet & startPaths,

Sync<State> state_(State{0, paths_, 0});

std::function<void(const Path &)> enqueue;
std::function<void(const StorePath &)> enqueue;

std::condition_variable done;

enqueue = [&](const Path & path) -> void {
enqueue = [&](const StorePath & path) -> void {
{
auto state(state_.lock());
if (state->exc) return;
if (!state->paths.insert(parseStorePath(path)).second) return;
if (!state->paths.insert(path).second) return;
state->pending++;
}

queryPathInfo(parseStorePath(path), {[&, pathS(path)](std::future<ref<const ValidPathInfo>> fut) {
queryPathInfo(path, {[&](std::future<ref<const ValidPathInfo>> fut) {
// FIXME: calls to isValidPath() should be async

try {
auto info = fut.get();

auto path = parseStorePath(pathS);

if (flipDirection) {

StorePathSet referrers;
queryReferrers(path, referrers);
for (auto & ref : referrers)
if (ref != path)
enqueue(printStorePath(ref));
enqueue(ref);

if (includeOutputs)
for (auto & i : queryValidDerivers(path))
enqueue(printStorePath(i));
enqueue(i);

if (includeDerivers && path.isDerivation())
for (auto & i : queryDerivationOutputs(path))
if (isValidPath(i) && queryPathInfo(i)->deriver == path)
enqueue(printStorePath(i));
enqueue(i);

} else {

for (auto & ref : info->references)
if (ref != path)
enqueue(printStorePath(ref));
enqueue(ref);

if (includeOutputs && path.isDerivation())
for (auto & i : queryDerivationOutputs(path))
if (isValidPath(i)) enqueue(printStorePath(i));
if (isValidPath(i)) enqueue(i);

if (includeDerivers && info->deriver && isValidPath(*info->deriver))
enqueue(printStorePath(*info->deriver));
enqueue(*info->deriver);

}

Expand All @@ -90,7 +88,7 @@ void Store::computeFSClosure(const StorePathSet & startPaths,
};

for (auto & startPath : startPaths)
enqueue(printStorePath(startPath));
enqueue(startPath);

{
auto state(state_.lock());
Expand Down Expand Up @@ -160,13 +158,10 @@ void Store::queryMissing(const std::vector<BuildableReq> & targets,
};

auto checkOutput = [&](
const Path & drvPathS, ref<Derivation> drv, const Path & outPathS, ref<Sync<DrvState>> drvState_)
const StorePath & drvPath, ref<Derivation> drv, const StorePath & outPath, ref<Sync<DrvState>> drvState_)
{
if (drvState_->lock()->done) return;

auto drvPath = parseStorePath(drvPathS);
auto outPath = parseStorePath(outPathS);

SubstitutablePathInfos infos;
querySubstitutablePathInfos({{outPath, getDerivationCA(*drv)}}, infos);

Expand Down Expand Up @@ -195,16 +190,16 @@ void Store::queryMissing(const std::vector<BuildableReq> & targets,
if (!state->done.insert(to_string(*this, req)).second) return;
}

std::visit(overloaded {
[&](BuildableReqFromDrv bfd) {
std::visit(overloaded {
[&](BuildableReqFromDrv bfd) {
if (!isValidPath(bfd.drvPath)) {
// FIXME: we could try to substitute the derivation.
auto state(state_.lock());
state->unknown.insert(bfd.drvPath);
return;
}

PathSet invalid;
StorePathSet invalid;
/* true for regular derivations, and CA derivations for which we
have a trust mapping for all wanted outputs. */
auto knownOutputPaths = true;
Expand All @@ -214,7 +209,7 @@ void Store::queryMissing(const std::vector<BuildableReq> & targets,
break;
}
if (wantOutput(outputName, bfd.outputs) && !isValidPath(*pathOpt))
invalid.insert(printStorePath(*pathOpt));
invalid.insert(*pathOpt);
}
if (knownOutputPaths && invalid.empty()) return;

Expand All @@ -224,12 +219,12 @@ void Store::queryMissing(const std::vector<BuildableReq> & targets,
if (knownOutputPaths && settings.useSubstitutes && parsedDrv.substitutesAllowed()) {
auto drvState = make_ref<Sync<DrvState>>(DrvState(invalid.size()));
for (auto & output : invalid)
pool.enqueue(std::bind(checkOutput, printStorePath(bfd.drvPath), drv, output, drvState));
pool.enqueue(std::bind(checkOutput, bfd.drvPath, drv, output, drvState));
} else
mustBuildDrv(bfd.drvPath, *drv);

},
[&](BuildableOpaque bo) {
[&](BuildableOpaque bo) {

if (isValidPath(bo.path)) return;

Expand Down

0 comments on commit cece11c

Please sign in to comment.