* Put building in the store API.

This commit is contained in:
Eelco Dolstra 2006-11-30 18:02:04 +00:00
parent e2ef5e07fd
commit 6ecb840fd1
11 changed files with 31 additions and 48 deletions

View file

@ -5,7 +5,7 @@ libstore_la_SOURCES = \
db.cc references.cc pathlocks.cc gc.cc
pkginclude_HEADERS = \
store-api.hh local-store.cc derivations.hh build.hh misc.hh globals.hh \
store-api.hh local-store.cc derivations.hh misc.hh globals.hh \
db.hh references.hh pathlocks.hh gc.hh
libstore_la_LIBADD = ../libutil/libutil.la ../boost/format/libformat.la

View file

@ -1,4 +1,3 @@
#include "build.hh"
#include "references.hh"
#include "pathlocks.hh"
#include "misc.hh"
@ -2195,7 +2194,7 @@ void Worker::waitForInput()
//////////////////////////////////////////////////////////////////////
void buildDerivations(const PathSet & drvPaths)
void LocalStore::buildDerivations(const PathSet & drvPaths)
{
startNest(nest, lvlDebug,
format("building %1%") % showPaths(drvPaths));
@ -2222,7 +2221,7 @@ void buildDerivations(const PathSet & drvPaths)
}
void ensurePath(const Path & path)
void LocalStore::ensurePath(const Path & path)
{
/* If the path is already valid, we're done. */
if (store->isValidPath(path)) return;

View file

@ -1,30 +0,0 @@
#ifndef __BUILD_H
#define __BUILD_H
#include "types.hh"
namespace nix {
extern string drvsLogDir;
/* Ensure that the output paths of the derivation are valid. If they
are already valid, this is a no-op. Otherwise, validity can
be reached in two ways. First, if the output paths have
substitutes, then those can be used. Second, the output paths can
be created by running the builder, after recursively building any
sub-derivations. */
void buildDerivations(const PathSet & drvPaths);
/* Ensure that a path is valid. If it is not currently valid, it may
be made valid by running a substitute (if defined for the path). */
void ensurePath(const Path & storePath);
}
#endif /* !__BUILD_H */

View file

@ -33,7 +33,6 @@ extern string nixConfDir;
extern string nixLibexecDir;
/* Misc. global flags. */
/* Whether to keep temporary directories of failed builds. */

View file

@ -18,6 +18,9 @@ class Transaction;
const int nixSchemaVersion = 3;
extern string drvsLogDir;
class LocalStore : public StoreAPI
{
public:
@ -56,6 +59,10 @@ public:
Path addTextToStore(const string & suffix, const string & s,
const PathSet & references);
void buildDerivations(const PathSet & drvPaths);
void ensurePath(const Path & storePath);
private:
Path _addToStore(bool fixed, bool recursive,
string hashAlgo, const Path & _srcPath);

View file

@ -1,6 +1,5 @@
#include "misc.hh"
#include "store-api.hh"
#include "build.hh"
#include "db.hh"
#include <aterm2.h>
@ -12,7 +11,7 @@ namespace nix {
Derivation derivationFromPath(const Path & drvPath)
{
assertStorePath(drvPath);
ensurePath(drvPath);
store->ensurePath(drvPath);
ATerm t = ATreadFromNamedFile(drvPath.c_str());
if (!t) throw Error(format("cannot read aterm from `%1%'") % drvPath);
return parseDerivation(t);

View file

@ -72,6 +72,19 @@ public:
a regular file containing the given string. */
virtual Path addTextToStore(const string & suffix, const string & s,
const PathSet & references) = 0;
/* Ensure that the output paths of the derivation are valid. If
they are already valid, this is a no-op. Otherwise, validity
can be reached in two ways. First, if the output paths have
substitutes, then those can be used. Second, the output paths
can be created by running the builder, after recursively
building any sub-derivations. */
virtual void buildDerivations(const PathSet & drvPaths) = 0;
/* Ensure that a path is valid. If it is not currently valid, it
may be made valid by running a substitute (if defined for the
path). */
virtual void ensurePath(const Path & storePath) = 0;
};