bmakelib icon indicating copy to clipboard operation
bmakelib copied to clipboard

Cache build targets

Open bahmanm opened this issue 2 years ago • 2 comments

Follow up on a conversation on Mastodon.

Is it possible to have a smarter™ way of caching a target based on the contents rather than modification time?

For example:


_expensive-target-workhorse:
	a bunch of expensive commands

expensive-target : _expensive-target-workhorse!cached

One idea for the implementation (non-PHONY targets) is to store the caches in PROJECT_ROOT/.bmakelib-caches & use checksums to identify if a target exists in the cache and retrieve the value. In the case of directories, the checksum of the tar'ed archive can be used.

bahmanm avatar Aug 26 '23 10:08 bahmanm

I'm not sure how this would work. Could you outline what you mean?

ACleverDisguise avatar Oct 05 '23 08:10 ACleverDisguise

Say you have a target named expensive.bin which does some expensive compiling and linking to produce, well, the executable expensive.bin.

You've also got one simple file which expensive.bin depends upon. For example, simple.foo.

  1. You make expensive.bin and do some tests.
  2. You modify simple.foo and make expensive.bin.
  3. You're not happy w/ the results, so you undo your changes and make expensive.bin which makes simple.foo in the process too.

If there was a build cache, the "remaking in (3) could have been avoided b/c Make could tell that it had already made simple.foo and expensive.bin w/ the exact same contents in (2) and there's no need to remake things. In that case, could simply move the artefacts from the cache to the "build" directory and call it done.

Does that make sense?

bahmanm avatar Oct 05 '23 08:10 bahmanm