File Coverage

blib/lib/ExtUtils/Builder/Compiler/Unixy.pm
Criterion Covered Total %
statement 29 29 100.0
branch 8 8 100.0
condition 6 8 75.0
subroutine 5 5 100.0
pod 0 1 0.0
total 48 51 94.1


line stmt bran cond sub pod time code
1             package ExtUtils::Builder::Compiler::Unixy;
2             $ExtUtils::Builder::Compiler::Unixy::VERSION = '0.035';
3 3     3   173014 use strict;
  3         4  
  3         148  
4 3     3   15 use warnings;
  3         5  
  3         178  
5              
6 3     3   542 use parent 'ExtUtils::Builder::Compiler';
  3         399  
  3         15  
7              
8             sub _init {
9 10     10   31 my ($self, %args) = @_;
10 10   50     32 $args{cc} //= ['cc'];
11 10         48 $self->SUPER::_init(%args);
12 10         25 $self->{cccdlflags} = $args{cccdlflags};
13 10   100     68 $self->{pic} = $args{pic} // ($self->type eq 'shared-library' || $self->type eq 'loadable-object') && @{ $self->{cccdlflags} };
      66        
14 10         32 return;
15             }
16              
17             sub compile_flags {
18 10     10 0 24 my ($self, $from, $to) = @_;
19 10         17 my @ret;
20 10         45 push @ret, $self->new_argument(ranking => 75, value => [ '-o' => $to, '-c', $from ]);
21 10 100       34 push @ret, $self->new_argument(ranking => 45, value => $self->{cccdlflags}) if $self->{pic};
22 10 100       34 push @ret, $self->new_argument(ranking => 15, value => [ "-std=$self->{standard}"]) if $self->{standard};
23 10         17 push @ret, map { $self->new_argument(ranking => $_->{ranking}, value => [ "-I$_->{value}" ]) } @{ $self->{include_dirs} };
  3         13  
  10         28  
24 10         19 for my $entry (@{ $self->{defines} }) {
  10         25  
25 4         10 my $key = $entry->{key};
26 4 100       21 my $value = defined $entry->{value} ? $entry->{value} ne '' ? "-D$key=$entry->{value}" : "-D$key" : "-U$key";
    100          
27 4         14 push @ret, $self->new_argument(ranking => $entry->{ranking}, value => [$value]);
28             }
29 10         54 return @ret;
30             }
31              
32             1;
33              
34             #ABSTRACT: Class for compiling with a unix compiler
35              
36             __END__