ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Perl-LibExtractor/LibExtractor.pm
(Generate patch)

Comparing cvsroot/Perl-LibExtractor/LibExtractor.pm (file contents):
Revision 1.15 by root, Thu Jan 26 01:24:25 2012 UTC vs.
Revision 1.16 by root, Thu Jan 26 15:11:46 2012 UTC

95If disabled, only shared objects and autoload files will be added. 95If disabled, only shared objects and autoload files will be added.
96 96
97Debian GNU/Linux doesn't completely package perl or any perl modules, so 97Debian GNU/Linux doesn't completely package perl or any perl modules, so
98this option will fail. Other perls should be fine. 98this option will fail. Other perls should be fine.
99 99
100=item extra_deps => { file => [files...] }
101
102Some (mainly runtime dependencies in the perl core library) cannot be
103detected automatically by this module, especially if you don't use
104packlists and C<add_core>.
105
106This module comes with a set of default dependencies (such as L<Carp>
107requiring L<Carp::Heavy>), which you cna override with this parameter.
108
109To see the default set of dependencies that come with this module, use
110this:
111
112 perl -MPerl::LibExtractor -MData::Dumper -e 'print Dumper $Perl::LibExtractor::EXTRA_DEPS'
113
100=back 114=back
101 115
102=cut 116=cut
117
118our $EXTRA_DEPS = {
119 'Config.pm' => ['Config_heavy.pl', 'Config_git.pl'],
120 'Carp.pm' => ['Carp/Heavy.pm'],
121 'utf8.pm' => ['utf8_heavy.pl'],
122 'bytes.pm' => ['bytes_heavy.pl'],
123 # Exporter::Heay is usually detected
124};
103 125
104sub new { 126sub new {
105 my ($class, %kv) = @_; 127 my ($class, %kv) = @_;
106 128
107 my $self = bless { 129 my $self = bless {
108 inc => [grep $_ ne ".", @INC], 130 inc => [grep $_ ne ".", @INC],
109 use_packlist => 1, 131 use_packlist => 1,
132 extra_deps => $EXTRA_DEPS,
110 %kv, 133 %kv,
111 set => {}, 134 set => {},
112 }, $class; 135 }, $class;
113 136
114 my %inc_seen; 137 my %inc_seen;
115 my @inc = grep !$inc_seen{$_}++ && -d "$_/.", @{ $self->{inc} }; 138 my @inc = grep !$inc_seen{$_}++ && -d "$_/.", @{ $self->{inc} };
116 $self->{inc} = \@inc; 139 $self->{inc} = \@inc;
361 384
362 skip: 385 skip:
363 } 386 }
364 } 387 }
365 388
389 if (exists $self->{extra_deps}{$_}) {
390 # we require it again, because many extra dependencies require the main module to be loaded
391 $self->add_eval ("require q\x00$_\x00");
392
393 exists $lib->{$_} and $self->add_require ($_)
394 for @{ $self->{extra_deps}{$_} };
395 }
396
366 \@info 397 \@info
367 }; 398 };
368 } 399 }
369} 400}
370 401
447 $self->_trace ("use $_", "{ package $pkg; use $_ }") 478 $self->_trace ("use $_", "{ package $pkg; use $_ }")
448 unless $self->{add_mod}{$_}++; 479 unless $self->{add_mod}{$_}++;
449 } 480 }
450} 481}
451 482
483=item $extractor->add_require ($name[, $name...])
484
485Works like C<add_mod>, but uses C<require $name> to load the module, i.e.
486the name must be a filename.
487
488Example: load Coro and AnyEvent::AIO, but using C<add_require> instead of C<add_mod>.
489
490 $extractor->add_require ("Coro.pm", "AnyEvent/AIO.pm");
491
492=cut
493
494sub add_require {
495 my $self = shift;
496
497 for (@_) {
498 $self->add_eval ("require q\x00$_\x00")
499 unless $self->{add_require}{$_}++;
500 }
501}
502
452=item $extractor->add_bin ($name[, $name...]) 503=item $extractor->add_bin ($name[, $name...])
453 504
454Adds the given (perl) program(s) to the file set, that is, a program 505Adds the given (perl) program(s) to the file set, that is, a program
455installed by some perl module, written in perl (an example would be the 506installed by some perl module, written in perl (an example would be the
456L<perl-libextract> program that is part of the C<Perl::LibExtractor> 507L<perl-libextract> program that is part of the C<Perl::LibExtractor>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines