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