2012-07-18 14:59:03 -04:00
|
|
|
#pragma once
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2010-10-04 13:55:38 -04:00
|
|
|
#include "eval.hh"
|
|
|
|
|
2006-02-08 08:21:16 -05:00
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
2006-09-04 17:06:23 -04:00
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
|
2006-02-08 08:21:16 -05:00
|
|
|
struct DrvInfo
|
|
|
|
{
|
2012-11-28 07:49:44 -05:00
|
|
|
public:
|
|
|
|
typedef std::map<string, Path> Outputs;
|
|
|
|
|
2006-02-08 08:21:16 -05:00
|
|
|
private:
|
2013-11-19 08:09:03 -05:00
|
|
|
EvalState * state;
|
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
mutable string name;
|
|
|
|
mutable string system;
|
|
|
|
mutable string drvPath;
|
|
|
|
mutable string outPath;
|
|
|
|
mutable string outputName;
|
2012-11-28 07:49:44 -05:00
|
|
|
Outputs outputs;
|
2010-04-19 08:10:04 -04:00
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
bool failed = false; // set if we get an AssertionError
|
2012-11-28 07:49:44 -05:00
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
Bindings * attrs = nullptr, * meta = nullptr;
|
2013-11-19 08:09:03 -05:00
|
|
|
|
|
|
|
Bindings * getMeta();
|
|
|
|
|
2013-11-19 08:29:39 -05:00
|
|
|
bool checkMeta(Value & v);
|
|
|
|
|
2006-02-08 08:21:16 -05:00
|
|
|
public:
|
2006-07-25 12:40:38 -04:00
|
|
|
string attrPath; /* path towards the derivation */
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
DrvInfo(EvalState & state) : state(&state) { };
|
|
|
|
DrvInfo(EvalState & state, const string & attrPath, Bindings * attrs);
|
2013-11-19 08:09:03 -05:00
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
string queryName() const;
|
|
|
|
string querySystem() const;
|
|
|
|
string queryDrvPath() const;
|
|
|
|
string queryOutPath() const;
|
|
|
|
string queryOutputName() const;
|
2016-02-23 08:19:14 -05:00
|
|
|
/** Return the list of outputs. The "outputs to install" are determined by `mesa.outputsToInstall`. */
|
|
|
|
Outputs queryOutputs(bool onlyOutputsToInstall = false);
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2013-11-19 08:09:03 -05:00
|
|
|
StringSet queryMetaNames();
|
|
|
|
Value * queryMeta(const string & name);
|
|
|
|
string queryMetaString(const string & name);
|
2016-01-04 18:40:40 -05:00
|
|
|
NixInt queryMetaInt(const string & name, NixInt def);
|
|
|
|
NixFloat queryMetaFloat(const string & name, NixFloat def);
|
2013-11-19 08:09:03 -05:00
|
|
|
bool queryMetaBool(const string & name, bool def);
|
|
|
|
void setMeta(const string & name, Value * v);
|
2010-04-19 08:10:04 -04:00
|
|
|
|
2013-11-19 08:09:03 -05:00
|
|
|
/*
|
2006-03-10 11:20:42 -05:00
|
|
|
MetaInfo queryMetaInfo(EvalState & state) const;
|
2009-06-30 11:53:39 -04:00
|
|
|
MetaValue queryMetaInfo(EvalState & state, const string & name) const;
|
2013-11-19 08:09:03 -05:00
|
|
|
*/
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2017-07-17 13:02:56 -04:00
|
|
|
void setName(const string & s) { name = s; }
|
|
|
|
void setDrvPath(const string & s) { drvPath = s; }
|
|
|
|
void setOutPath(const string & s) { outPath = s; }
|
2007-02-01 20:52:42 -05:00
|
|
|
|
2012-07-11 10:14:06 -04:00
|
|
|
void setFailed() { failed = true; };
|
|
|
|
bool hasFailed() { return failed; };
|
2006-02-08 08:21:16 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-25 08:47:34 -05:00
|
|
|
#if HAVE_BOEHMGC
|
|
|
|
typedef list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
|
|
|
|
#else
|
2006-02-08 08:21:16 -05:00
|
|
|
typedef list<DrvInfo> DrvInfos;
|
2010-11-25 08:47:34 -05:00
|
|
|
#endif
|
2006-02-08 08:21:16 -05:00
|
|
|
|
|
|
|
|
2017-07-20 07:32:01 -04:00
|
|
|
/* If value `v' denotes a derivation, return a DrvInfo object
|
|
|
|
describing it. Otherwise return nothing. */
|
|
|
|
std::experimental::optional<DrvInfo> getDerivation(EvalState & state,
|
|
|
|
Value & v, bool ignoreAssertionFailures);
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2010-03-31 11:38:03 -04:00
|
|
|
void getDerivations(EvalState & state, Value & v, const string & pathPrefix,
|
2012-10-04 15:22:25 -04:00
|
|
|
Bindings & autoArgs, DrvInfos & drvs,
|
|
|
|
bool ignoreAssertionFailures);
|
2006-02-08 08:21:16 -05:00
|
|
|
|
2012-11-28 07:49:44 -05:00
|
|
|
|
2006-09-04 17:06:23 -04:00
|
|
|
}
|