I'm not looking for the next Module::Build. I'm also not looking for make. What I'm looking for is some functionality that I've implemented myself in various bad and ad-hoc ways:
I'm generating some output files, which usually depend on one or more input files. And as this is a lengthy process, I only want to do that if some condition holds. That condition usually is that minimum last change timestamps of the output files is later than the maximum last change timetamp of all input files, that is, all output files were created later than the last input file was changed.
Now, the basic Perl code for this is
if ((stat($target))[9] < (stat($source))[9]) { ... do work ... }
but that only covers one target depending on one source file. Also, this gets complicated, because from time to time, you want to ignore all that smartness and force a clean slate by regenerating everything anyway:
if ($force or (stat($target))[9] < (stat($source))[9]) { ... do work ... }
So, what I'd like would be something that I preconfigure and which then handles those dependencies for me and invokes my callback. Maybe like this:
GetOptions( 'f' => \my $force, 'o' => \my $outdir, ); $outdir ||= 'thumbnails'; my $needs_remake = My::Dependencies::MTime->new( force => $force ); for my $source_image (@ARGV) { if ($needs_remake->([$source_image], ["$outdir/${source_image}_t.j +pg"])) { ... do work here }; };
... except that this API doesn't look quite usable to me, and worst of all, I would need to write it myself, again. So, maybe somebody has already written and tested that code for me, or maybe somebody is even a user of code that somebody else has written, and I don't know about the module. Please tell me whether the Easter Bunny has left this on CPAN already, and where.
I've already looked at the following modules:
Currently, I've somewhat uneasily settled on Decision::Depends with the following construct:
if (test_dep( -target => $thumbname, -depend => $info->{file} )) { ... }
... which still is a bit more verbose than I'd like it to be, but then again, I didn't need to write any code myself. Still, other recommendations are welcome!
In reply to A module encapsulating "make"-like checks by Corion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |