diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-14T10·23+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-14T10·23+0000 |
commit | 3509299aca833ed50faab146f985853255041cb2 (patch) | |
tree | 4c5edc08eaa798790f72715ccbc8f19b0ef8ac47 /src/fstate.cc | |
parent | 135b7d54db4e0ca56bda67946432fcf9d4f3ac5c (diff) |
* After building, scan for actual file system references as
opposed to declared references. This prunes the reference graph, thus allowing better garbage collection and more efficient derivate distribution.
Diffstat (limited to 'src/fstate.cc')
-rw-r--r-- | src/fstate.cc | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/fstate.cc b/src/fstate.cc index a597b6df6b77..36f7482acf9d 100644 --- a/src/fstate.cc +++ b/src/fstate.cc @@ -11,6 +11,7 @@ #include "globals.hh" #include "store.hh" #include "db.hh" +#include "references.hh" /* A Unix environment is a mapping from strings to strings. */ @@ -279,12 +280,15 @@ static FState realise(FState fs, StringSet & paths) checkPlatform(platform); /* Realise inputs. */ + Strings inPaths; ATermList ins2 = ATempty; while (!ATisEmpty(ins)) { - ins2 = ATinsert(ins2, realise(ATgetFirst(ins), paths)); + FState in = realise(ATgetFirst(ins), paths); + inPaths.push_back(fstatePath(in)); + ins2 = ATinsert(ins2, in); ins = ATgetNext(ins); } - ins2 = ATreverse(ins2); + ins = ATreverse(ins2); /* Build the environment. */ Environment env; @@ -323,9 +327,34 @@ static FState realise(FState fs, StringSet & paths) values.cc. */ registerPath(outPath, outHash); + /* Filter out inputs that are not referenced in the output. */ + for (Strings::iterator i = inPaths.begin(); + i != inPaths.end(); i++) + debug(format("in: %1%") % *i); + + Strings outPaths = filterReferences(outPath, inPaths); + + for (Strings::iterator i = outPaths.begin(); + i != outPaths.end(); i++) + debug(format("out: %1%") % *i); + + ins2 = ATempty; + while (!ATisEmpty(ins)) { + FState in = ATgetFirst(ins); + string path = fstatePath(in); + for (Strings::iterator i = outPaths.begin(); + i != outPaths.end(); i++) + if (path.find(*i) != string::npos) { + debug(format("out2: %1%") % path); + ins2 = ATinsert(ins2, in); + } + ins = ATgetNext(ins); + } + ins = ATreverse(ins2); + /* Register the normal form of fs. */ FState nf = ATmake("Path(<str>, Hash(<str>), <term>)", - outPath.c_str(), ((string) outHash).c_str(), ins2); + outPath.c_str(), ((string) outHash).c_str(), ins); nf = storeSuccessor(fs, nf, paths); return nf; |