mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 09:49:36 +01:00
Implement realisation operations on dummy store
This commit is contained in:
parent
e06968ec25
commit
5592bb717b
5 changed files with 62 additions and 5 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "nix/util/callback.hh"
|
||||
#include "nix/util/memory-source-accessor.hh"
|
||||
#include "nix/store/dummy-store-impl.hh"
|
||||
#include "nix/store/realisation.hh"
|
||||
|
||||
#include <boost/unordered/concurrent_flat_map.hpp>
|
||||
|
||||
|
|
@ -251,7 +252,10 @@ struct DummyStoreImpl : DummyStore
|
|||
|
||||
void registerDrvOutput(const Realisation & output) override
|
||||
{
|
||||
unsupported("registerDrvOutput");
|
||||
auto ref = make_ref<UnkeyedRealisation>(output);
|
||||
buildTrace.insert_or_visit({output.id.drvHash, {{output.id.outputName, ref}}}, [&](auto & kv) {
|
||||
kv.second.insert_or_assign(output.id.outputName, make_ref<UnkeyedRealisation>(output));
|
||||
});
|
||||
}
|
||||
|
||||
void narFromPath(const StorePath & path, Sink & sink) override
|
||||
|
|
@ -267,9 +271,18 @@ struct DummyStoreImpl : DummyStore
|
|||
}
|
||||
|
||||
void queryRealisationUncached(
|
||||
const DrvOutput &, Callback<std::shared_ptr<const UnkeyedRealisation>> callback) noexcept override
|
||||
const DrvOutput & drvOutput, Callback<std::shared_ptr<const UnkeyedRealisation>> callback) noexcept override
|
||||
{
|
||||
callback(nullptr);
|
||||
bool visited = false;
|
||||
buildTrace.cvisit(drvOutput.drvHash, [&](const auto & kv) {
|
||||
if (auto it = kv.second.find(drvOutput.outputName); it != kv.second.end()) {
|
||||
visited = true;
|
||||
callback(it->second.get_ptr());
|
||||
}
|
||||
});
|
||||
|
||||
if (!visited)
|
||||
callback(nullptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceAccessor> getFSAccessor(const StorePath & path, bool requireValidPath) override
|
||||
|
|
|
|||
|
|
@ -30,6 +30,18 @@ struct DummyStore : virtual Store
|
|||
*/
|
||||
boost::concurrent_flat_map<StorePath, PathInfoAndContents> contents;
|
||||
|
||||
/**
|
||||
* The build trace maps the pair of a content-addressing (fixed or
|
||||
* floating) derivations an one of its output to a
|
||||
* (content-addressed) store object.
|
||||
*
|
||||
* It is [curried](https://en.wikipedia.org/wiki/Currying), so we
|
||||
* instead having a single output with a `DrvOutput` key, we have an
|
||||
* outer map for the derivation, and inner maps for the outputs of a
|
||||
* given derivation.
|
||||
*/
|
||||
boost::concurrent_flat_map<Hash, std::map<std::string, ref<UnkeyedRealisation>>> buildTrace;
|
||||
|
||||
DummyStore(ref<const Config> config)
|
||||
: Store{*config}
|
||||
, config(config)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "nix/store/store-api.hh"
|
||||
|
||||
#include <boost/unordered/concurrent_flat_map.hpp>
|
||||
|
||||
namespace nix {
|
||||
|
||||
struct DummyStore;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue