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