From 147eb4fd15f439b8f14b84df285e26cf5b7108ac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Jun 2015 16:33:50 +0200 Subject: [PATCH] Support requiredSystemFeatures --- src/hydra-queue-runner/hydra-queue-runner.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 6f6d2219..8e21b3ba 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -88,6 +88,7 @@ struct Step Path drvPath; Derivation drv; + std::set requiredSystemFeatures; struct State { @@ -134,7 +135,10 @@ struct Machine bool supportsStep(Step::ptr step) { if (systemTypes.find(step->drv.platform) == systemTypes.end()) return false; - // FIXME: check features + for (auto & f : mandatoryFeatures) + if (step->requiredSystemFeatures.find(f) == step->requiredSystemFeatures.end()) return false; + for (auto & f : step->requiredSystemFeatures) + if (supportedFeatures.find(f) == supportedFeatures.end()) return false; return true; } }; @@ -299,6 +303,8 @@ void State::loadMachines() machine->speedFactor = atof(tokens[4].c_str()); machine->supportedFeatures = tokenizeString(tokens[5], ","); machine->mandatoryFeatures = tokenizeString(tokens[6], ","); + for (auto & f : machine->mandatoryFeatures) + machine->supportedFeatures.insert(f); newMachines.push_back(machine); } @@ -502,7 +508,7 @@ void State::getQueuedBuilds(Connection & conn, std::shared_ptr store, bool badStep = false; for (auto & r : newSteps) { BuildStatus buildStatus = bsSuccess; - BuildStepStatus buildStepStatus; + BuildStepStatus buildStepStatus = bssFailed; bool supported = false; { @@ -613,6 +619,11 @@ Step::ptr State::createStep(std::shared_ptr store, const Path & drvPat auto step = std::make_shared(); step->drvPath = drvPath; step->drv = readDerivation(drvPath); + { + auto i = step->drv.env.find("requiredSystemFeatures"); + if (i != step->drv.env.end()) + step->requiredSystemFeatures = tokenizeString>(i->second); + } newSteps.insert(step); /* Are all outputs valid? */