| 1 | package App::FatPacker::Trace; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings FATAL => 'all'; | ||
| 5 | use B (); | ||
| 6 | |||
| 7 | my $trace_file; | ||
| 8 | my %initial_inc; | ||
| 9 | |||
| 10 | sub import { | ||
| 11 | my (undef, $file, @extras) = @_; | ||
| 12 | |||
| 13 | $trace_file = $file || '>>fatpacker.trace'; | ||
| 14 | # For filtering out our own deps later. | ||
| 15 | # (Not strictly required as these are core only and won't have packlists, but | ||
| 16 | # looks neater.) | ||
| 17 | %initial_inc = %INC; | ||
| 18 | |||
| 19 | # Use any extra modules specified | ||
| 20 | eval "use $_" for @extras; | ||
| 21 | |||
| 22 | B::minus_c; | ||
| 23 | } | ||
| 24 | |||
| 25 | CHECK { | ||
| 26 | return unless $trace_file; # not imported | ||
| 27 | |||
| 28 | open my $trace, $trace_file | ||
| 29 | or die "Couldn't open $trace_file to trace to: $!"; | ||
| 30 | |||
| 31 | for my $inc (keys %INC) { | ||
| 32 | next if exists $initial_inc{$inc}; | ||
| 33 | next unless defined($INC{$inc}) and $INC{$inc} =~ /\Q${inc}\E\Z/; | ||
| 34 | print $trace "$inc\n"; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | __END__ |