There are numerous problems with using directory mtimes for comparisons:
- They don't always change when the source code changes.
For libraries that are fetched over HTTP, the comparison was mostly fine because for those the source directory that the script compared against was the versioned subdirectory that either doesn't exist or is named after the lib version (e.g. "libsodium/libsodium-1.0.18/" compared to "libsodium/.already-built").
However, directories for which the source is checked into version control (such as SpiderMonkey), this doesn't work so well as individual files within source/spidermonkey/ may change without the directory mtime changing per-se (mtimes of files don't propagate to parent directories on most file systems, as far as I know).
This was raised in Trac issue #2551 and worked around in rP15696 by adding a second mtime comparison for source/spidermonkey/README.txt which just so happens to contain the mozjs version number.
Instead of these indirect measures, I propose to write the LIB_VERSION value to the .already-built file and compare against that directly.
- They don't work properly when going backwards in time.
When checking out an older revision, branch, or when using something like git-bisect, the time comparisons might not work as expected, especially if the older version still exists on disk with its older timestamp.
By performing strict comparisons we remove the assumption that a newer source directory is always want we are currently interested in. Thus reducing our assumption to only that we are interested in what the currently executing version of the build script is meant to produce.
Also, there were two libraries that were lacking any kind of mtime or other comparison. These were NVTT and FColladda. This meant that once built, no matter how long ago, they would never be rebuild unless the user passed the --force-rebuild option. These change quite rarely, so perhaps that isn't too bad, but I've added a LIB_VERSION for these as well so that we at least have the option of making this work automatically if we remember to bump them, which could even be done after the fact if forgotten and still helps other people. Rebuilding only one library takes significantly less time than rebuilding everything from scratch.