File Coverage

builder/MyBuilder.pm
Criterion Covered Total %
statement 14 38 36.8
branch 0 12 0.0
condition 0 6 0.0
subroutine 5 9 55.5
pod 0 4 0.0
total 19 69 27.5


line stmt bran cond sub pod time code
1             package builder::MyBuilder;
2 1     1   20 use 5.008_001;
  1         9  
3 1     1   4 use strict;
  1         6  
  1         41  
4 1     1   4 use warnings;
  1         1  
  1         69  
5 1     1   593 use parent 'Module::Build';
  1         341  
  1         6  
6              
7 1     1   106671 use Config;
  1         3  
  1         508  
8              
9             my $LIBZSTD_DIR = 'ext/zstd/lib';
10              
11             sub new {
12 0     0 0   my ($class, %args) = @_;
13 0           my $self = $class->SUPER::new(%args);
14 0 0 0       if ($self->is_debug && !-d $LIBZSTD_DIR) {
15 0           $self->do_system('git', 'submodule', 'update', '--init');
16             }
17 0           my @extra_compiler_flags = (qw/
18             -Wall -Wextra -Wno-parentheses
19             -Wno-unused -Wno-unused-parameter
20             /, ('-I.', "-I$LIBZSTD_DIR"), ('-DZSTD_LEGACY_MULTITHREADED_API'));
21 0           my $ld = $self->config('ld');
22 0 0         if ($ld =~ s/^\s*env MACOSX_DEPLOYMENT_TARGET=[^\s]+ //) {
23 0           $self->config(ld => $ld);
24             }
25 0 0         if ($self->is_debug) {
26 0           $self->config(optimize => '-g -O0');
27             }
28 0           $self->extra_compiler_flags(@extra_compiler_flags);
29 0           $self->extra_linker_flags('-pthread', "$LIBZSTD_DIR/libzstd.a");
30 0           $self;
31             }
32              
33             sub is_debug {
34 0     0 0   -d '.git';
35             }
36              
37             sub ACTION_build {
38 0     0 0   my $self = shift;
39 0 0         $self->ACTION_ppport_h() unless -e 'ppport.h';
40 0 0         unless (-f "$LIBZSTD_DIR/libzstd.a") {
41 0           local $ENV{CFLAGS} = '-DZSTD_MULTITHREAD -DZSTD_LEGACY_MULTITHREADED_API -O3 -fPIC';
42 0           my $make = 'make';
43 0 0 0       $make = 'gmake' if $^O =~ /bsd$/ && $^O !~ /gnukfreebsd$/;
44 0           $self->do_system($make => '-C', $LIBZSTD_DIR, 'libzstd.a');
45             }
46 0           $self->SUPER::ACTION_build();
47             }
48              
49             sub ACTION_ppport_h {
50 0     0 0   require Devel::PPPort;
51 0           Devel::PPPort::WriteFile('ppport.h');
52             }
53              
54             1;
55             __END__