2003-07-14 06:23:11 -04:00
|
|
|
#ifndef __FSTATE_H
|
|
|
|
#define __FSTATE_H
|
2003-06-16 09:33:38 -04:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <aterm2.h>
|
|
|
|
}
|
|
|
|
|
2003-07-15 12:28:54 -04:00
|
|
|
#include "store.hh"
|
2003-06-16 09:33:38 -04:00
|
|
|
|
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
/* Abstract syntax of Nix expressions. */
|
2003-06-27 05:55:31 -04:00
|
|
|
|
2003-07-15 12:28:54 -04:00
|
|
|
typedef list<FSId> FSIds;
|
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
struct ClosureElem
|
2003-07-15 12:28:54 -04:00
|
|
|
{
|
|
|
|
FSId id;
|
2003-08-20 10:11:40 -04:00
|
|
|
StringSet refs;
|
2003-07-15 12:28:54 -04:00
|
|
|
};
|
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
typedef map<string, ClosureElem> ClosureElems;
|
2003-07-15 12:28:54 -04:00
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
struct Closure
|
2003-07-15 12:28:54 -04:00
|
|
|
{
|
2003-08-20 10:11:40 -04:00
|
|
|
StringSet roots;
|
2003-10-07 08:27:49 -04:00
|
|
|
ClosureElems elems;
|
2003-07-15 12:28:54 -04:00
|
|
|
};
|
2003-06-16 09:33:38 -04:00
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
typedef map<string, FSId> DerivationOutputs;
|
2003-08-20 10:11:40 -04:00
|
|
|
typedef map<string, string> StringPairs;
|
2003-07-20 15:29:38 -04:00
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
struct Derivation
|
2003-07-20 15:29:38 -04:00
|
|
|
{
|
2003-10-07 08:27:49 -04:00
|
|
|
DerivationOutputs outputs;
|
2003-08-20 10:11:40 -04:00
|
|
|
FSIdSet inputs;
|
2003-07-20 15:29:38 -04:00
|
|
|
string platform;
|
2003-08-15 08:32:37 -04:00
|
|
|
string builder;
|
|
|
|
Strings args;
|
2003-07-20 15:29:38 -04:00
|
|
|
StringPairs env;
|
|
|
|
};
|
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
struct NixExpr
|
2003-07-20 15:29:38 -04:00
|
|
|
{
|
2003-10-07 08:27:49 -04:00
|
|
|
enum { neClosure, neDerivation } type;
|
|
|
|
Closure closure;
|
|
|
|
Derivation derivation;
|
2003-07-20 15:29:38 -04:00
|
|
|
};
|
|
|
|
|
2003-07-15 12:28:54 -04:00
|
|
|
|
2003-06-17 09:37:44 -04:00
|
|
|
/* Return a canonical textual representation of an expression. */
|
2003-06-27 09:55:12 -04:00
|
|
|
string printTerm(ATerm t);
|
2003-06-18 08:36:12 -04:00
|
|
|
|
2003-07-06 10:20:47 -04:00
|
|
|
/* Throw an exception with an error message containing the given
|
|
|
|
aterm. */
|
|
|
|
Error badTerm(const format & f, ATerm t);
|
|
|
|
|
2003-06-27 09:55:12 -04:00
|
|
|
/* Hash an aterm. */
|
|
|
|
Hash hashTerm(ATerm t);
|
2003-06-16 09:33:38 -04:00
|
|
|
|
2003-07-15 12:28:54 -04:00
|
|
|
/* Read an aterm from disk, given its id. */
|
2003-07-20 15:29:38 -04:00
|
|
|
ATerm termFromId(const FSId & id);
|
2003-07-08 09:22:08 -04:00
|
|
|
|
2003-07-06 10:20:47 -04:00
|
|
|
/* Write an aterm to the Nix store directory, and return its hash. */
|
2003-07-21 16:07:12 -04:00
|
|
|
FSId writeTerm(ATerm t, const string & suffix, FSId id = FSId());
|
2003-07-10 14:48:11 -04:00
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
/* Parse a Nix expression. */
|
|
|
|
NixExpr parseNixExpr(ATerm t);
|
2003-07-16 07:05:59 -04:00
|
|
|
|
2003-10-07 08:27:49 -04:00
|
|
|
/* Parse a Nix expression. */
|
|
|
|
ATerm unparseNixExpr(const NixExpr & ne);
|
2003-07-15 18:28:27 -04:00
|
|
|
|
2003-06-16 09:33:38 -04:00
|
|
|
|
2003-07-14 06:23:11 -04:00
|
|
|
#endif /* !__FSTATE_H */
|