diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30 18:02:04 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30 18:02:04 +0000 |
commit | 6ecb840fd118019f879de60007e13321b7c080d3 (patch) | |
tree | 29f9db5fbf0da0b3e08af282db1a0fedba81decf | |
parent | e2ef5e07fdc142670f7f3161d3133ff04e99d342 (diff) |
* Put building in the store API.
-rw-r--r-- | src/libexpr/primops.cc | 3 | ||||
-rw-r--r-- | src/libstore/Makefile.am | 2 | ||||
-rw-r--r-- | src/libstore/build.cc | 5 | ||||
-rw-r--r-- | src/libstore/build.hh | 30 | ||||
-rw-r--r-- | src/libstore/globals.hh | 1 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 7 | ||||
-rw-r--r-- | src/libstore/misc.cc | 3 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 13 | ||||
-rw-r--r-- | src/nix-env/main.cc | 7 | ||||
-rw-r--r-- | src/nix-instantiate/main.cc | 1 | ||||
-rw-r--r-- | src/nix-store/main.cc | 7 |
11 files changed, 31 insertions, 48 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index d4de6027e..17a04bc83 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1,4 +1,3 @@ -#include "build.hh" #include "misc.hh" #include "eval.hh" #include "globals.hh" @@ -50,7 +49,7 @@ static Expr primImport(EvalState & state, const ATermVector & args) throw EvalError(format("cannot import `%1%', since path `%2%' is not valid") % path % *i); if (isDerivation(*i)) - buildDerivations(singleton<PathSet>(*i)); + store->buildDerivations(singleton<PathSet>(*i)); } return evalFile(state, path); diff --git a/src/libstore/Makefile.am b/src/libstore/Makefile.am index 209a1e692..4d25c2d68 100644 --- a/src/libstore/Makefile.am +++ b/src/libstore/Makefile.am @@ -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 diff --git a/src/libstore/build.cc b/src/libstore/build.cc index a78d5010c..54c48cf91 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -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; diff --git a/src/libstore/build.hh b/src/libstore/build.hh deleted file mode 100644 index 71895c0a9..000000000 --- a/src/libstore/build.hh +++ /dev/null @@ -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 */ diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 9441dc344..b93f5d62c 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -33,7 +33,6 @@ extern string nixConfDir; extern string nixLibexecDir; - /* Misc. global flags. */ /* Whether to keep temporary directories of failed builds. */ diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 2fd45cd7a..e41e43683 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -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); diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index b442bd4c2..6849e2c1a 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -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); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 91beba50f..abf27a346 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -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; }; diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index 997c45da3..ce0bef069 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -1,7 +1,6 @@ #include "profiles.hh" #include "names.hh" #include "globals.hh" -#include "build.hh" #include "misc.hh" #include "gc.hh" #include "shared.hh" @@ -152,7 +151,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems, drvsToBuild.insert(i->queryDrvPath(state)); debug(format("building user environment dependencies")); - buildDerivations(drvsToBuild); + store->buildDerivations(drvsToBuild); /* Get the environment builder expression. */ Expr envBuilder = parseExprFromFile(state, @@ -184,7 +183,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems, /* This is only necessary when installing store paths, e.g., `nix-env -i /nix/store/abcd...-foo'. */ addTempRoot(i->queryOutPath(state)); - ensurePath(i->queryOutPath(state)); + store->ensurePath(i->queryOutPath(state)); references.insert(i->queryOutPath(state)); if (drvPath != "") references.insert(drvPath); @@ -212,7 +211,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems, /* Realise the resulting store expression. */ debug(format("building user environment")); - buildDerivations(singleton<PathSet>(topLevelDrv.queryDrvPath(state))); + store->buildDerivations(singleton<PathSet>(topLevelDrv.queryDrvPath(state))); /* Switch the current user environment to the output path. */ debug(format("switching to new user environment")); diff --git a/src/nix-instantiate/main.cc b/src/nix-instantiate/main.cc index 144b13d2b..71f0a44e2 100644 --- a/src/nix-instantiate/main.cc +++ b/src/nix-instantiate/main.cc @@ -2,7 +2,6 @@ #include <iostream> #include "globals.hh" -#include "build.hh" #include "gc.hh" #include "shared.hh" #include "eval.hh" diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index 273fa3e74..f31814881 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -2,7 +2,6 @@ #include <algorithm> #include "globals.hh" -#include "build.hh" #include "misc.hh" #include "gc.hh" #include "archive.hh" @@ -64,7 +63,7 @@ static Path realisePath(const Path & path) if (isDerivation(path)) { PathSet paths; paths.insert(path); - buildDerivations(paths); + store->buildDerivations(paths); Path outPath = findOutput(derivationFromPath(path), "out"); if (gcRoot == "") @@ -76,7 +75,7 @@ static Path realisePath(const Path & path) return outPath; } else { - ensurePath(path); + store->ensurePath(path); return path; } } @@ -97,7 +96,7 @@ static void opRealise(Strings opFlags, Strings opArgs) i != opArgs.end(); ++i) if (isDerivation(*i)) drvPaths.insert(*i); - buildDerivations(drvPaths); + store->buildDerivations(drvPaths); } for (Strings::iterator i = opArgs.begin(); |