2005-01-19 18:39:47 +02:00
|
|
|
#include "build.hh"
|
2004-06-18 21:09:32 +03:00
|
|
|
|
|
|
|
|
2005-01-19 13:16:11 +02:00
|
|
|
Derivation derivationFromPath(const Path & drvPath)
|
2004-06-18 21:09:32 +03:00
|
|
|
{
|
2005-01-19 13:16:11 +02:00
|
|
|
assertStorePath(drvPath);
|
|
|
|
ensurePath(drvPath);
|
|
|
|
ATerm t = ATreadFromNamedFile(drvPath.c_str());
|
|
|
|
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
|
|
|
|
return parseDerivation(t);
|
2004-06-18 21:09:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-19 13:16:11 +02:00
|
|
|
void computeFSClosure(const Path & storePath,
|
2005-01-25 13:18:03 +02:00
|
|
|
PathSet & paths, bool flipDirection)
|
2005-01-19 13:16:11 +02:00
|
|
|
{
|
|
|
|
if (paths.find(storePath) != paths.end()) return;
|
|
|
|
paths.insert(storePath);
|
|
|
|
|
|
|
|
PathSet references;
|
2005-01-25 13:18:03 +02:00
|
|
|
if (flipDirection)
|
|
|
|
queryReferers(storePath, references);
|
|
|
|
else
|
|
|
|
queryReferences(storePath, references);
|
2005-01-19 13:16:11 +02:00
|
|
|
|
|
|
|
for (PathSet::iterator i = references.begin();
|
|
|
|
i != references.end(); ++i)
|
2005-01-25 13:18:03 +02:00
|
|
|
computeFSClosure(*i, paths, flipDirection);
|
2005-01-19 13:16:11 +02:00
|
|
|
}
|