From c3cc2262b7244f476223e2aacb196c124cebe6b7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Mar 2009 14:59:43 +0000 Subject: [PATCH] * Start of a helper tool to evaluate job expressions efficiently. --- src/c/Makefile | 5 +++++ src/c/eval-jobs.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/c/Makefile create mode 100644 src/c/eval-jobs.cc diff --git a/src/c/Makefile b/src/c/Makefile new file mode 100644 index 00000000..dfb4e512 --- /dev/null +++ b/src/c/Makefile @@ -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 diff --git a/src/c/eval-jobs.cc b/src/c/eval-jobs.cc new file mode 100644 index 00000000..78298b07 --- /dev/null +++ b/src/c/eval-jobs.cc @@ -0,0 +1,41 @@ +#include +#include + +#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 \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";