Include all outputs of derivations in the closure of explicitly-passed derivation paths

This required adding a queryOutputDerivationNames function in the store API
This commit is contained in:
Shea Levy 2011-11-06 06:28:20 +00:00
parent 981edeab7b
commit af2e53fd48
8 changed files with 58 additions and 2 deletions

View file

@ -347,6 +347,7 @@ static void prim_derivationStrict(EvalState & state, Value * * args, Value & v)
derivation. */ derivation. */
foreach (PathSet::iterator, i, context) { foreach (PathSet::iterator, i, context) {
Path path = *i; Path path = *i;
bool explicitlyPassed = false;
/* Paths marked with `=' denote that the path of a derivation /* Paths marked with `=' denote that the path of a derivation
is explicitly passed to the builder. Since that allows the is explicitly passed to the builder. Since that allows the
@ -361,8 +362,10 @@ static void prim_derivationStrict(EvalState & state, Value * * args, Value & v)
foreach (PathSet::iterator, j, refs) { foreach (PathSet::iterator, j, refs) {
drv.inputSrcs.insert(*j); drv.inputSrcs.insert(*j);
if (isDerivation(*j)) if (isDerivation(*j))
drv.inputDrvs[*j] = singleton<StringSet>("out"); drv.inputDrvs[*j] = store -> queryDerivationOutputNames(*j);
} }
explicitlyPassed = true;
} }
/* See prim_unsafeDiscardOutputDependency. */ /* See prim_unsafeDiscardOutputDependency. */
@ -376,7 +379,10 @@ static void prim_derivationStrict(EvalState & state, Value * * args, Value & v)
debug(format("derivation uses `%1%'") % path); debug(format("derivation uses `%1%'") % path);
if (!useDrvAsSrc && isDerivation(path)) if (!useDrvAsSrc && isDerivation(path))
drv.inputDrvs[path] = singleton<StringSet>("out"); if (explicitlyPassed)
drv.inputDrvs[path] = store -> queryDerivationOutputNames(path);
else
drv.inputDrvs[path] = singleton<StringSet>("out");
else else
drv.inputSrcs.insert(path); drv.inputSrcs.insert(path);
} }

View file

@ -820,6 +820,28 @@ PathSet LocalStore::queryDerivationOutputs(const Path & path)
} }
StringSet LocalStore::queryDerivationOutputNames(const Path & path)
{
SQLiteTxn txn(db);
SQLiteStmtUse use(stmtQueryDerivationOutputs);
stmtQueryDerivationOutputs.bind(queryValidPathId(path));
StringSet outputNames;
int r;
while ((r = sqlite3_step(stmtQueryDerivationOutputs)) == SQLITE_ROW) {
const char * s = (const char *) sqlite3_column_text(stmtQueryDerivationOutputs, 0);
assert(s);
outputNames.insert(s);
}
if (r != SQLITE_DONE)
throwSQLiteError(db, format("error getting output names of `%1%'") % path);
return outputNames;
}
void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter & run) void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter & run)
{ {
if (run.pid != -1) return; if (run.pid != -1) return;

View file

@ -119,6 +119,8 @@ public:
PathSet queryDerivationOutputs(const Path & path); PathSet queryDerivationOutputs(const Path & path);
StringSet queryDerivationOutputNames(const Path & path);
PathSet querySubstitutablePaths(); PathSet querySubstitutablePaths();
bool hasSubstitutes(const Path & path); bool hasSubstitutes(const Path & path);

View file

@ -322,6 +322,16 @@ PathSet RemoteStore::queryDerivationOutputs(const Path & path)
} }
PathSet RemoteStore::queryDerivationOutputNames(const Path & path)
{
openConnection();
writeInt(wopQueryDerivationOutputNames, to);
writeString(path, to);
processStderr();
return readStringSet(from);
}
Path RemoteStore::addToStore(const Path & _srcPath, Path RemoteStore::addToStore(const Path & _srcPath,
bool recursive, HashType hashAlgo, PathFilter & filter) bool recursive, HashType hashAlgo, PathFilter & filter)
{ {

View file

@ -41,6 +41,8 @@ public:
PathSet queryDerivationOutputs(const Path & path); PathSet queryDerivationOutputs(const Path & path);
StringSet queryDerivationOutputNames(const Path & path);
bool hasSubstitutes(const Path & path); bool hasSubstitutes(const Path & path);
bool querySubstitutablePathInfo(const Path & path, bool querySubstitutablePathInfo(const Path & path,

View file

@ -141,6 +141,9 @@ public:
/* Query the outputs of the derivation denoted by `path'. */ /* Query the outputs of the derivation denoted by `path'. */
virtual PathSet queryDerivationOutputs(const Path & path) = 0; virtual PathSet queryDerivationOutputs(const Path & path) = 0;
/* Query the output names of the derivation denoted by `path'. */
virtual StringSet queryDerivationOutputNames(const Path & path) = 0;
/* Query whether a path has substitutes. */ /* Query whether a path has substitutes. */
virtual bool hasSubstitutes(const Path & path) = 0; virtual bool hasSubstitutes(const Path & path) = 0;

View file

@ -39,6 +39,7 @@ typedef enum {
wopQueryFailedPaths = 24, wopQueryFailedPaths = 24,
wopClearFailedPaths = 25, wopClearFailedPaths = 25,
wopQueryPathInfo = 26, wopQueryPathInfo = 26,
wopQueryDerivationOutputNames = 27,
} WorkerOp; } WorkerOp;

View file

@ -331,6 +331,16 @@ static void performOp(unsigned int clientVersion,
break; break;
} }
case wopQueryDerivationOutputNames: {
Path path = readStorePath(from);
startWork();
StringSet names;
names = store->queryDerivationOutputNames(path);
stopWork();
writeStringSet(names, to);
break;
}
case wopQueryDeriver: { case wopQueryDeriver: {
Path path = readStorePath(from); Path path = readStorePath(from);
startWork(); startWork();