From 6bcdfc8a1ff859a586d80b78a30c55acb34061a7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 7 Jul 2009 13:20:00 +0000 Subject: [PATCH] --- src/c/Makefile | 2 +- src/c/hydra_eval_jobs.cc | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/c/Makefile b/src/c/Makefile index fd5b509d..d158a123 100644 --- a/src/c/Makefile +++ b/src/c/Makefile @@ -2,4 +2,4 @@ NIX = /home/eelco/Dev/nix/inst ATERM = /home/eelco/Dev/nix/externals/inst-aterm hydra_eval_jobs: hydra_eval_jobs.cc - libtool --mode=link g++ -o hydra_eval_jobs hydra_eval_jobs.cc -I$(NIX)/include/nix -I$(ATERM)/include -L$(NIX)/lib/nix/ -lmain -lexpr -L$(ATERM)/lib -lATerm + libtool --mode=link g++ -o hydra_eval_jobs hydra_eval_jobs.cc -I$(NIX)/include/nix -I$(ATERM)/include -L$(NIX)/lib/nix/ -lmain -lexpr -L$(ATERM)/lib -lATerm -Wall diff --git a/src/c/hydra_eval_jobs.cc b/src/c/hydra_eval_jobs.cc index 79dc3a60..84c6e8a5 100644 --- a/src/c/hydra_eval_jobs.cc +++ b/src/c/hydra_eval_jobs.cc @@ -44,7 +44,7 @@ static void tryJobAlts(EvalState & state, XMLWriter & doc, return; } - Expr name, def; ATerm def2; ATermList values; + Expr name; ATerm def2; ATermList values; if (!matchFormal(ATgetFirst(formals), name, def2)) abort(); if ((values = (ATermList) argsLeft.get(name))) { @@ -77,6 +77,26 @@ static void showArgsUsed(XMLWriter & doc, const ATermMap & argsUsed) } } + +static string queryMetaFieldString(MetaInfo & meta, const string & name) +{ + MetaValue value = meta[name]; + if (value.type != MetaValue::tpString) return ""; + return value.stringValue; +} + + +static int queryMetaFieldInt(MetaInfo & meta, const string & name, int def) +{ + MetaValue value = meta[name]; + if (value.type == MetaValue::tpInt) return value.intValue; + if (value.type == MetaValue::tpString) { + int n; + if (string2Int(value.stringValue, n)) return n; + } + return def; +} + static void findJobsWrapped(EvalState & state, XMLWriter & doc, const ATermMap & argsUsed, const ATermMap & argsLeft, @@ -86,7 +106,7 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, e = evalExpr(state, e); - ATermList as, es, formals; + ATermList as, formals; ATermBool ellipsis; ATerm pat, body, pos; string s; @@ -107,12 +127,14 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc, xmlAttrs["system"] = drv.system; xmlAttrs["drvPath"] = drvPath = drv.queryDrvPath(state); xmlAttrs["outPath"] = drv.queryOutPath(state); - xmlAttrs["description"] = drv.queryMetaInfo(state, "description"); - xmlAttrs["longDescription"] = drv.queryMetaInfo(state, "longDescription"); - xmlAttrs["license"] = drv.queryMetaInfo(state, "license"); - xmlAttrs["homepage"] = drv.queryMetaInfo(state, "homepage"); - xmlAttrs["schedulingPriority"] = drv.queryMetaInfo(state, "schedulingPriority"); - + MetaInfo meta = drv.queryMetaInfo(state); + xmlAttrs["description"] = queryMetaFieldString(meta, "description"); + xmlAttrs["longDescription"] = queryMetaFieldString(meta, "longDescription"); + xmlAttrs["license"] = queryMetaFieldString(meta, "license"); + xmlAttrs["homepage"] = queryMetaFieldString(meta, "homepage"); + int prio = queryMetaFieldInt(meta, "schedulingPriority", 100); + xmlAttrs["schedulingPriority"] = int2String(prio); + /* Register the derivation as a GC root. !!! This registers roots for jobs that we may have already done. */