* 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:
Eelco Dolstra 2005-05-30 11:46:55 +00:00
parent b119dd279e
commit b90606f4e4
3 changed files with 35 additions and 7 deletions

View file

@ -988,10 +988,27 @@ bool DerivationGoal::prepareBuild()
different input closures might contain different paths from the
*same* output path equivalence class. We should pick one from
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 */
consolidatePaths(inputPaths, true);
Replacements dummy;
consolidatePaths(inputPaths, true, dummy);
printMsg(lvlError, format("added input paths %1%") % showPaths(inputPaths)); /* !!! */

View file

@ -104,9 +104,12 @@ static void findBestRewrite(const ClassMap::const_iterator & pos,
static Path maybeRewrite(const Path & path, const PathSet & selection,
const FinalClassMap & finalClassMap)
const FinalClassMap & finalClassMap,
Replacements & replacements)
{
assert(selection.find(path) != selection.end());
if (replacements.find(path) != replacements.end()) return replacements[path];
PathSet 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);
Path newPath = maybeRewrite(j->second, selection, finalClassMap);
Path newPath = maybeRewrite(j->second, selection,
finalClassMap, replacements);
if (*i != 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);
replacements[path] = newPath;
return newPath;
}
PathSet consolidatePaths(const PathSet & paths, bool checkOnly)
PathSet consolidatePaths(const PathSet & paths, bool checkOnly,
Replacements & replacements)
{
printMsg(lvlError, format("consolidating"));
@ -199,9 +206,10 @@ PathSet consolidatePaths(const PathSet & paths, bool checkOnly)
finalClassMap[i->first] = *j;
PathSet newPaths;
replacements.clear();
for (PathSet::iterator i = bestSelection.begin();
i != bestSelection.end(); ++i)
newPaths.insert(maybeRewrite(*i, bestSelection, finalClassMap));
newPaths.insert(maybeRewrite(*i, bestSelection, finalClassMap, replacements));
return newPaths;
}

View file

@ -33,7 +33,10 @@ Path findTrustedEqClassMember(const OutputEqClass & eqClass,
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 */