forked from lix-project/lix
Move writeStructuredAttrsShell
out of ParsedDerivation
class
This commit is contained in:
parent
27ce722638
commit
6f206549ba
|
@ -1088,7 +1088,7 @@ void LocalDerivationGoal::writeStructuredAttrs()
|
||||||
{
|
{
|
||||||
if (auto structAttrsJson = parsedDrv->prepareStructuredAttrs(inputRewrites, worker.store, inputPaths)) {
|
if (auto structAttrsJson = parsedDrv->prepareStructuredAttrs(inputRewrites, worker.store, inputPaths)) {
|
||||||
auto json = structAttrsJson.value();
|
auto json = structAttrsJson.value();
|
||||||
auto jsonSh = parsedDrv->writeStructuredAttrsShell(json);
|
auto jsonSh = writeStructuredAttrsShell(json);
|
||||||
|
|
||||||
writeFile(tmpDir + "/.attrs.sh", rewriteStrings(jsonSh, inputRewrites));
|
writeFile(tmpDir + "/.attrs.sh", rewriteStrings(jsonSh, inputRewrites));
|
||||||
chownToBuilder(tmpDir + "/.attrs.sh");
|
chownToBuilder(tmpDir + "/.attrs.sh");
|
||||||
|
|
|
@ -165,13 +165,13 @@ std::optional<nlohmann::json> ParsedDerivation::prepareStructuredAttrs(std::opti
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ParsedDerivation::writeStructuredAttrsShell(nlohmann::json & json)
|
/* As a convenience to bash scripts, write a shell file that
|
||||||
|
maps all attributes that are representable in bash -
|
||||||
|
namely, strings, integers, nulls, Booleans, and arrays and
|
||||||
|
objects consisting entirely of those values. (So nested
|
||||||
|
arrays or objects are not supported.) */
|
||||||
|
std::string writeStructuredAttrsShell(nlohmann::json & json)
|
||||||
{
|
{
|
||||||
/* As a convenience to bash scripts, write a shell file that
|
|
||||||
maps all attributes that are representable in bash -
|
|
||||||
namely, strings, integers, nulls, Booleans, and arrays and
|
|
||||||
objects consisting entirely of those values. (So nested
|
|
||||||
arrays or objects are not supported.) */
|
|
||||||
|
|
||||||
auto handleSimpleType = [](const nlohmann::json & value) -> std::optional<std::string> {
|
auto handleSimpleType = [](const nlohmann::json & value) -> std::optional<std::string> {
|
||||||
if (value.is_string())
|
if (value.is_string())
|
||||||
|
|
|
@ -38,7 +38,8 @@ public:
|
||||||
bool substitutesAllowed() const;
|
bool substitutesAllowed() const;
|
||||||
|
|
||||||
std::optional<nlohmann::json> prepareStructuredAttrs(std::optional<StringMap> inputRewrites, Store & store, const StorePathSet & inputPaths);
|
std::optional<nlohmann::json> prepareStructuredAttrs(std::optional<StringMap> inputRewrites, Store & store, const StorePathSet & inputPaths);
|
||||||
std::string writeStructuredAttrsShell(nlohmann::json & json);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string writeStructuredAttrsShell(nlohmann::json & json);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,6 +695,9 @@ public:
|
||||||
|
|
||||||
const Stats & getStats();
|
const Stats & getStats();
|
||||||
|
|
||||||
|
/* Computes the full closure of of a set of store-paths for e.g.
|
||||||
|
derivations that need this information for `exportReferencesGraph`.
|
||||||
|
*/
|
||||||
StorePathSet exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths);
|
StorePathSet exportReferences(const StorePathSet & storePaths, const StorePathSet & inputPaths);
|
||||||
|
|
||||||
/* Return the build log of the specified store path, if available,
|
/* Return the build log of the specified store path, if available,
|
||||||
|
|
|
@ -446,7 +446,7 @@ static void main_nix_build(int argc, char * * argv)
|
||||||
|
|
||||||
if (auto structAttrs = parsedDrv.prepareStructuredAttrs(std::nullopt, *store, inputs)) {
|
if (auto structAttrs = parsedDrv.prepareStructuredAttrs(std::nullopt, *store, inputs)) {
|
||||||
auto json = structAttrs.value();
|
auto json = structAttrs.value();
|
||||||
structuredAttrsRC = parsedDrv.writeStructuredAttrsShell(json);
|
structuredAttrsRC = writeStructuredAttrsShell(json);
|
||||||
|
|
||||||
auto attrsJSON = (Path) tmpDir + "/.attrs.json";
|
auto attrsJSON = (Path) tmpDir + "/.attrs.json";
|
||||||
writeFile(attrsJSON, json.dump());
|
writeFile(attrsJSON, json.dump());
|
||||||
|
|
Loading…
Reference in a new issue