This commit is contained in:
parent
c3cc2262b7
commit
c724439b20
|
@ -5,7 +5,9 @@
|
|||
#include "store-api.hh"
|
||||
#include "eval.hh"
|
||||
#include "parser.hh"
|
||||
#include "expr-to-xml.hh"
|
||||
#include "nixexpr-ast.hh"
|
||||
#include "util.hh"
|
||||
#include "xml-writer.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
|
@ -16,6 +18,63 @@ void printHelp()
|
|||
}
|
||||
|
||||
|
||||
Expr evalAttr(EvalState & state, Expr e)
|
||||
{
|
||||
return e ? evalExpr(state, e) : e;
|
||||
}
|
||||
|
||||
|
||||
static void findJobs(EvalState & state, XMLWriter & doc,
|
||||
Expr e, const string & attrPath)
|
||||
{
|
||||
std::cerr << "at `" << attrPath << "'\n";
|
||||
|
||||
e = evalExpr(state, e);
|
||||
|
||||
ATermList as, es;
|
||||
ATerm pat, body, pos;
|
||||
string s;
|
||||
PathSet context;
|
||||
|
||||
if (matchAttrs(e, as)) {
|
||||
ATermMap attrs;
|
||||
queryAllAttrs(e, attrs);
|
||||
|
||||
Expr a = evalAttr(state, attrs.get(toATerm("type")));
|
||||
if (a && matchStr(a, s, context) && s == "derivation") {
|
||||
std::cerr << "derivation\n";
|
||||
|
||||
XMLAttrs xmlAttrs;
|
||||
Path outPath, drvPath;
|
||||
|
||||
xmlAttrs["name"] = attrPath;
|
||||
|
||||
a = evalAttr(state, attrs.get(toATerm("drvPath")));
|
||||
if (matchStr(a, drvPath, context)) xmlAttrs["drvPath"] = drvPath;
|
||||
|
||||
a = evalAttr(state, attrs.get(toATerm("outPath")));
|
||||
if (matchStr(a, outPath, context)) xmlAttrs["outPath"] = outPath;
|
||||
|
||||
XMLOpenElement _(doc, "job", xmlAttrs);
|
||||
}
|
||||
|
||||
else {
|
||||
std::cerr << "attrset\n";
|
||||
foreach (ATermMap::const_iterator, i, attrs)
|
||||
findJobs(state, doc, i->value,
|
||||
(attrPath.empty() ? "" : attrPath + ".") + aterm2String(i->key));
|
||||
}
|
||||
}
|
||||
|
||||
else if (matchFunction(e, pat, body, pos)) {
|
||||
std::cerr << "function\n";
|
||||
}
|
||||
|
||||
else
|
||||
std::cerr << showValue(e) << "\n";
|
||||
}
|
||||
|
||||
|
||||
void run(Strings args)
|
||||
{
|
||||
EvalState state;
|
||||
|
@ -31,10 +90,11 @@ void run(Strings args)
|
|||
|
||||
store = openStore();
|
||||
|
||||
Expr e = evalExpr(state, parseExprFromFile(state, releaseExpr));
|
||||
Expr e = parseExprFromFile(state, releaseExpr);
|
||||
|
||||
PathSet context;
|
||||
printTermAsXML(e, std::cout, context);
|
||||
XMLWriter doc(true, std::cout);
|
||||
XMLOpenElement root(doc, "jobs");
|
||||
findJobs(state, doc, e, "");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue