From 4b31b23c04c8565b3c3cfafc16a5ce445f158e18 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 8 Oct 2015 11:56:30 +0200 Subject: [PATCH] Handle attrsets in meta.license (i.e. lib.licenses) --- src/hydra-eval-jobs/hydra-eval-jobs.cc | 38 ++++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 7fadef71..8f57fd8c 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -71,25 +71,27 @@ static void tryJobAlts(EvalState & state, JSONObject & top, static string queryMetaStrings(EvalState & state, DrvInfo & drv, const string & name) { - Value * v = drv.queryMeta(name); - if (v) { - state.forceValue(*v); - if (v->type == tString) - return v->string.s; - else if (v->isList()) { - string res = ""; - for (unsigned int n = 0; n < v->listSize(); ++n) { - Value v2(*v->listElems()[n]); - state.forceValue(v2); - if (v2.type == tString) { - if (res.size() != 0) res += ", "; - res += v2.string.s; - } - } - return res; + Strings res; + std::function rec; + + rec = [&](Value & v) { + state.forceValue(v); + if (v.type == tString) + res.push_back(v.string.s); + else if (v.isList()) + for (unsigned int n = 0; n < v.listSize(); ++n) + rec(*v.listElems()[n]); + else if (v.type == tAttrs) { + auto a = v.attrs->find(state.symbols.create("shortName")); + if (a != v.attrs->end()) + res.push_back(state.forceString(*a->value)); } - } - return ""; + }; + + Value * v = drv.queryMeta(name); + if (v) rec(*v); + + return concatStringsSep(", ", res); }