From 05f0430de1d8eeae222a1306d4d0f7f407c8ce7d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Jan 2005 14:10:19 +0000 Subject: * Another change to low-level derivations. The last one this year, I promise :-) This allows derivations to specify on *what* output paths of input derivations they are dependent. This helps to prevent unnecessary downloads. For instance, a build might be dependent on the `devel' and `lib' outputs of some library component, but not the `docs' output. --- src/libstore/build.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 60e72c9dc195..9e984a5b3fd9 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -448,9 +448,10 @@ void DerivationGoal::haveStoreExpr() } /* Inputs must be built before we can build this goal. */ - for (PathSet::iterator i = drv.inputDrvs.begin(); + /* !!! but if possible, only install the paths that we need */ + for (DerivationInputs::iterator i = drv.inputDrvs.begin(); i != drv.inputDrvs.end(); ++i) - addWaitee(worker.makeDerivationGoal(*i)); + addWaitee(worker.makeDerivationGoal(i->first)); for (PathSet::iterator i = drv.inputSrcs.begin(); i != drv.inputSrcs.end(); ++i) @@ -812,18 +813,23 @@ bool DerivationGoal::prepareBuild() /* Determine the full set of input paths. */ /* First, the input derivations. */ - for (PathSet::iterator i = drv.inputDrvs.begin(); + for (DerivationInputs::iterator i = drv.inputDrvs.begin(); i != drv.inputDrvs.end(); ++i) { - /* Add all the output closures of the input derivation `*i' as - input paths. !!! there should be a way to indicate - specific outputs. */ + /* Add the relevant output closures of the input derivation + `*i' as input paths. Only add the closures of output paths + that are specified as inputs. */ /* !!! is `*i' present? */ - assert(isValidPath(*i)); - Derivation inDrv = derivationFromPath(*i); - for (DerivationOutputs::iterator j = inDrv.outputs.begin(); - j != inDrv.outputs.end(); ++j) - computeFSClosure(j->second.path, inputPaths); + assert(isValidPath(i->first)); + Derivation inDrv = derivationFromPath(i->first); + for (StringSet::iterator j = i->second.begin(); + j != i->second.begin(); ++j) + if (inDrv.outputs.find(*j) != inDrv.outputs.end()) + computeFSClosure(inDrv.outputs[*j].path, inputPaths); + else + throw Error( + format("derivation `%1%' requires non-existent output `%2%' from input derivation `%3%'") + % drvPath % *j % i->first); } for (PathSet::iterator i = inputPaths.begin(); i != inputPaths.end(); ++i) -- cgit 1.4.1