Add a dependencies field to DrvOutputInfo

Currently never used, nor set but will be useful shortly
This commit is contained in:
regnat 2020-11-10 14:49:25 +01:00
parent 4077d55775
commit 7ce0441d80
2 changed files with 12 additions and 0 deletions

View file

@ -22,10 +22,14 @@ std::string DrvOutput::to_string() const {
} }
nlohmann::json Realisation::toJSON() const { nlohmann::json Realisation::toJSON() const {
nlohmann::json jsonDrvOutputDeps;
for (auto & dep : drvOutputDeps)
jsonDrvOutputDeps.push_back(dep.to_string());
return nlohmann::json{ return nlohmann::json{
{"id", id.to_string()}, {"id", id.to_string()},
{"outPath", outPath.to_string()}, {"outPath", outPath.to_string()},
{"signatures", signatures}, {"signatures", signatures},
{"drvOutputDeps", jsonDrvOutputDeps},
}; };
} }
@ -51,10 +55,16 @@ Realisation Realisation::fromJSON(
if (auto signaturesIterator = json.find("signatures"); signaturesIterator != json.end()) if (auto signaturesIterator = json.find("signatures"); signaturesIterator != json.end())
signatures.insert(signaturesIterator->begin(), signaturesIterator->end()); signatures.insert(signaturesIterator->begin(), signaturesIterator->end());
std::set <DrvOutput> drvOutputDeps;
if (auto jsonDependencies = json.find("drvOutputDeps"); jsonDependencies != json.end())
for (auto & jsonDep : *jsonDependencies)
drvOutputDeps.insert(DrvOutput::parse(jsonDep.get<std::string>()));
return Realisation{ return Realisation{
.id = DrvOutput::parse(getField("id")), .id = DrvOutput::parse(getField("id")),
.outPath = StorePath(getField("outPath")), .outPath = StorePath(getField("outPath")),
.signatures = signatures, .signatures = signatures,
.drvOutputDeps = drvOutputDeps,
}; };
} }

View file

@ -28,6 +28,8 @@ struct Realisation {
StringSet signatures; StringSet signatures;
std::set<DrvOutput> drvOutputDeps;
nlohmann::json toJSON() const; nlohmann::json toJSON() const;
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence); static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);