Open zah opened 8 years ago
I agree this is something we should support, but instead of a %x flag it might make sense to have tup better handle variable-named outputs instead. Then whatever program you have that is generating the files can name them with whatever hashing convention it likes. Otherwise we'd likely have to implement multiple hashing styles and have a variety of %-style flags to support them.
I'm using tup to generate a static site, and even just the most basic hashing function would be very useful for maintaining my thumbnail cache. I don't think there's a need to get too fancy about it, just pick a decent hashing function and stick with it. Even md5 would be fine for 99% of use cases.
I'm using Tup in web projects with transpilers such as CoffeeScript, TypeScript, Stylus, Less, Sass and so on. I'd like to permanently cache the final compiled JavaScript and CSS files (in the browser) by generating unique file names on each build.
Let's add a %x flag that will tell Tup to compute a checksum of the output file and then rename it immediately after the build. The groups and bins feature can be used to give a symbolic name of the output if it's used as a dependency in another command. %x could support a prefix length to let the user have some control over the generated names.