mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
* Don't forget to apply the rewritten paths to the hash rewrite map
that's applied to the environment variables / command-line arguments. Otherwise the builder will still use the unconsolidated paths.
This commit is contained in:
parent
b119dd279e
commit
b90606f4e4
3 changed files with 35 additions and 7 deletions
|
|
@ -988,10 +988,27 @@ bool DerivationGoal::prepareBuild()
|
||||||
different input closures might contain different paths from the
|
different input closures might contain different paths from the
|
||||||
*same* output path equivalence class. We should pick one from
|
*same* output path equivalence class. We should pick one from
|
||||||
each, and rewrite dependent paths. */
|
each, and rewrite dependent paths. */
|
||||||
inputPaths = consolidatePaths(inputPaths, false);
|
Replacements replacements;
|
||||||
|
inputPaths = consolidatePaths(inputPaths, false, replacements);
|
||||||
|
|
||||||
|
HashRewrites rewrites2;
|
||||||
|
for (Replacements::iterator i = replacements.begin();
|
||||||
|
i != replacements.end(); ++i)
|
||||||
|
{
|
||||||
|
printMsg(lvlError, format("FOO %1% %2%")
|
||||||
|
% i->first % i->second);
|
||||||
|
printMsg(lvlError, format("HASH REWRITE %1% %2%")
|
||||||
|
% hashPartOf(i->first).toString() % hashPartOf(i->second).toString());
|
||||||
|
rewrites2[hashPartOf(i->first)] = hashPartOf(i->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (HashRewrites::iterator i = rewrites.begin();
|
||||||
|
i != rewrites.end(); ++i)
|
||||||
|
rewrites[i->first] = PathHash(rewriteHashes(i->second.toString(), rewrites2));
|
||||||
|
|
||||||
/* !!! remove, debug only */
|
/* !!! remove, debug only */
|
||||||
consolidatePaths(inputPaths, true);
|
Replacements dummy;
|
||||||
|
consolidatePaths(inputPaths, true, dummy);
|
||||||
|
|
||||||
printMsg(lvlError, format("added input paths %1%") % showPaths(inputPaths)); /* !!! */
|
printMsg(lvlError, format("added input paths %1%") % showPaths(inputPaths)); /* !!! */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,12 @@ static void findBestRewrite(const ClassMap::const_iterator & pos,
|
||||||
|
|
||||||
|
|
||||||
static Path maybeRewrite(const Path & path, const PathSet & selection,
|
static Path maybeRewrite(const Path & path, const PathSet & selection,
|
||||||
const FinalClassMap & finalClassMap)
|
const FinalClassMap & finalClassMap,
|
||||||
|
Replacements & replacements)
|
||||||
{
|
{
|
||||||
assert(selection.find(path) != selection.end());
|
assert(selection.find(path) != selection.end());
|
||||||
|
|
||||||
|
if (replacements.find(path) != replacements.end()) return replacements[path];
|
||||||
|
|
||||||
PathSet references;
|
PathSet references;
|
||||||
queryReferences(noTxn, path, references);
|
queryReferences(noTxn, path, references);
|
||||||
|
|
@ -131,7 +134,8 @@ static Path maybeRewrite(const Path & path, const PathSet & selection,
|
||||||
|
|
||||||
printMsg(lvlError, format("replacing with `%1%'") % j->second);
|
printMsg(lvlError, format("replacing with `%1%'") % j->second);
|
||||||
|
|
||||||
Path newPath = maybeRewrite(j->second, selection, finalClassMap);
|
Path newPath = maybeRewrite(j->second, selection,
|
||||||
|
finalClassMap, replacements);
|
||||||
if (*i != newPath)
|
if (*i != newPath)
|
||||||
rewrites[hashPartOf(*i)] = hashPartOf(newPath);
|
rewrites[hashPartOf(*i)] = hashPartOf(newPath);
|
||||||
}
|
}
|
||||||
|
|
@ -148,11 +152,14 @@ static Path maybeRewrite(const Path & path, const PathSet & selection,
|
||||||
|
|
||||||
printMsg(lvlError, format("rewrote `%1%' to `%2%'") % path % newPath);
|
printMsg(lvlError, format("rewrote `%1%' to `%2%'") % path % newPath);
|
||||||
|
|
||||||
|
replacements[path] = newPath;
|
||||||
|
|
||||||
return newPath;
|
return newPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PathSet consolidatePaths(const PathSet & paths, bool checkOnly)
|
PathSet consolidatePaths(const PathSet & paths, bool checkOnly,
|
||||||
|
Replacements & replacements)
|
||||||
{
|
{
|
||||||
printMsg(lvlError, format("consolidating"));
|
printMsg(lvlError, format("consolidating"));
|
||||||
|
|
||||||
|
|
@ -199,9 +206,10 @@ PathSet consolidatePaths(const PathSet & paths, bool checkOnly)
|
||||||
finalClassMap[i->first] = *j;
|
finalClassMap[i->first] = *j;
|
||||||
|
|
||||||
PathSet newPaths;
|
PathSet newPaths;
|
||||||
|
replacements.clear();
|
||||||
for (PathSet::iterator i = bestSelection.begin();
|
for (PathSet::iterator i = bestSelection.begin();
|
||||||
i != bestSelection.end(); ++i)
|
i != bestSelection.end(); ++i)
|
||||||
newPaths.insert(maybeRewrite(*i, bestSelection, finalClassMap));
|
newPaths.insert(maybeRewrite(*i, bestSelection, finalClassMap, replacements));
|
||||||
|
|
||||||
return newPaths;
|
return newPaths;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@ Path findTrustedEqClassMember(const OutputEqClass & eqClass,
|
||||||
const TrustId & trustId);
|
const TrustId & trustId);
|
||||||
|
|
||||||
|
|
||||||
PathSet consolidatePaths(const PathSet & paths, bool checkOnly);
|
typedef map<Path, Path> Replacements;
|
||||||
|
|
||||||
|
PathSet consolidatePaths(const PathSet & paths, bool checkOnly,
|
||||||
|
Replacements & replacements);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__MISC_H */
|
#endif /* !__MISC_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue