* Start of a helper tool to evaluate job expressions efficiently.

This commit is contained in:
Eelco Dolstra 2009-03-05 14:59:43 +00:00
parent 8da2a47568
commit c3cc2262b7
2 changed files with 46 additions and 0 deletions

5
src/c/Makefile Normal file
View file

@ -0,0 +1,5 @@
NIX = /home/eelco/Dev/nix/inst
ATERM = /home/eelco/Dev/nix/externals/inst-aterm
eval-jobs: eval-jobs.cc
libtool --mode=link g++ -o eval-jobs eval-jobs.cc -I$(NIX)/include/nix -I$(ATERM)/include -L$(NIX)/lib/nix/ -lmain -lexpr -L$(ATERM)/lib -lATerm

41
src/c/eval-jobs.cc Normal file
View file

@ -0,0 +1,41 @@
#include <map>
#include <iostream>
#include "shared.hh"
#include "store-api.hh"
#include "eval.hh"
#include "parser.hh"
#include "expr-to-xml.hh"
using namespace nix;
void printHelp()
{
std::cout << "Syntax: eval-jobs <expr>\n";
}
void run(Strings args)
{
EvalState state;
Path releaseExpr;
for (Strings::iterator i = args.begin(); i != args.end(); ) {
string arg = *i++;
if (arg[0] == '-')
throw UsageError(format("unknown flag `%1%'") % arg);
else
releaseExpr = arg;
}
store = openStore();
Expr e = evalExpr(state, parseExprFromFile(state, releaseExpr));
PathSet context;
printTermAsXML(e, std::cout, context);
}
string programId = "eval-jobs";