use parent qw/Exporter/;
no if $] > 5.017011, warnings => 'experimental::smartmatch';
+use Digest::SHA qw/sha256_hex/;
use Expect::Simple;
use File::Basename qw/fileparse/;
+use File::Copy qw/cp/;
use File::Slurp qw/read_file write_file/;
use List::MoreUtils qw/natatime/;
use Log::Log4perl qw/get_logger/;
$file->{run} = mkrun($format);
write_file $name, $content;
- prepare $name, $format;
+ if ($ENV{GRUNTMASTER_CCACHE}) {
+ my $key = lc sha256_hex($content) . '-' . $format;
+ my $cachefn = "$ENV{GRUNTMASTER_CCACHE}/$key";
+ my $exefn = fileparse $name, qr/[.][^.]*/s;
+ if (cp $cachefn, $exefn) {
+ get_logger->trace("File $name found in compilation cache")
+ } else {
+ prepare $name, $format;
+ cp $exefn, $cachefn
+ }
+ } else {
+ prepare $name, $format
+ }
}
}