We have found that OSTree
& Ninja work really well together. OSTree is like Git, but it handles binary files well (for example you can store a complete Linux filesystem in OSTree). We commit every intermediate build target to OSTree, and this gives our Ninja rules the ability to depend on an entire tree (directory) not just individual files. This is useful for a "system integrator" build system, where we are integrating lots of third party packages (think: building your own Linux distro for an embedded device).
At my company we have been using this approach for the last 4 years. I have written it up in detail here:https://lwn.net/SubscriberLink/821367/c05df51aafbaa821/