forked from lix-project/lix
Clean up toDerivedPaths() logic
This commit is contained in:
parent
1123c42f90
commit
7f1af270dd
|
@ -478,11 +478,9 @@ struct InstallableAttrPath : InstallableValue
|
||||||
DrvInfos drvInfos;
|
DrvInfos drvInfos;
|
||||||
getDerivations(*state, *v, "", autoArgs, drvInfos, false);
|
getDerivations(*state, *v, "", autoArgs, drvInfos, false);
|
||||||
|
|
||||||
DerivedPathsWithInfo res;
|
|
||||||
|
|
||||||
// Backward compatibility hack: group results by drvPath. This
|
// Backward compatibility hack: group results by drvPath. This
|
||||||
// helps keep .all output together.
|
// helps keep .all output together.
|
||||||
std::map<StorePath, size_t> byDrvPath;
|
std::map<StorePath, DerivedPath::Built> byDrvPath;
|
||||||
|
|
||||||
for (auto & drvInfo : drvInfos) {
|
for (auto & drvInfo : drvInfos) {
|
||||||
auto drvPath = drvInfo.queryDrvPath();
|
auto drvPath = drvInfo.queryDrvPath();
|
||||||
|
@ -497,21 +495,16 @@ struct InstallableAttrPath : InstallableValue
|
||||||
for (auto & output : drvInfo.queryOutputs(false, std::get_if<DefaultOutputs>(&outputsSpec)))
|
for (auto & output : drvInfo.queryOutputs(false, std::get_if<DefaultOutputs>(&outputsSpec)))
|
||||||
outputsToInstall.insert(output.first);
|
outputsToInstall.insert(output.first);
|
||||||
|
|
||||||
auto i = byDrvPath.find(*drvPath);
|
auto derivedPath = byDrvPath.emplace(*drvPath, DerivedPath::Built { .drvPath = *drvPath }).first;
|
||||||
if (i == byDrvPath.end()) {
|
|
||||||
byDrvPath[*drvPath] = res.size();
|
|
||||||
res.push_back({
|
|
||||||
.path = DerivedPath::Built {
|
|
||||||
.drvPath = std::move(*drvPath),
|
|
||||||
.outputs = std::move(outputsToInstall),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
for (auto & output : outputsToInstall)
|
for (auto & output : outputsToInstall)
|
||||||
std::get<DerivedPath::Built>(res[i->second].path).outputs.insert(output);
|
derivedPath->second.outputs.insert(output);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DerivedPathsWithInfo res;
|
||||||
|
for (auto & [_, info] : byDrvPath)
|
||||||
|
res.push_back({ .path = { info } });
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue