blib/lib/InlineX/CPP2XS.pm

filter: Statementstmt 90.2% 332 / 368 Branchbran 76.6% 161 / 210 Conditioncond 83.3% 20 / 24 MC/DCmcdc 68.7% 11 / 16 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 84.7% 534 / 630 SCAR 51.7
CC
125
Cov
85%
cpp2xs
96.2
_write_pm
25.9
rewrite_makefile_pl
16.8
CRAP 175.5
↑ Summary
1 package InlineX::CPP2XS;
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 11 require Exporter;
7 11 our @ISA = qw(Exporter);
8
9 11 our @EXPORT_OK = qw(cpp2xs);
10
11 11 our $VERSION = '0.24';
12 11 $VERSION = eval $VERSION;
13
14 11 my $config_options;
15
16 11 our @allowable_config_keys = ('AUTOWRAP', 'AUTO_INCLUDE', 'CODE', 'DIST', 'TYPEMAPS', 'LIBS', 'INC',
17 'WRITE_MAKEFILE_PL', 'BUILD_NOISY', 'BOOT', 'BOOT_F', 'EXPORT_ALL', 'EXPORT_OK_ALL',
18 'EXPORT_TAGS_ALL', 'MAKE', 'PREFIX', 'PREREQ_PM', 'CCFLAGS', 'CCFLAGSEX', 'LD', 'LDDLFLAGS',
19 'MYEXTLIB', 'OPTIMIZE', 'PRE_HEAD', 'CC', 'SRC_LOCATION', '_TESTING', 'USE', 'USING',
20 'WRITE_PM', 'VERSION', 'MANIF');
21
22 ##=========================##
23
24 sub cpp2xs {
25 ## This is basically just a copy'n'paste of the InlineX::C2XS::c2xs() function,
26 ## with all occurrences of "C" changed to "CPP" ... clever, eh ??
27 19 ▶ eval {require "Inline/CPP.pm"};
Subroutine cpp2xs: called CC=74 SCAR=45.7
Pod undocumented
28 19 ▶ if($@ || $Inline::CPP::VERSION < 0.39) {die "Need a functioning Inline::CPP (version 0.39 or later). $@"}
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or $Inline::CPP::VERSION < "0.39") 0 19 19
Condition33%1/3
$@ or $Inline::CPP::VERSION < "0.39"
l!l&&r!l&&!r
0019
MC/DC0%0/2
$@ or $Inline::CPP::VERSION < "0.39"
$@ $Inline::CPP::VERSION < "0.39"
Truth table33%1/3
A or B
A= $@B= $Inline::CPP::VERSION < "0.39"
ABresult
1X1
011
000
29 19 my $module = shift;
30 19 my $pkg = shift;
31
32 # Set the default for $build_dir.
33 # (This will be overwritten by the build_dir argument in @_, if supplied.)
34 19 my $build_dir = '.';
35
36
37 19 ▶ if(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 18 1 19
38 18 ▶ if(ref($_[0]) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 6 12 18
39 6 $config_options = shift;
40 6 ▶ if(@_) {die "Incorrect usage - there should be no arguments to cpp2xs() after the hash reference"}
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 5 6
41 }
42 12 else {$build_dir = shift}
43 }
44
45 18 ▶ if(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 11 7 18
46 11 ▶ if(ref($_[0]) ne "HASH") {die "Fourth arg to cpp2xs() needs to be a hash containing config options ... but it's not !!\n"}
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] ne "HASH") 1 10 11
47 10 $config_options = shift;
48 }
49
50 17 ▶ unless(-d $build_dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $build_dir) 1 16 17
51 1 die "$build_dir is not a valid directory";
52 }
53 16 my $modfname = (split /::/, $module)[-1];
54 16 ▶ my $need_inline_h = $config_options->{AUTOWRAP} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$config_options->{'AUTOWRAP'} ? : 6 10 16
55 16 my $code = '';
56 16 my $o;
57
58 16 ▶ if(exists($config_options->{CODE}) && exists($config_options->{SRC_LOCATION})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config_options->{"CODE"} and exists $config_options->{"SRC_LOCATION"}) 1 15 16
Condition100%3/3
exists $config_options->{"CODE"} and exists $config_options->{"SRC_LOCATION"}
!ll&&!rl&&r
1321
MC/DC100%2/2
exists $config_options->{"CODE"} and exists $config_options->{"SRC_LOCATION"}
exists $config_options->{"CODE"} exists $config_options->{"SRC_LOCATION"}
Truth table100%3/3
A and B
A= exists $config_options->{"CODE"}B= exists $config_options->{"SRC_LOCATION"}
ABresult
0X0
100
111
59 1 die "You can provide either CODE *or* SRC_LOCATION arguments ... but not *both*";
60 }
61
62 15 ▶ if(exists($config_options->{BOOT}) && exists($config_options->{BOOT_F})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config_options->{"BOOT"} and exists $config_options->{"BOOT_F"}) 0 15 15
Condition66%2/3
exists $config_options->{"BOOT"} and exists $config_options->{"BOOT_F"}
!ll&&!rl&&r
1410
MC/DC0%0/2
exists $config_options->{"BOOT"} and exists $config_options->{"BOOT_F"}
exists $config_options->{"BOOT"} exists $config_options->{"BOOT_F"}
Truth table66%2/3
A and B
A= exists $config_options->{"BOOT"}B= exists $config_options->{"BOOT_F"}
ABresult
0X0
100
111
63 0 die "You can provide either BOOT *or* BOOT_F arguments ... but not *both*";
64 }
65
66 15 ▶ if(exists($config_options->{CODE})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $config_options->{'CODE'}) { } 2 13 15
elsif (exists $config_options->{'SRC_LOCATION'}) { } 5 8 13
67 2 $code = $config_options->{CODE};
68 2 ▶ if($code =~ /inline_stack_vars/i) {$need_inline_h = 1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($code =~ /inline_stack_vars/i) 0 2 2
69 }
70 elsif(exists($config_options->{SRC_LOCATION})) {
71 5 ▶ open(RD, "<", $config_options->{SRC_LOCATION}) or die "Can't open ", $config_options->{SRC_LOCATION}, " for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", $config_options->{"SRC_LOCATION"} or die "Can't open ", $config_options->{"SRC_LOCATION"}, " for reading: $!" 1 4 5
72 4 ▶ while(<RD>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline RD)) 490 4 494
73 490 $code .= $_;
74 490 ▶ if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /inline_stack_vars/i) 0 490 490
75 }
76 4 ▶ close(RD) or die "Can't close ", $config_options->{SRC_LOCATION}, " after reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Can't close ", $config_options->{"SRC_LOCATION"}, " after reading: $!" 0 4 4
77 }
78 else {
79 8 ▶ open(RD, "<", "src/$modfname.cpp") or die "Can't open src/${modfname}.cpp for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", "src/$modfname.cpp" or die "Can't open src/$modfname.cpp for reading: $!" 0 8 8
80 8 ▶ while(<RD>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline RD)) 88 8 96
81 88 $code .= $_;
82 88 ▶ if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /inline_stack_vars/i) 3 85 88
83 }
84 8 ▶ close(RD) or die "Can't close src/$modfname.cpp after reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Can't close src/$modfname.cpp after reading: $!" 0 8 8
85 }
86
87 ## Initialise $o.
88 ## Many of these keys may not be needed for the purpose of this
89 ## specific exercise - but they shouldn't do any harm, so I'll
90 ## leave them in, just in case they're ever needed.
91 14 $o->{CONFIG}{BUILD_TIMERS} = 0;
92 14 $o->{CONFIG}{PRINT_INFO} = 0;
93 14 $o->{CONFIG}{USING} = [];
94 14 $o->{CONFIG}{WARNINGS} = 1;
95 14 $o->{CONFIG}{PRINT_VERSION} = 0;
96 14 $o->{CONFIG}{CLEAN_BUILD_AREA} = 0;
97 14 $o->{CONFIG}{GLOBAL_LOAD} = 0;
98 14 $o->{CONFIG}{DIRECTORY} = '';
99 14 $o->{CONFIG}{SAFEMODE} = -1;
100 14 $o->{CONFIG}{CLEAN_AFTER_BUILD} = 1;
101 14 $o->{CONFIG}{FORCE_BUILD} = 0;
102 14 $o->{CONFIG}{NAME} = '';
103 14 $o->{CONFIG}{_INSTALL_} = 0;
104 14 $o->{CONFIG}{WITH} = [];
105 14 $o->{CONFIG}{AUTONAME} = 1;
106 14 $o->{CONFIG}{REPORTBUG} = 0;
107 14 $o->{CONFIG}{UNTAINT} = 0;
108 14 $o->{CONFIG}{VERSION} = '';
109 14 $o->{CONFIG}{BUILD_NOISY} = 1;
110 14 $o->{INLINE}{ILSM_suffix} = $Config::Config{dlext};
111 14 $o->{INLINE}{ILSM_module} = 'Inline::CPP';
112 14 $o->{INLINE}{version} = $Inline::VERSION;
113 14 $o->{INLINE}{ILSM_type} = 'compiled';
114 14 $o->{INLINE}{DIRECTORY} = 'irrelevant_0';
115 14 $o->{INLINE}{object_ready} = 0;
116 14 $o->{INLINE}{md5} = 'irrelevant_1';
117 14 $o->{API}{modfname} = $modfname;
118 14 $o->{API}{script} = 'irrelevant_2';
119 14 $o->{API}{location} = 'irrelevant_3';
120 14 $o->{API}{language} = 'CPP';
121 14 $o->{API}{modpname} = 'irrelevant_4';
122 14 $o->{API}{directory} = 'irrelevant_5';
123 14 $o->{API}{install_lib} = 'irrelevant_6';
124 14 $o->{API}{build_dir} = $build_dir;
125 14 $o->{API}{language_id} = 'CPP';
126 14 $o->{API}{pkg} = $pkg;
127 14 $o->{API}{suffix} = $Config::Config{dlext};
128 14 $o->{API}{cleanup} = 1;
129 14 $o->{API}{module} = $module;
130 14 $o->{API}{code} = $code;
131
132 # Check for invalid config options - and die if one is found
133 14 ▶ for(keys(%$config_options)) { die "$_ is an invalid config option" if !_check_config_keys($_)}
Branch: 1 branch
BranchTrueFalseTotal
unless _check_config_keys($_) 1 65 66
134
135 13 ▶ if(exists($config_options->{BUILD_NOISY})) {$o->{CONFIG}{BUILD_NOISY} = $config_options->{BUILD_NOISY}}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config_options->{"BUILD_NOISY"}) 1 12 13
136
137 13 ▶ if($config_options->{DIST}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"DIST"}) 1 12 13
138 1 $config_options->{WRITE_MAKEFILE_PL} = 'P';
139 1 $config_options->{WRITE_PM} = 1;
140 1 $config_options->{MANIF} = 1;
141 }
142
143 13 ▶ if($config_options->{AUTOWRAP}) {$o->{ILSM}{AUTOWRAP} = 1}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"AUTOWRAP"}) 6 7 13
144
145 13 ▶ if($config_options->{BOOT}) {$o->{ILSM}{XS}{BOOT} = $config_options->{BOOT}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"BOOT"}) 1 12 13
146
147 13 ▶ if($config_options->{BOOT_F}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"BOOT_F"}) 0 13 13
148 0 my $code;
149 0 ▶ open(RD, "<", $config_options->{BOOT_F}) or die "Can't open ", $config_options->{BOOT_F}, " for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", $config_options->{"BOOT_F"} or die "Can't open ", $config_options->{"BOOT_F"}, " for reading: $!" 0 0 0
150 0 ▶ while(<RD>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline RD)) 0 0 0
151 0 $code .= $_;
152 0 ▶ if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /inline_stack_vars/i) 0 0 0
153 }
154 0 ▶ close(RD) or die "Can't close ", $config_options->{BOOT_F}, " after reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Can't close ", $config_options->{"BOOT_F"}, " after reading: $!" 0 0 0
155 0 $o->{ILSM}{XS}{BOOT} = $code;
156 }
157
158 # This is what Inline::C does with the MAKE parameter ... so we'll do the same.
159 # Not sure that this achieves anything in the context of InlineX::CPP2XS.
160 13 ▶ if($config_options->{MAKE}) {$o->{ILSM}{MAKE} = $config_options->{MAKE}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"MAKE"}) 1 12 13
161
162 13 ▶ if(exists($config_options->{TYPEMAPS})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config_options->{'TYPEMAPS'}) { } 7 6 13
163 7 ▶ if(ref($config_options->{TYPEMAPS}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $config_options->{'TYPEMAPS'} eq 'ARRAY') { } 5 2 7
164 5 for(@{$config_options->{TYPEMAPS}}) {
165 5 ▶ die "Couldn't locate the typemap $_" unless -f $_;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $_ 1 4 5
166 }
167 4 $o->{ILSM}{MAKEFILE}{TYPEMAPS} = $config_options->{TYPEMAPS};
168 }
169 else {
170 2 my @vals = split /\s+/, $config_options->{TYPEMAPS};
171 2 for(@vals) {
172 2 ▶ die "Couldn't locate the typemap $_" unless -f $_;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $_ 0 2 2
173 }
174 2 $o->{ILSM}{MAKEFILE}{TYPEMAPS} = \@vals;
175 }
176 }
177 else {
178 6 $o->{ILSM}{MAKEFILE}{TYPEMAPS} = [];
179 }
180
181 12 my @uncorrupted_typemaps = @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}};
182 12 push @uncorrupted_typemaps, 'CPP.map';
183
184 12 ▶ if($config_options->{PREFIX}) {$o->{ILSM}{XS}{PREFIX} = $config_options->{PREFIX}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"PREFIX"}) 1 11 12
185
186 12 bless($o, 'Inline::CPP');
187
188 12 Inline::CPP::validate($o);
189
190 12 ▶ if($config_options->{LIBS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"LIBS"}) 1 11 12
191 1 my @init;
192 my $init;
193 1 ▶ if(ref($o->{ILSM}{MAKEFILE}{LIBS}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $o->{'ILSM'}{'MAKEFILE'}{'LIBS'} eq 'ARRAY') { } 1 0 1
194 1 @init = @{$o->{ILSM}{MAKEFILE}{LIBS}};
195 1 $init = join ' ', @init;
196 }
197 0 else {$init = $o->{ILSM}{MAKEFILE}{LIBS};}
198
199 1 my @add;
200 my $add;
201 1 ▶ if(ref($config_options->{LIBS}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $config_options->{'LIBS'} eq 'ARRAY') { } 1 0 1
202 1 @add = @{$config_options->{LIBS}};
203 1 $add = join ' ', @add;
204 }
205 0 else {$add = $config_options->{LIBS};}
206 1 $o->{ILSM}{MAKEFILE}{LIBS} = $init . ' ' . $add;
207 }
208 #else { $o->{ILSM}{MAKEFILE}{LIBS} = []} # We don't want this with Inline::CPP
209 # as it clobbers any setting that was
210 # made by Inline::CPP::validate()
211
212 12 ▶ if($config_options->{PRE_HEAD}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"PRE_HEAD"}) 2 10 12
213 2 my $v = $config_options->{PRE_HEAD};
214 #{ # open scope
215 # no warnings 'newline';
216 2 ▶ unless( -f $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $v) { } 1 1 2
217 1 $o->{ILSM}{AUTO_INCLUDE} = $v . "\n" . $o->{ILSM}{AUTO_INCLUDE};
218 }
219 else {
220 1 my $insert;
221 1 ▶ open RD, '<', $v or die "Couldn't open $v for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", $v or die "Couldn't open $v for reading: $!" 0 1 1
222 1 ▶ while(<RD>) {$insert .= $_}
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline RD)) 5 1 6
223 1 ▶ close RD or die "Couldn't close $v after reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Couldn't close $v after reading: $!" 0 1 1
224 1 $o->{ILSM}{AUTO_INCLUDE} = $insert . "\n" . $o->{ILSM}{AUTO_INCLUDE};
225 }
226 #} # close scope
227 }
228
229 12 ▶ if($config_options->{AUTO_INCLUDE}) {$o->{ILSM}{AUTO_INCLUDE} .= $config_options->{AUTO_INCLUDE} . "\n"}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"AUTO_INCLUDE"}) 6 6 12
230
231 12 ▶ if($config_options->{CC}) {$o->{ILSM}{MAKEFILE}{CC} = $config_options->{CC}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"CC"}) 1 11 12
232
233 12 ▶ if($config_options->{CCFLAGS}) {$o->{ILSM}{MAKEFILE}{CCFLAGS} = " " . $config_options->{CCFLAGS}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"CCFLAGS"}) 1 11 12
234
235 12 ▶ if($config_options->{CCFLAGSEX}) {$o->{ILSM}{MAKEFILE}{CCFLAGS} = $Config{ccflags} . " "
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"CCFLAGSEX"}) 0 12 12
236 0 . $config_options->{CCFLAGSEX}}
237
238 12 ▶ if(exists($config_options->{INC})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config_options->{'INC'}) { } 6 6 12
239 6 ▶ if(ref($config_options->{INC}) eq 'ARRAY') {$o->{ILSM}{MAKEFILE}{INC} = join ' ', @{$config_options->{INC}};}
Branch: 1 branch
BranchTrueFalseTotal
if (ref $config_options->{'INC'} eq 'ARRAY') { } 0 6 6
240 6 else {$o->{ILSM}{MAKEFILE}{INC} = $config_options->{INC};}
241 }
242 6 else {$o->{ILSM}{MAKEFILE}{INC} = ''}
243
244 12 my $uncorrupted_inc = $o->{ILSM}{MAKEFILE}{INC};
245
246 12 ▶ if($config_options->{LD}) {$o->{ILSM}{MAKEFILE}{LD} = " " . $config_options->{LD}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"LD"}) 1 11 12
247
248 12 ▶ if($config_options->{PREREQ_PM}) {$o->{ILSM}{MAKEFILE}{PREREQ_PM} = $config_options->{PREREQ_PM}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"PREREQ_PM"}) 1 11 12
249
250 12 ▶ if($config_options->{LDDLFLAGS}) {$o->{ILSM}{MAKEFILE}{LDDLFLAGS} = " " . $config_options->{LDDLFLAGS}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"LDDLFLAGS"}) 1 11 12
251
252 # Here, we'll add the MAKE parameter to $o->{ILSM}{MAKEFILE}{MAKE} ... which
253 # could be useful (given that recent versions of Extutils::MakeMaker now recognise it):
254 12 ▶ if($config_options->{MAKE}) {$o->{ILSM}{MAKEFILE}{MAKE} = $config_options->{MAKE}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"MAKE"}) 1 11 12
255
256 12 ▶ if($config_options->{MYEXTLIB}) {$o->{ILSM}{MAKEFILE}{MYEXTLIB} = " " . $config_options->{MYEXTLIB}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"MYEXTLIB"}) 1 11 12
257
258 12 ▶ if($config_options->{OPTIMIZE}) {$o->{ILSM}{MAKEFILE}{OPTIMIZE} = " " . $config_options->{OPTIMIZE}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"OPTIMIZE"}) 1 11 12
259
260 12 ▶ if($config_options->{USING}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"USING"}) 0 12 12
261 0 my $val = $config_options->{USING};
262 0 ▶ if(ref($val) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq 'ARRAY') { } 0 0 0
263 0 $o->{CONFIG}{USING} = $val;
264 }
265 else {
266 0 $o->{CONFIG}{USING} = [$val];
267 }
268 0 Inline::push_overrides($o);
269 }
270
271 12 ▶ if(!$need_inline_h) {$o->{ILSM}{AUTO_INCLUDE} =~ s/#include "INLINE\.h"//i}
Branch: 1 branch
BranchTrueFalseTotal
unless ($need_inline_h) 5 7 12
272
273 12 my $portable;
274 {
275 11 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
276 12 ▶ $portable = uc($config_options->{WRITE_MAKEFILE_PL}) eq 'P' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
uc $config_options->{'WRITE_MAKEFILE_PL'} eq 'P' ? : 1 11 12
277 }
278
279 12 _build($o, $need_inline_h, $portable);
280
281 12 ▶ if($config_options->{WRITE_MAKEFILE_PL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"WRITE_MAKEFILE_PL"}) 4 8 12
282 4 $o->{ILSM}{MAKEFILE}{INC}= $uncorrupted_inc; # Otherwise cwd is automatically added.
283 4 $o->{ILSM}{MAKEFILE}{TYPEMAPS}= \@uncorrupted_typemaps; # Otherwise standard perl typemap is added.
284 4 ▶ if($config_options->{VERSION}) {$o->{API}{version} = $config_options->{VERSION}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{'VERSION'}) { } 4 0 4
285 0 else {warn "'VERSION' being set to '0.00' in the Makefile.PL. Did you supply a correct version number to cpp2xs() ?"}
286 4 print "Writing Makefile.PL in the ", $o->{API}{build_dir}, " directory\n";
287 4 $o->call('write_Makefile_PL', 'Build Glue 3');
288 4 ▶ if(uc($config_options->{WRITE_MAKEFILE_PL}) eq 'P') { # Need to rewrite the genrated Makefile.PL
Branch: 1 branch
BranchTrueFalseTotal
if (uc $config_options->{"WRITE_MAKEFILE_PL"} eq "P") 1 3 4
289 1 rewrite_makefile_pl($build_dir);
290 }
291 }
292
293 12 ▶ if($config_options->{WRITE_PM}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"WRITE_PM"}) 4 8 12
294 4 ▶ if($config_options->{VERSION}) {$o->{API}{version} = $config_options->{VERSION}}
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{'VERSION'}) { } 4 0 4
295 else {
296 0 warn "'\$VERSION' being set to '0.00' in ", $o->{API}{modfname}, ".pm. Did you supply a correct version number to cpp2xs() ?";
297 0 $o->{API}{version} = '0.00';
298 }
299 4 _write_pm($o);
300 }
301
302 12 ▶ if($config_options->{MANIF}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"MANIF"}) 2 10 12
303 2 _write_manifest($modfname, $build_dir, $config_options, $need_inline_h);
304 }
305 }
306
307 ##=========================##
308
309 sub _build {
310 12 ▶ my $o = shift;
Subroutine _build: called CC=9 SCAR=22.0
311 12 my $need_inline_headers = shift;
312 12 my $portable = shift;
313 12 my $save;
314
315 12 $o->call('preprocess', 'Build Preprocess');
316 12 $o->call('parse', 'Build Parse');
317
318 12 my $modfname = $o->{API}{modfname};
319 12 my $build_dir = $o->{API}{build_dir};
320
321 12 print "Writing ${modfname}.xs in the $build_dir directory\n";
322 12 ▶ if($portable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($portable) 1 11 12
323 1 $save = $o->{ILSM}{AUTO_INCLUDE};
324 1 my @s = split /\n/, $save;
325 1 ▶ open WRA, '>', "$build_dir/auto_include.in" or die "Couldn't open $build_dir/auto_include.in for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open WRA, ">", "$build_dir/auto_include.in" or die "Couldn't open $build_dir/auto_include.in for writing: $!" 0 1 1
326 1 for my $l(@s) {
327 19 ▶ $l = '' if($l =~ /__INLINE_CPP_STANDARD_HEADERS/ || $l =~ /__INLINE_CPP_NAMESPACE_STD/);
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /__INLINE_CPP_STANDARD_HEADERS/ or $l =~ /__INLINE_CPP_NAMESPACE_STD/ 2 17 19
Condition100%3/3
$l =~ /__INLINE_CPP_STANDARD_HEADERS/ or $l =~ /__INLINE_CPP_NAMESPACE_STD/
l!l&&r!l&&!r
1117
MC/DC100%2/2
$l =~ /__INLINE_CPP_STANDARD_HEADERS/ or $l =~ /__INLINE_CPP_NAMESPACE_STD/
$l =~ /__INLINE_CPP_STANDARD_HEADERS/ $l =~ /__INLINE_CPP_NAMESPACE_STD/
Truth table100%3/3
A or B
A= $l =~ /__INLINE_CPP_STANDARD_HEADERS/B= $l =~ /__INLINE_CPP_NAMESPACE_STD/
ABresult
1X1
011
000
328 19 print WRA $l, "\n";
329 }
330 1 ▶ close WRA or die "Couldn't close $build_dir/auto_include.in after writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
close WRA or die "Couldn't close $build_dir/auto_include.in after writing: $!" 0 1 1
331 1 $o->{ILSM}{AUTO_INCLUDE} = "\n#include \"icppdefines.h\"\n";;
332 }
333
334 12 $Inline::CPP::Config::cpp_flavor_defs = ''; # Otherwise we find one more occurrence of
335 # $Inline::CPP::Config::cpp_flavor_defs in the generated XS
336 # file than we want.
337 12 $o->call('write_XS', 'Build Glue 1');
338 12 ▶ $o->{ILSM}{AUTO_INCLUDE} = $save if $portable;
Branch: 1 branch
BranchTrueFalseTotal
if $portable 1 11 12
339
340 12 ▶ if($need_inline_headers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($need_inline_headers) 7 5 12
341 7 print "Writing INLINE.h in the ", $o->{API}{build_dir}, " directory\n";
342 7 $o->call('write_Inline_headers', 'Build Glue 2');
343 }
344
345 }
346
347 ##=========================##
348
349 sub _check_config_keys {
350 66 ▶ for(@allowable_config_keys) {
Subroutine _check_config_keys: called CC=3 SCAR=11.0
351 913 ▶ return 1 if $_ eq $_[0]; # it's a valid config option
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $_[0] 65 848 913
352 }
353 1 return 0; # it's an invalid config option
354 }
355
356 ##=========================##
357
358 sub _write_pm {
359 4 ▶ my $o = shift;
Subroutine _write_pm: called CC=25 SCAR=32.5
360 4 my $offset = 4;
361 4 my $max = 100;
362 4 my $length = $offset;
363 4 my @use;
364
365 4 ▶ if($config_options->{USE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"USE"}) 2 2 4
366 die "Value supplied to config option USE must be an array reference"
367 2 ▶ if ref($config_options->{USE}) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $config_options->{"USE"} ne "ARRAY" 0 2 2
368 2 @use = @{$config_options->{USE}};
369 }
370
371 4 ▶ open(WR, '>', $o->{API}{build_dir} . '/' . $o->{API}{modfname} . ".pm")
Branch: 1 branch
BranchTrueFalseTotal
open WR, ">", $o->{"API"}{"build_dir"} . '/' . $o->{"API"}{"modfname"} . '.pm' or die "Couldn't create the .pm file: $!" 0 4 4
372 or die "Couldn't create the .pm file: $!";
373 4 print "Writing ", $o->{API}{modfname}, ".pm in the ", $o->{API}{build_dir}, " directory\n";
374 4 print WR "## This file generated by InlineX::CPP2XS (version ",
375 $InlineX::CPP2XS::VERSION, ") using Inline::CPP (version ", $Inline::CPP::VERSION, ")\n";
376 4 print WR "package ", $o->{API}{module}, ";\n";
377 4 for(@use) {
378 2 print WR "use ${_};\n";
379 }
380 4 print WR "\n";
381 4 print WR "require Exporter;\n*import = \\&Exporter::import;\nrequire DynaLoader;\n\n";
382 4 print WR "our \$VERSION = '", $o->{API}{version}, "';\n";
383 4 print WR "\$VERSION = eval \$VERSION;\n";
384 4 print WR "DynaLoader::bootstrap ", $o->{API}{module}, " \$VERSION;\n\n";
385
386 4 ▶ unless($config_options->{EXPORT_ALL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{'EXPORT_ALL'}) { } 1 3 4
387 3 print WR "\@", $o->{API}{module}, "::EXPORT = ();\n";
388 }
389 else {
390 1 print WR "\@", $o->{API}{module}, "::EXPORT = qw(\n";
391 1 for(@{$o->{ILSM}{parser}{data}{functions}}) {
392 # exclude function names that begin with a single underscore
393 8 ▶ if ($_ =~ /^_/ && $_ !~ /^__/) {next}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^_/ and not $_ =~ /^__/) 4 4 8
Condition100%3/3
$_ =~ /^_/ and not $_ =~ /^__/
!ll&&!rl&&r
314
MC/DC100%2/2
$_ =~ /^_/ and not $_ =~ /^__/
$_ =~ /^_/ not $_ =~ /^__/
Truth table100%3/3
A and not(B)
A= $_ =~ /^_/B= not $_ =~ /^__/
ABresult
0X0
100
111
394 4 my $l = length($_);
395 4 ▶ if($length + $l > $max) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length + $l > $max) 0 4 4
396 0 print WR "\n", " " x $offset, "$_ ";
397 0 $length = $offset + $l + 1;
398 }
399 4 ▶ if($length == $offset) {print WR " " x $offset, "$_ "}
Branch: 1 branch
BranchTrueFalseTotal
if ($length == $offset) { } 1 3 4
400 3 else {print WR "$_ " }
401 4 $length += $l + 1;
402 }
403 1 print WR "\n", " " x $offset, ");\n\n";
404 1 $length = $offset;
405 }
406
407 4 ▶ unless($config_options->{EXPORT_OK_ALL} || $config_options->{EXPORT_TAGS_ALL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{'EXPORT_OK_ALL'} or $config_options->{'EXPORT_TAGS_ALL'}) { } 3 1 4
Condition66%2/3
$config_options->{"EXPORT_OK_ALL"} or $config_options->{"EXPORT_TAGS_ALL"}
l!l&&r!l&&!r
301
MC/DC50%1/2
$config_options->{"EXPORT_OK_ALL"} or $config_options->{"EXPORT_TAGS_ALL"}
$config_options->{"EXPORT_OK_ALL"} $config_options->{"EXPORT_TAGS_ALL"}
Truth table66%2/3
A or B
A= $config_options->{"EXPORT_OK_ALL"}B= $config_options->{"EXPORT_TAGS_ALL"}
ABresult
1X1
011
000
408 1 print WR "\@", $o->{API}{module}, "::EXPORT_OK = ();\n\n";
409 }
410 else {
411 3 print WR "\@", $o->{API}{module}, "::EXPORT_OK = qw(\n";
412 3 for(@{$o->{ILSM}{parser}{data}{functions}}) {
413 # exclude function names that begin with a single underscore
414 30 ▶ if ($_ =~ /^_/ && $_ !~ /^__/) {next}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^_/ and not $_ =~ /^__/) 24 6 30
Condition100%3/3
$_ =~ /^_/ and not $_ =~ /^__/
!ll&&!rl&&r
5124
MC/DC100%2/2
$_ =~ /^_/ and not $_ =~ /^__/
$_ =~ /^_/ not $_ =~ /^__/
Truth table100%3/3
A and not(B)
A= $_ =~ /^_/B= not $_ =~ /^__/
ABresult
0X0
100
111
415 6 my $l = length($_);
416 6 ▶ if($length + $l > $max) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length + $l > $max) 0 6 6
417 0 print WR "\n", " " x $offset, "$_ ";
418 0 $length = $offset + $l + 1;
419 }
420 6 ▶ if($length == $offset) {print WR " " x $offset, "$_ "}
Branch: 1 branch
BranchTrueFalseTotal
if ($length == $offset) { } 3 3 6
421 3 else {print WR "$_ " }
422 6 $length += $l + 1;
423 }
424 3 print WR "\n", " " x $offset, ");\n\n";
425 3 $length = $offset;
426 }
427
428 4 ▶ if($config_options->{EXPORT_TAGS_ALL}){
Branch: 1 branch
BranchTrueFalseTotal
if ($config_options->{"EXPORT_TAGS_ALL"}) 1 3 4
429 1 print WR "\%", $o->{API}{module}, "::EXPORT_TAGS = (", $config_options->{EXPORT_TAGS_ALL}, " => [qw(\n";
430 1 for(@{$o->{ILSM}{parser}{data}{functions}}) {
431 # exclude function names that begin with a single underscore
432 8 ▶ if ($_ =~ /^_/ && $_ !~ /^__/) {next}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^_/ and not $_ =~ /^__/) 4 4 8
Condition100%3/3
$_ =~ /^_/ and not $_ =~ /^__/
!ll&&!rl&&r
314
MC/DC100%2/2
$_ =~ /^_/ and not $_ =~ /^__/
$_ =~ /^_/ not $_ =~ /^__/
Truth table100%3/3
A and not(B)
A= $_ =~ /^_/B= not $_ =~ /^__/
ABresult
0X0
100
111
433 4 my $l = length($_);
434 4 ▶ if($length + $l > $max) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length + $l > $max) 0 4 4
435 0 print WR "\n", " " x $offset, "$_ ";
436 0 $length = $offset + $l + 1;
437 }
438 4 ▶ if($length == $offset) {print WR " " x $offset, "$_ "}
Branch: 1 branch
BranchTrueFalseTotal
if ($length == $offset) { } 1 3 4
439 3 else {print WR "$_ " }
440 4 $length += $l + 1;
441 }
442 1 print WR "\n", " " x $offset, ")]);\n\n";
443 1 $length = $offset;
444 }
445
446 4 print WR "sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking\n\n";
447 4 print WR "1;\n";
448 4 ▶ close(WR) or die "Couldn't close the .pm file after writing to it: $!";
Branch: 1 branch
BranchTrueFalseTotal
close WR or die "Couldn't close the .pm file after writing to it: $!" 0 4 4
449 }
450
451 ##=========================##
452
453 sub rewrite_makefile_pl {
454 # This sub will get called if we want to write a portable Makefile.PL - ie iff
455 # WRITE_MAKEFILE_PL is set to 'p' or 'P'.
456 # Lines starting with '>>' are heredoc entries. (All occurrences of '>>' are
457 # removed before the heredoc gets written to file.)
458 1 ▶ my $bd = shift; # build directory
Subroutine rewrite_makefile_pl: called CC=13 SCAR=28.2
Pod undocumented
459
460 1 ▶ die "Couldn't rename $bd/Makefile.PL"
Branch: 1 branch
BranchTrueFalseTotal
unless rename "$bd/Makefile.PL", "$bd/Makefile.PL_first" 0 1 1
461 unless rename "$bd/Makefile.PL", "$bd/Makefile.PL_first";
462
463 # Use the cpp test script from Inline::CPP
464 1 my $test_cpp = <<' TEST_CPP';
465 >>#include <iostream>
466 >>int main(){
467 >> return 0;
468 >>}
469 >>
470 TEST_CPP
471
472 1 $test_cpp =~ s/>>//g;
473
474 1 ▶ open WRT, '>', "$bd/ilcpptest.cpp" or die "Couldn't open $bd/ilcpptest.cpp for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open WRT, ">", "$bd/ilcpptest.cpp" or die "Couldn't open $bd/ilcpptest.cpp for writing: $!" 0 1 1
475 1 print WRT $test_cpp;
476 1 ▶ close WRT or die "Couldn't close $bd/ilcpptest.cpp: $!";
Branch: 1 branch
BranchTrueFalseTotal
close WRT or die "Couldn't close $bd/ilcpptest.cpp: $!" 0 1 1
477
478
479 1 ▶ open RD, '<', "$bd/Makefile.PL_first" or die "Couldn't open $bd/Makefile.PL_first for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open RD, "<", "$bd/Makefile.PL_first" or die "Couldn't open $bd/Makefile.PL_first for reading: $!" 0 1 1
480 1 ▶ open WR, '>', "$bd/Makefile.PL" or die "Couldn't open Makefile.PL for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open WR, ">", "$bd/Makefile.PL" or die "Couldn't open Makefile.PL for writing: $!" 0 1 1
481
482 1 my @make = <RD>;
483
484 1 my $insert = <<' IN';
485 >>
486 >> my ($cc_guess, $libs_guess) = _guess();
487 >>
488 >> my $iostream = which_iostream($cc_guess);
489 >>
490 >> my $standard;
491 >> if($iostream eq '<iostream>' ) {
492 >> $standard = <<'STD';
493 >>
494 >>#define __INLINE_CPP_STANDARD_HEADERS 1
495 >>#define __INLINE_CPP_NAMESPACE_STD 1
496 >>
497 >>STD
498 >> }
499 >> else {$standard = ''}
500 >>
501 >>write_icppdefines_h($standard);
502 >>
503 >>sub _guess {
504 >>
505 >> my $cc_guess;
506 >> my $libs_guess;
507 >>
508 >> if($Config{osname} eq 'darwin'){
509 >> my $stdlib_query =
510 >> 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p )';
511 >> my $stdcpp =
512 >> `$stdlib_query`; + $stdcpp =~ s/^(.*)\/[^\/]+$/$1/;
513 >> $cc_guess = 'g++';
514 >> $libs_guess = "-L$stdcpp -lstdc++";
515 >> }
516 >> elsif (
517 >> $Config{osname} ne 'darwin' and
518 >> $Config{gccversion} and
519 >> $Config{cc} =~ m#\bgcc\b[^/]*$# ) {
520 >> ($cc_guess = $Config{cc}) =~ s[\bgcc\b([^/]*)$(?:)][g\+\+$1];
521 >> $libs_guess = '-lstdc++';
522 >> }
523 >> elsif ($Config{osname} =~ m/^MSWin/) {
524 >> $cc_guess = 'cl -TP -EHsc';
525 >> $libs_guess = 'MSVCIRT.LIB';
526 >> }
527 >> elsif ($Config{osname} eq 'linux') {
528 >> $cc_guess = 'g++';
529 >> $libs_guess = '-lstdc++';
530 >> }
531 >> # Dragonfly patch is just a hunch...
532 >> elsif( $Config{osname} eq 'netbsd' || $Config{osname} eq 'dragonfly' ) {
533 >> $cc_guess = 'g++';
534 >> $libs_guess = '-lstdc++ -lgcc_s';
535 >> }
536 >> elsif ($Config{osname} eq 'cygwin') {
537 >> $cc_guess = 'g++';
538 >> $libs_guess = '-lstdc++';
539 >> }
540 >> elsif ($Config{osname} eq 'solaris' or $Config{osname} eq 'SunOS') {
541 >> if(
542 >> $Config{cc} eq 'gcc' ||( exists( $Config{gccversion} ) && $Config{gccversion} > 0)) {
543 >> $cc_guess = 'g++';
544 >> $libs_guess = '-lstdc++';
545 >> }
546 >> else {
547 >> $cc_guess = 'CC';
548 >> $libs_guess ='-lCrun';
549 >> }
550 >> }
551 >> elsif ($Config{osname} eq 'mirbsd') {
552 >> my $stdlib_query =
553 >> 'find /usr/lib/gcc -name "libstdc++*" | grep $( uname -p ) | head -1';
554 >> my $stdcpp =
555 >> `$stdlib_query`; + $stdcpp =~ s/^(.*)\/[^\/]+$/$1/;
556 >> $cc_guess = 'g++';
557 >> $libs_guess = "-L$stdcpp -lstdc++ -lc -lgcc_s";
558 >> }
559 >> # Sane defaults for other (probably unix-like) operating systems
560 >> else {
561 >> $cc_guess = 'g++';
562 >> $libs_guess = '-lstdc++';
563 >> }
564 >>
565 >> return ($cc_guess, $libs_guess);
566 >>}
567 >>
568 >>sub which_iostream {
569 >>
570 >> my $cpp_compiler = shift;
571 >>
572 >> my $result;
573 >> if( $cpp_compiler =~ m/^cl/ ) {
574 >> $result = system(
575 >> qq{$cpp_compiler -Fe:ilcpptest.exe } .
576 >> qq{ilcpptest.cpp}
577 >> );
578 >> }
579 >> else {
580 >> $result = system(
581 >> qq{$cpp_compiler -o ilcpptest.exe } .
582 >> qq{ilcpptest.cpp}
583 >> );
584 >> }
585 >>
586 >> if( $result != 0 ) {
587 >> # Compiling with <iostream> failed, so we'll assume .h headers.
588 >> $result = '<iostream.h>';
589 >> }
590 >> else {
591 >> # Compiling with <iostream> succeeded.
592 >> $result = '<iostream>';
593 >> unlink "ilcpptest.exe" or warn $!; # Unlink the executable.
594 >> }
595 >> return $result;
596 >>}
597 >>
598 >>sub write_icppdefines_h {
599 >>
600 >> my $standard = shift;
601 >>
602 >> open RDA, '<', 'auto_include.in' or die "Couldn't open auto_include.in for reading: $!";
603 >> my @auto = <RDA>;
604 >> close RDA or die "Couldn't close auto_include.in after reading: $!";
605 >>
606 >> my $auto = join '', @auto;
607 >>
608 >> if($standard) {$auto =~ s/<iostream.h>/<iostream>/g}
609 >> else {$auto =~ s/<iostream>/<iostream.h>/g}
610 >>
611 >> open WRXS, '>', "icppdefines.h" or die "Couldn't open icppdefines.h for writing: $!";
612 >>
613 >> print WRXS "\n/* This file generated by the Makefile.PL */\n\n";
614 >> print WRXS $standard;
615 >> print WRXS $auto;
616 >>
617 >> close WRXS or die "Couldn't close icppdefines.h: $!";
618 >>
619 >>}
620 >>
621 IN
622
623 1 $insert =~ s/>>//g;
624
625 1 $make[0] .= $insert;
626 1 for(@make) {
627 19 ▶ if($_ =~ /'LIBS' => '/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /'LIBS' => '/) 0 19 19
628 0 my @t = split /'LIBS' => /;
629 0 $t[1] =~ s/'/"/g;
630 0 $t[1] =~ s/"/\$libs_guess /;
631 0 $_ = join "'LIBS' => \"", @t;
632 }
633 19 ▶ if($_ =~ /'CC' =>/) {$_ = ' \'CC\' => "$cc_guess",' . "\n"}
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /'CC' =>/) 1 18 19
634 }
635
636 1 for(@make) {print WR $_}
637 1 ▶ close RD or die "Couldn't close $bd/Makefile.PL_first: $!";
Branch: 1 branch
BranchTrueFalseTotal
close RD or die "Couldn't close $bd/Makefile.PL_first: $!" 0 1 1
638 1 ▶ close WR or die "Couldn't close $bd/Makefile.PL: $!";
Branch: 1 branch
BranchTrueFalseTotal
close WR or die "Couldn't close $bd/Makefile.PL: $!" 0 1 1
639 1 ▶ unlink "$bd/Makefile.PL_first" or die "Couldn't unlink $bd/Makefile.PL_first: $!";
Branch: 1 branch
BranchTrueFalseTotal
unlink "$bd/Makefile.PL_first" or die "Couldn't unlink $bd/Makefile.PL_first: $!" 0 1 1
640 }
641
642 ##=========================##
643
644 sub _write_manifest {
645 2 ▶ my $m = shift; # name of pm and xs files
Subroutine _write_manifest: called CC=6 SCAR=18.3
646 2 my $bd = shift; # build directory
647 2 my $c = shift; # config options
648 2 my $ih = shift; # INLINE.h required ?
649
650 2 print "Writing the MANIFEST file in the $bd directory\n";
651
652 2 ▶ open WRM, '>', "$bd/MANIFEST" or die "Can't open MANIFEST for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open WRM, ">", "$bd/MANIFEST" or die "Can't open MANIFEST for writing: $!" 0 2 2
653 2 print WRM "MANIFEST\n";
654 2 ▶ if($c->{WRITE_PM}) {print WRM "$m.pm\n"}
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"WRITE_PM"}) 2 0 2
655 2 ▶ if($ih) {print WRM "INLINE.h\n"}
Branch: 1 branch
BranchTrueFalseTotal
if ($ih) 0 2 2
656 2 print WRM "$m.xs\nCPP.map\n";
657 2 ▶ if($c->{WRITE_MAKEFILE_PL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"WRITE_MAKEFILE_PL"}) 2 0 2
658 2 print WRM "Makefile.PL\n";
659 2 ▶ if(uc($c->{WRITE_MAKEFILE_PL}) eq 'P') {
Branch: 1 branch
BranchTrueFalseTotal
if (uc $c->{"WRITE_MAKEFILE_PL"} eq "P") 1 1 2
660 1 print WRM "auto_include.in\nilcpptest.cpp\n";
661 }
662 }
663 2 close WRM;
664 }
665
666 ##=========================##
667
668 ##=========================##
669
670 ##=========================##
671
672 ##=========================##
673
674 11 1;
675
676 __END__
↑ Summary