File Coverage

blib/lib/Module/Install/External.pm
Criterion Covered Total %
statement 12 41 29.2
branch 0 8 0.0
condition n/a
subroutine 4 7 57.1
pod 3 3 100.0
total 19 59 32.2


line stmt bran cond sub pod time code
1             package Module::Install::External;
2              
3             # Provides dependency declarations for external non-Perl things
4              
5 1     1   1111 use strict;
  1         2  
  1         23  
6 1     1   5 use Module::Install::Base ();
  1         18  
  1         43  
7              
8 1     1   7 use vars qw{$VERSION $ISCORE @ISA};
  1         2  
  1         71  
9             BEGIN {
10 1     1   4 $VERSION = '1.19';
11 1         1 $ISCORE = 1;
12 1         276 @ISA = qw{Module::Install::Base};
13             }
14              
15             sub requires_xs {
16 0     0 1   my $self = shift;
17              
18             # First check for the basic C compiler
19 0           $self->requires_external_cc;
20              
21             # We need a C compiler that can build XS files
22 0 0         unless ( $self->can_xs ) {
23 0           print "Unresolvable missing external dependency.\n";
24 0           print "This package requires perl's header files.\n";
25 0           print STDERR "NA: Unable to build distribution on this platform.\n";
26 0           exit(0);
27             }
28              
29 0           1;
30             }
31              
32             sub requires_external_cc {
33 0     0 1   my $self = shift;
34              
35             # We need a C compiler, use the can_cc method for this
36 0 0         unless ( $self->can_cc ) {
37 0           print "Unresolvable missing external dependency.\n";
38 0           print "This package requires a C compiler.\n";
39 0           print STDERR "NA: Unable to build distribution on this platform.\n";
40 0           exit(0);
41             }
42              
43             # Unlike some of the other modules, while we need to specify a
44             # C compiler as a dep, it needs to be a build-time dependency.
45              
46 0           1;
47             }
48              
49             sub requires_external_bin {
50 0     0 1   my ($self, $bin, $version) = @_;
51 0 0         if ( $version ) {
52 0           die "requires_external_bin does not support versions yet";
53             }
54              
55             # Load the package containing can_run early,
56             # to avoid breaking the message below.
57 0           $self->load('can_run');
58              
59             # Locate the bin
60 0           print "Locating bin:$bin...";
61 0           my $found_bin = $self->can_run( $bin );
62 0 0         if ( $found_bin ) {
63 0           print " found at $found_bin.\n";
64             } else {
65 0           print " missing.\n";
66 0           print "Unresolvable missing external dependency.\n";
67 0           print "Please install '$bin' seperately and try again.\n";
68 0           print STDERR "NA: Unable to build distribution on this platform.\n";
69 0           exit(0);
70             }
71              
72             # Once we have some way to specify external deps, do it here.
73             # In the mean time, continue as normal.
74              
75 0           1;
76             }
77              
78             1;
79              
80             __END__