hydra-eval-jobs: Fix building against the latest unstable Nix

This commit is contained in:
Eelco Dolstra 2014-01-12 17:37:56 +01:00
parent 1d392f64c6
commit 62809f484f

View file

@ -89,39 +89,27 @@ static void showArgsUsed(XMLWriter & doc, const ArgsUsed & argsUsed)
} }
static string queryMetaFieldString(MetaInfo & meta, const string & name) static string queryMetaStrings(EvalState & state, DrvInfo & drv, const string & name)
{ {
MetaValue value = meta[name]; Value * v = drv.queryMeta(name);
if (value.type != MetaValue::tpString) return ""; if (v) {
return value.stringValue; state.forceValue(*v);
} if (v->type == tString)
return v->string.s;
else if (v->type == tList) {
static int queryMetaFieldInt(MetaInfo & meta, const string & name, int def) string res = "";
{ for (unsigned int n = 0; n < v->list.length; ++n) {
MetaValue value = meta[name]; Value v2(*v->list.elems[n]);
if (value.type == MetaValue::tpInt) return value.intValue; state.forceValue(v2);
if (value.type == MetaValue::tpString) { if (v2.type == tString) {
int n;
if (string2Int(value.stringValue, n)) return n;
}
return def;
}
static string queryMetaField(MetaInfo & meta, const string & name)
{
string res;
MetaValue value = meta[name];
if (value.type == MetaValue::tpString)
res = value.stringValue;
else if (value.type == MetaValue::tpStrings) {
foreach (Strings::const_iterator, i, value.stringValues) {
if (res.size() != 0) res += ", "; if (res.size() != 0) res += ", ";
res += *i; res += v2.string.s;
} }
} }
return res; return res;
}
}
return "";
} }
@ -137,33 +125,29 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
if (v.type == tAttrs) { if (v.type == tAttrs) {
DrvInfo drv; DrvInfo drv(state);
if (getDerivation(state, v, drv, false)) { if (getDerivation(state, v, drv, false)) {
XMLAttrs xmlAttrs; XMLAttrs xmlAttrs;
Path drvPath; Path drvPath;
DrvInfo::Outputs outputs = drv.queryOutputs(state); DrvInfo::Outputs outputs = drv.queryOutputs();
xmlAttrs["jobName"] = attrPath; xmlAttrs["jobName"] = attrPath;
xmlAttrs["nixName"] = drv.name; xmlAttrs["nixName"] = drv.name;
xmlAttrs["system"] = drv.system; xmlAttrs["system"] = drv.system;
xmlAttrs["drvPath"] = drvPath = drv.queryDrvPath(state); xmlAttrs["drvPath"] = drvPath = drv.queryDrvPath();
MetaInfo meta = drv.queryMetaInfo(state); xmlAttrs["description"] = drv.queryMetaString("description");
xmlAttrs["description"] = queryMetaFieldString(meta, "description"); xmlAttrs["longDescription"] = drv.queryMetaString("longDescription");
xmlAttrs["longDescription"] = queryMetaFieldString(meta, "longDescription"); xmlAttrs["license"] = queryMetaStrings(state, drv, "license");
xmlAttrs["license"] = queryMetaField(meta, "license"); xmlAttrs["homepage"] = drv.queryMetaString("homepage");
xmlAttrs["homepage"] = queryMetaFieldString(meta, "homepage"); xmlAttrs["maintainers"] = queryMetaStrings(state, drv, "maintainers");
xmlAttrs["maintainers"] = queryMetaField(meta, "maintainers");
int prio = queryMetaFieldInt(meta, "schedulingPriority", 100); xmlAttrs["schedulingPriority"] = int2String(drv.queryMetaInt("schedulingPriority", 100));
xmlAttrs["schedulingPriority"] = int2String(prio);
int timeout = queryMetaFieldInt(meta, "timeout", 36000); xmlAttrs["timeout"] = int2String(drv.queryMetaInt("timeout", 36000));
xmlAttrs["timeout"] = int2String(timeout);
int maxsilent = queryMetaFieldInt(meta, "maxSilent", 3600); xmlAttrs["maxSilent"] = int2String(drv.queryMetaInt("maxSilent", 3600));
xmlAttrs["maxSilent"] = int2String(maxsilent);
/* 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"));