File Coverage

_build/lib/MyModuleBuilder.pm
Criterion Covered Total %
statement 39 74 52.7
branch 5 32 15.6
condition 0 4 0.0
subroutine 7 9 77.7
pod 0 2 0.0
total 51 121 42.1


line stmt bran cond sub pod time code
1             package MyModuleBuilder;
2 1     1   598 use Module::Build;
  1         75146  
  1         217  
3             our @ISA = qw(Module::Build);
4              
5             unless(__PACKAGE__->can("cbuilder")) {
6             *cbuilder = sub { $_[0]->_cbuilder or die "no C support" };
7             }
8             sub compile_c {
9 1     1 0 3181 my($self, $file, %args) = @_;
10 1         9 my $cc0_h =
11             $self->localize_file_path("lib/Devel/callchecker0.h");
12 1 50       42 unless(-f $cc0_h) {
13 0         0 require Devel::CallChecker;
14 0         0 Devel::CallChecker->VERSION(0.001);
15 0         0 my $content = &Devel::CallChecker::callchecker0_h();
16 0         0 $self->add_to_cleanup($cc0_h);
17 0         0 require IO::File;
18 0 0       0 my $fh = IO::File->new($cc0_h, "w") or die $!;
19 0 0       0 $fh->printflush($content) or die $!;
20 0 0       0 $fh->close or die $!;
21             }
22 1         24 return $self->SUPER::compile_c($file, %args);
23             }
24             sub link_c {
25 1     1   7 no strict "refs";
  1         1  
  1         62  
26 1     1 0 678760 my($self, $spec) = @_;
27 1         15 my $cb = $self->cbuilder;
28 1         25 my $cbclass = ref($cb);
29 1         53 my $orig_cb_prelink = $cb->can("prelink");
30 1         12 local *{"${cbclass}::prelink"} = sub {
31 1     1   4 use strict "refs";
  1         1  
  1         359  
32 0     0   0 my($self, %args) = @_;
33 0 0       0 if($args{dl_name} eq "Devel::CallParser") {
34             $args{dl_func_list} = [
35 0 0       0 @{$args{dl_func_list}||[]},
  0 0       0  
36             qw(
37             C8K61oRQKxigiqmUlVdk_gcp0
38             C8K61oRQKxigiqmUlVdk_scp0
39             ),
40             ("$]" < 5.013008 ? () : qw(
41             C8K61oRQKxigiqmUlVdk_pac0
42             C8K61oRQKxigiqmUlVdk_paz0
43             C8K61oRQKxigiqmUlVdk_pau0
44             C8K61oRQKxigiqmUlVdk_pal0
45             C8K61oRQKxigiqmUlVdk_pab0
46             C8K61oRQKxigiqmUlVdk_pap0
47             C8K61oRQKxigiqmUlVdk_pan0
48             C8K61oRQKxigiqmUlVdk_gcp1
49             C8K61oRQKxigiqmUlVdk_scp1
50             )),
51             ];
52 0   0     0 $args{dl_funcs} ||= {};
53 0         0 my $pname = $args{dl_name};
54 0 0       0 unless(exists $args{dl_funcs}->{$pname}) {
55             $args{dl_funcs} = {
56 0         0 %{$args{dl_funcs}},
  0         0  
57             $pname => [],
58             };
59             }
60             }
61 0         0 @_ = ($self, %args);
62 0         0 goto &$orig_cb_prelink;
63 1         25 };
64 1         18 my $orig_cb_link = $cb->can("link");
65 1         9 local *{"${cbclass}::link"} = sub {
66 1     1   310 my($self, %args) = @_;
67 1 50       11 if($args{module_name} eq "Devel::CallParser") {
68 1         693 require Devel::CallChecker;
69 1         1326 Devel::CallChecker->VERSION(0.002);
70             $args{objects} = [
71 1         3 @{$args{objects}},
  1         10  
72             Devel::CallChecker::callchecker_linkable(),
73             ];
74             }
75 1         3493 @_ = ($self, %args);
76 1         19 goto &$orig_cb_link;
77 1         15 };
78 1         5 my($libfile, $impfile);
79 1 50       9 if($^O eq "MSWin32") {
80 0         0 my $dlext = $cb->{config}->{dlext};
81 0         0 my $libext = $cb->{config}->{lib_ext};
82 0         0 $libfile = $spec->{lib_file};
83 0 0       0 ($impfile = $libfile) =~ s/\.\Q$dlext\E\z/$libext/
84             or die "can't generate import library name";
85 0 0       0 unlink $libfile, $impfile
86             unless $self->up_to_date($libfile, $impfile);
87             }
88 1         18 my $orig_cb_flk = $cb->can("format_linker_cmd");
89 0         0 local *{"${cbclass}::format_linker_cmd"} = sub {
90 1     1   5 use strict "refs";
  1         2  
  1         189  
91 0     0   0 my($self, %spec) = @_;
92 0         0 my @cmds = &$orig_cb_flk;
93 0         0 my $cf = $self->{config};
94 0         0 my $norm_libfile = $libfile;
95 0         0 my $norm_impfile = $impfile;
96 0         0 $self->normalize_filespecs(
97             \$norm_libfile, \$norm_impfile);
98             push @cmds, [
99             $cf->{dlltool} || "dlltool",
100             "--def", $spec{def_file},
101             "--output-lib", $norm_impfile,
102             "--dllname", $spec{basename}.".".$cf->{dlext},
103             $spec{output},
104 0 0 0     0 ] if $spec{output} eq $norm_libfile;
105 0         0 return @cmds;
106 1 50       22 } if $cb->isa("ExtUtils::CBuilder::Platform::Windows::GCC");
107 1         20 $self->SUPER::link_c($spec);
108 1 50       40813 if($^O eq "MSWin32") {
109 0 0         die "failed to generate import library"
110             unless -e $impfile;
111 0           $self->add_to_cleanup($impfile);
112             }
113             }
114              
115             1;