2003-07-14 12:23:11 +02:00
|
|
|
#ifndef __FSTATE_H
|
|
|
|
#define __FSTATE_H
|
2003-06-16 15:33:38 +02:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <aterm2.h>
|
|
|
|
}
|
|
|
|
|
2003-07-15 18:28:54 +02:00
|
|
|
#include "store.hh"
|
2003-06-16 15:33:38 +02:00
|
|
|
|
|
|
|
|
2003-07-20 21:29:38 +02:00
|
|
|
/* Abstract syntax of fstate-expressions. */
|
2003-06-27 11:55:31 +02:00
|
|
|
|
2003-07-15 18:28:54 +02:00
|
|
|
typedef list<FSId> FSIds;
|
|
|
|
|
|
|
|
struct SliceElem
|
|
|
|
{
|
|
|
|
string path;
|
|
|
|
FSId id;
|
|
|
|
FSIds refs;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef list<SliceElem> SliceElems;
|
|
|
|
|
|
|
|
struct Slice
|
|
|
|
{
|
|
|
|
FSIds roots;
|
|
|
|
SliceElems elems;
|
|
|
|
};
|
2003-06-16 15:33:38 +02:00
|
|
|
|
2003-07-20 21:29:38 +02:00
|
|
|
typedef pair<string, FSId> DeriveOutput;
|
|
|
|
typedef pair<string, string> StringPair;
|
|
|
|
typedef list<DeriveOutput> DeriveOutputs;
|
|
|
|
typedef list<StringPair> StringPairs;
|
|
|
|
|
|
|
|
struct Derive
|
|
|
|
{
|
|
|
|
DeriveOutputs outputs;
|
|
|
|
FSIds inputs;
|
|
|
|
string builder;
|
|
|
|
string platform;
|
|
|
|
StringPairs env;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FState
|
|
|
|
{
|
|
|
|
enum { fsSlice, fsDerive } type;
|
|
|
|
Slice slice;
|
|
|
|
Derive derive;
|
|
|
|
};
|
|
|
|
|
2003-07-15 18:28:54 +02:00
|
|
|
|
2003-06-17 15:37:44 +02:00
|
|
|
/* Return a canonical textual representation of an expression. */
|
2003-06-27 15:55:12 +02:00
|
|
|
string printTerm(ATerm t);
|
2003-06-18 14:36:12 +02:00
|
|
|
|
2003-07-06 16:20:47 +02:00
|
|
|
/* Throw an exception with an error message containing the given
|
|
|
|
aterm. */
|
|
|
|
Error badTerm(const format & f, ATerm t);
|
|
|
|
|
2003-06-27 15:55:12 +02:00
|
|
|
/* Hash an aterm. */
|
|
|
|
Hash hashTerm(ATerm t);
|
2003-06-16 15:33:38 +02:00
|
|
|
|
2003-07-15 18:28:54 +02:00
|
|
|
/* Read an aterm from disk, given its id. */
|
2003-07-20 21:29:38 +02:00
|
|
|
ATerm termFromId(const FSId & id);
|
2003-07-08 15:22:08 +02:00
|
|
|
|
2003-07-06 16:20:47 +02:00
|
|
|
/* Write an aterm to the Nix store directory, and return its hash. */
|
2003-07-20 21:29:38 +02:00
|
|
|
FSId writeTerm(ATerm t, const string & suffix);
|
2003-07-10 20:48:11 +02:00
|
|
|
|
2003-07-20 21:29:38 +02:00
|
|
|
/* Parse an fstate-expression. */
|
|
|
|
FState parseFState(ATerm t);
|
2003-07-16 13:05:59 +02:00
|
|
|
|
2003-07-20 21:29:38 +02:00
|
|
|
/* Parse an fstate-expression. */
|
|
|
|
ATerm unparseFState(const FState & fs);
|
2003-07-16 00:28:27 +02:00
|
|
|
|
2003-06-16 15:33:38 +02:00
|
|
|
|
2003-07-14 12:23:11 +02:00
|
|
|
#endif /* !__FSTATE_H */
|