diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-12 20:20:27 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-12 20:20:27 -0500 |
commit | 31875bcfb7ccbbf6e88c2cc62714a2a3794994ec (patch) | |
tree | b3750a8c2f786afa433c0d41071478fe2a80ecc7 /src/libcmd/installables.cc | |
parent | 0faf5326bd333eeef126730683dc02009a06402f (diff) |
Split `OutputsSpec::merge` into `OuputsSpec::{union_, isSubsetOf}`
Additionally get rid of the evil time we made an empty
`OutputSpec::Names()`.
Diffstat (limited to 'src/libcmd/installables.cc')
-rw-r--r-- | src/libcmd/installables.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index d73109873..5090ea6d2 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -469,20 +469,14 @@ struct InstallableAttrPath : InstallableValue // Backward compatibility hack: group results by drvPath. This // helps keep .all output together. - std::map<StorePath, DerivedPath::Built> byDrvPath; + std::map<StorePath, OutputsSpec> byDrvPath; for (auto & drvInfo : drvInfos) { auto drvPath = drvInfo.queryDrvPath(); if (!drvPath) throw Error("'%s' is not a derivation", what()); - auto derivedPath = byDrvPath.emplace(*drvPath, DerivedPath::Built { - .drvPath = *drvPath, - // Not normally legal, but we will merge right below - .outputs = OutputsSpec::Names { StringSet { } }, - }).first; - - derivedPath->second.outputs.merge(std::visit(overloaded { + auto newOutputs = std::visit(overloaded { [&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec { std::set<std::string> outputsToInstall; for (auto & output : drvInfo.queryOutputs(false, true)) @@ -492,12 +486,22 @@ struct InstallableAttrPath : InstallableValue [&](const ExtendedOutputsSpec::Explicit & e) -> OutputsSpec { return e; }, - }, extendedOutputsSpec.raw())); + }, extendedOutputsSpec.raw()); + + auto [iter, didInsert] = byDrvPath.emplace(*drvPath, newOutputs); + + if (!didInsert) + iter->second = iter->second.union_(newOutputs); } DerivedPathsWithInfo res; - for (auto & [_, info] : byDrvPath) - res.push_back({ .path = { info } }); + for (auto & [drvPath, outputs] : byDrvPath) + res.push_back({ + .path = DerivedPath::Built { + .drvPath = drvPath, + .outputs = outputs, + }, + }); return res; } |