hydra-eval-jobs: Fix build

This commit is contained in:
Eelco Dolstra 2016-10-06 15:05:05 +02:00
parent 934829a1a9
commit 706e06e8d7

View file

@ -8,7 +8,7 @@
#include "eval.hh" #include "eval.hh"
#include "eval-inline.hh" #include "eval-inline.hh"
#include "util.hh" #include "util.hh"
#include "value-to-json.hh" #include "json.hh"
#include "get-drvs.hh" #include "get-drvs.hh"
#include "common-opts.hh" #include "common-opts.hh"
#include "globals.hh" #include "globals.hh"
@ -117,8 +117,7 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
throw EvalError("derivation must have a system attribute"); throw EvalError("derivation must have a system attribute");
{ {
top.attr(attrPath); auto res = top.object(attrPath);
JSONObject res(top.str);
res.attr("nixName", drv.name); res.attr("nixName", drv.name);
res.attr("system", drv.system); res.attr("system", drv.system);
res.attr("drvPath", drvPath = drv.queryDrvPath()); res.attr("drvPath", drvPath = drv.queryDrvPath());
@ -133,7 +132,7 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
/* If this is an aggregate, then get its constituents. */ /* If this is an aggregate, then get its constituents. */
Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate")); Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate"));
if (a != v.attrs->end() && state.forceBool(*a->value)) { if (a != v.attrs->end() && state.forceBool(*a->value, *a->pos)) {
Bindings::iterator a = v.attrs->find(state.symbols.create("constituents")); Bindings::iterator a = v.attrs->find(state.symbols.create("constituents"));
if (a == v.attrs->end()) if (a == v.attrs->end())
throw EvalError("derivation must have a constituents attribute"); throw EvalError("derivation must have a constituents attribute");
@ -151,18 +150,17 @@ static void findJobsWrapped(EvalState & state, JSONObject & top,
/* Register the derivation as a GC root. !!! This /* Register the derivation as a GC root. !!! This
registers roots for jobs that we may have already registers roots for jobs that we may have already
done. */ done. */
if (gcRootsDir != "") { auto localStore = state.store.dynamic_pointer_cast<LocalFSStore>();
if (gcRootsDir != "" && localStore) {
Path root = gcRootsDir + "/" + baseNameOf(drvPath); Path root = gcRootsDir + "/" + baseNameOf(drvPath);
if (!pathExists(root)) state.store->addPermRoot(drvPath, root, false); if (!pathExists(root)) localStore->addPermRoot(drvPath, root, false);
} }
res.attr("outputs"); auto res2 = res.object("outputs");
JSONObject res2(res.str);
for (auto & j : outputs) for (auto & j : outputs)
res2.attr(j.first, j.second); res2.attr(j.first, j.second);
} }
top.str << std::endl;
} }
else { else {
@ -198,11 +196,9 @@ static void findJobs(EvalState & state, JSONObject & top,
findJobsWrapped(state, top, argsLeft, v, attrPath); findJobsWrapped(state, top, argsLeft, v, attrPath);
} catch (EvalError & e) { } catch (EvalError & e) {
{ {
top.attr(attrPath); auto res = top.object(attrPath);
JSONObject res(top.str);
res.attr("error", e.msg()); res.attr("error", e.msg());
} }
top.str << std::endl;
} }
} }
@ -283,7 +279,7 @@ int main(int argc, char * * argv)
Value v; Value v;
state.evalFile(releaseExpr, v); state.evalFile(releaseExpr, v);
JSONObject json(std::cout); JSONObject json(std::cout, true);
findJobs(state, json, autoArgs, v, ""); findJobs(state, json, autoArgs, v, "");
state.printStats(); state.printStats();