about summary refs log tree commit diff
path: root/src/libexpr/get-drvs.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-02-08T13·21+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-02-08T13·21+0000
commit39f50db731bb1924d3c18b153dfe4258208b8812 (patch)
treeb0a4c793d826353580de19e0151cfa6a8096ca3a /src/libexpr/get-drvs.hh
parent4db4b61380d94c2626b7c4ee2e613b6b6223f803 (diff)
* Refactoring: move derivation evaluation to libexpr.
Diffstat (limited to 'src/libexpr/get-drvs.hh')
-rw-r--r--src/libexpr/get-drvs.hh64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/libexpr/get-drvs.hh b/src/libexpr/get-drvs.hh
new file mode 100644
index 000000000000..bfcff8cca333
--- /dev/null
+++ b/src/libexpr/get-drvs.hh
@@ -0,0 +1,64 @@
+#ifndef __GET_DRVS_H
+#define __GET_DRVS_H
+
+#include <string>
+#include <map>
+
+#include "eval.hh"
+
+
+struct DrvInfo
+{
+private:
+    string drvPath;
+    string outPath;
+    
+public:
+    string name;
+    string system;
+
+    ATermMap attrs;
+
+    string queryDrvPath(EvalState & state) const
+    {
+        if (drvPath == "") {
+            Expr a = attrs.get("drvPath");
+            (string &) drvPath = a ? evalPath(state, a) : "";
+        }
+        return drvPath;
+    }
+    
+    string queryOutPath(EvalState & state) const
+    {
+        if (outPath == "") {
+            Expr a = attrs.get("outPath");
+            if (!a) throw Error("output path missing");
+            (string &) outPath = evalPath(state, a);
+        }
+        return outPath;
+    }
+
+    void setDrvPath(const string & s)
+    {
+        drvPath = s;
+    }
+    
+    void setOutPath(const string & s)
+    {
+        outPath = s;
+    }
+};
+
+
+typedef list<DrvInfo> DrvInfos;
+
+
+/* Evaluate expression `e'.  If it evaluates to a derivation, store
+   information about the derivation in `drv' and return true.
+   Otherwise, return false. */
+bool getDerivation(EvalState & state, Expr e, DrvInfo & drv);
+
+void getDerivations(EvalState & state, Expr e, DrvInfos & drvs);
+
+
+#endif /* !__GET_DRVS_H */