This is my interpretation of these three phrases:
If the input section of the rule contains a glob on some directory D {
DirNode DN = database.findNode(D)
if (DN == null) DN = database.createDirectoryNode(D)
//Cache the directory content in the tup database
foreach direntry F in D {
FileNode FN = database.findNode(F.name)
if (FN == null) database.createFileNode(F.name)
}
// evaluate the glob on the file nodes in the database
foreach filenode FN in DN: if (glob matches FN.name) inputNodes += FN
} else {
foreach file F in the input section {
FileNode FN = database.findNode(F.name)
if (FN == null) database.createFileNode(F.name)
inputNodes += FN
}
}
// ...continue parsing the output section and cmd sections of the rule
Tup will only re-parse the tupfile when directory D has changed since the previous build and/or when the tupfile itself has changed.
Another interpretation is:
If the input section of the rule contains a glob on some directory D {
GlobNode DN = database.findNode(D, globPattern)
if (DN == null) DN = database.createGlobNode(D)
//Cache the glob result in the tup database
foreach direntry F in D {
if (glob matches F) {
FileNode FN = database.findNode(F)
if (FN == null) database.createFileNode(F)
inputNodes += FN
}
}
} else {
foreach file F in the input section {
FileNode FN = database.findNode(F)
if (FN == null) database.createFileNode(F)
inputFileNames += FN.name
}
}
This second interpretation however does not reflect the "...and use the glob operation on the database... "
because it does not apply the glob to the (file nodes in the) database but directly to the directory entries.
My question: which interpretation best matches tup's implementation? Or is tup acting in yet another way?
Why do I want to understand this ?
Consider a directory that contains a large numbers files of which only few files match the glob and
of which only few files will ever be used as input by the build.
For such a directory the first interpretation will result in many not-used file nodes in the tup database, making the
database larger and possibly slower.