4 ms·
This computes a single hash based on the contents of all files. I suppose it's appropriate for languages/build systems that do not have file-level compilation.
by zvr 4y ago
This computes a single hash based on the contents of all files. I suppose it's appropriate for languages/build systems that do not have file-level compilation. Otherwise, it would be more efficient to keep hashes per file and re-build only those that have changed.
A criticism on this implementation: The "state" directory is never cleaned; new states are always added. Therefore if you go back to a state (hash) that you had already built in the past, you will not be able to build it again.
And there is no need to create separate shell scripts, when you can have all the relevant code inside your Makefile. Presumably those are not going to be called independently anyway.
As I've written on previous discussions:
Make by default uses the file change timestamp to trigger actions. But this is definitely not the only way, and you can code your Makefile so that rebuilds happen when a file's checksum changes. IIRC, the GNU Make Book has the code ready for you to study...
Or, you might get more clever and say "when only a comment is changed, I don't want to rebuild"; file checksums are not the correct solution for this, so you can code another trigger.
- tempay 4y ago> Make by default uses the file change timestamp to trigger actions. But this is definitely not the only way Can you point to some documentation for this? I haven't been able to find anything.
- actionfromafar 4y agoccache is one approach. It's orthogonal in a way, but basically solving the same problem from a different angle.
- zvr 4y agoI wrote "the GNU Make Book has the code ready for you to study." I'm currently traveling, without access to my books, but a quick online search at the contents of this book https://nostarch.com/download/GNU_Make_dTOC.pdf https://nostarch.com/download/GNU_Make_dTOC.pdf shows that p.82 has the code for "Rebuilding When a File's Checksum Changes". The GNU Make Book by John Graham-Cumming, No Starch Press, April 2015, 256 pp., ISBN-13: 978-1-59327-649-2
- pondidum 4y agoCorrect, the state directory isn't being cleared. As this is mostly aimed at making ephemeral build agents faster, this shouldn't matter much in practice. Having said that, there is definitely some work to do on keeping the remote storage somewhat clean.