| 1 | package FFI::Probe::Runner::Builder; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Capture::Tiny qw( capture_merged ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Text::ParseWords (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use FFI::Build::Platform; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # ABSTRACT: Probe runner builder for FFI | ||||||||||||||||||||||||||||
| 12 | 3 | our $VERSION = '2.12'; # VERSION | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub new | ||||||||||||||||||||||||||||
| 16 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 1 | my($class, %args) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | $args{dir} ||= 'blib/lib/auto/share/dist/FFI-Platypus/probe'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"dir"} ||= "blib/lib/auto/share/dist/FFI-Platypus/probe"
MC/DC0%0/1
$args{"dir"} ||= "blib/lib/auto/share/dist/FFI-Platypus/probe"
$args{"dir"}
Truth table50%1/2
A
A= $args{"dir"}
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | my $platform = FFI::Build::Platform->new; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | my $self = bless { | ||||||||||||||||||||||||||||
| 24 | dir => $args{dir}, | ||||||||||||||||||||||||||||
| 25 | platform => $platform, | ||||||||||||||||||||||||||||
| 26 | # we don't use the platform ccflags, etc because they are geared | ||||||||||||||||||||||||||||
| 27 | # for building dynamic libs not exes | ||||||||||||||||||||||||||||
| 28 | cc => [$platform->shellwords($Config{cc})], | ||||||||||||||||||||||||||||
| 29 | ld => [$platform->shellwords($Config{ld})], | ||||||||||||||||||||||||||||
| 30 | ccflags => [$platform->shellwords($Config{ccflags})], | ||||||||||||||||||||||||||||
| 31 | optimize => [$platform->shellwords($Config{optimize})], | ||||||||||||||||||||||||||||
| 32 | ldflags => [$platform->shellwords($Config{ldflags})], | ||||||||||||||||||||||||||||
| 33 | libs => | ||||||||||||||||||||||||||||
| 34 | $^O eq 'MSWin32' | ||||||||||||||||||||||||||||
| 35 | ? [[]] | ||||||||||||||||||||||||||||
| 36 | 1 | ▶ | : [['-ldl'], [], map { [$_] } grep !/^-ldl/, $platform->shellwords($Config{perllibs})], | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | }, $class; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | $self; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub dir | ||||||||||||||||||||||||||||
| 44 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
dir: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 5 | my($self, @subdirs) = @_; | |||||||||||||||||||||||||||
| 46 | 5 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | ▶ | if(@subdirs) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||
| 50 | 5 | require File::Spec; | |||||||||||||||||||||||||||
| 51 | 5 | $dir = File::Spec->catdir($dir, @subdirs); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 5 | ▶ | unless(-d $dir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 2 | require File::Path; | |||||||||||||||||||||||||||
| 57 | 2 | File::Path::mkpath($dir, 0, oct(755)); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 5 | $dir; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub cc { shift->{cc} } | ||||||||||||||||||||||||||
|
Subroutine
cc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub ccflags { shift->{ccflags} } | ||||||||||||||||||||||||||
|
Subroutine
ccflags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 1 | ▶ | sub optimize { shift->{optimize} } | ||||||||||||||||||||||||||
|
Subroutine
optimize: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 7 | ▶ | sub ld { shift->{ld} } | ||||||||||||||||||||||||||
|
Subroutine
ld: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 7 | ▶ | sub ldflags { shift->{ldflags} } | ||||||||||||||||||||||||||
|
Subroutine
ldflags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | sub libs { shift->{libs} } | ||||||||||||||||||||||||||
|
Subroutine
libs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub file | ||||||||||||||||||||||||||||
| 72 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 4 | my($self, @sub) = @_; | |||||||||||||||||||||||||||
| 74 | 4 | ▶ | @sub >= 1 or die 'usage: $builder->file([@subdirs], $filename)'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 4 | my $filename = pop @sub; | |||||||||||||||||||||||||||
| 76 | 4 | require File::Spec; | |||||||||||||||||||||||||||
| 77 | 4 | File::Spec->catfile($self->dir(@sub), $filename); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 3 | my $source; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub exe | ||||||||||||||||||||||||||||
| 84 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
exe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 1 | my($self) = @_; | |||||||||||||||||||||||||||
| 86 | 1 | my $xfn = $self->file('bin', "dlrun$Config{exe_ext}"); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub source | ||||||||||||||||||||||||||||
| 91 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
source: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | unless($source) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | 1 | local $/; | |||||||||||||||||||||||||||
| 95 | 1 | $source = <DATA>; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | $source; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 3 | our $VERBOSE = !!$ENV{V}; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | sub extract | ||||||||||||||||||||||||||||
| 105 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
extract: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 1 | my($self) = @_; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # the source src/dlrun.c | ||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 1 | ▶ | print "XX src/dlrun.c\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 1 | my $fh; | |||||||||||||||||||||||||||
| 112 | 1 | my $fn = $self->file('src', 'dlrun.c'); | |||||||||||||||||||||||||||
| 113 | 1 | my $source = $self->source; | |||||||||||||||||||||||||||
| 114 | 1 | ▶ | open $fh, '>', $fn or die "unable to write $fn $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 1 | print $fh $source; | |||||||||||||||||||||||||||
| 116 | 1 | close $fh; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # the bin directory bin | ||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||
| 121 | 1 | ▶ | print "XX bin/\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 1 | $self->dir('bin'); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | sub run | ||||||||||||||||||||||||||||
| 129 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 130 | 2 | my($self, $type, @cmd) = @_; | |||||||||||||||||||||||||||
| 131 | 2 | ▶ | @cmd = map { ref $_ ? @$_ : $_ } @cmd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 2 | ▶ | my($out, $ret) = capture_merged { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 133 | 2 | $self->{platform}->run(@cmd); | |||||||||||||||||||||||||||
| 134 | 2 | }; | |||||||||||||||||||||||||||
| 135 | 2 | ▶ | if($ret) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||
| 137 | 0 | print STDERR $out; | |||||||||||||||||||||||||||
| 138 | 0 | die "$type failed"; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 2 | ▶ | print $out if $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 2 | $out; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub run_list | ||||||||||||||||||||||||||||
| 146 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
run_list: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 147 | 1 | my($self, $type, @commands) = @_; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 1 | my $log = ''; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 1 | foreach my $cmd (@commands) | |||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||
| 153 | 1 | ▶ | my($out, $ret) = capture_merged { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 154 | 1 | $self->{platform}->run(@$cmd); | |||||||||||||||||||||||||||
| 155 | 1 | }; | |||||||||||||||||||||||||||
| 156 | 1 | ▶ | if($VERBOSE) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||
| 158 | 1 | print $out; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | else | ||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||
| 162 | 0 | $log .= $out; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 1 | ▶ | return if !$ret; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | print $log; | |||||||||||||||||||||||||||
| 168 | 0 | die "$type failed"; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | sub build | ||||||||||||||||||||||||||||
| 173 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
build: called CC=12 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||
| 174 | 1 | my($self) = @_; | |||||||||||||||||||||||||||
| 175 | 1 | $self->extract; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # this should really be done in `new` but the build | ||||||||||||||||||||||||||||
| 178 | # scripts for FFI-Platypus edit the ldfalgs from there | ||||||||||||||||||||||||||||
| 179 | # so. Also this may actually belong in FFI::Build::Platform | ||||||||||||||||||||||||||||
| 180 | # which would resolve the problem. | ||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if($^O eq 'MSWin32' && $Config{ccname} eq 'cl') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O eq "MSWin32" and $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
MC/DC0%0/2
$^O eq "MSWin32" and $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
$^O eq "MSWin32"
$FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||
| 183 | $self->{ldflags} = [ | ||||||||||||||||||||||||||||
| 184 | grep !/^-nodefaultlib$/i, | ||||||||||||||||||||||||||||
| 185 | 0 | @{ $self->{ldflags} } | |||||||||||||||||||||||||||
| 186 | ]; | ||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 1 | my $cfn = $self->file('src', 'dlrun.c'); | |||||||||||||||||||||||||||
| 190 | 1 | my $ofn = $self->file('src', "dlrun$Config{obj_ext}"); | |||||||||||||||||||||||||||
| 191 | 1 | my $xfn = $self->exe; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # compile | ||||||||||||||||||||||||||||
| 194 | 1 | ▶ | print "CC src/dlrun.c\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | $self->run( | ||||||||||||||||||||||||||||
| 196 | compile => | ||||||||||||||||||||||||||||
| 197 | $self->cc, | ||||||||||||||||||||||||||||
| 198 | $self->ccflags, | ||||||||||||||||||||||||||||
| 199 | $self->optimize, | ||||||||||||||||||||||||||||
| 200 | '-c', | ||||||||||||||||||||||||||||
| 201 | 1 | $self->{platform}->flag_object_output($ofn), | |||||||||||||||||||||||||||
| 202 | $cfn, | ||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | # link | ||||||||||||||||||||||||||||
| 206 | 1 | ▶ | print "LD src/dlrun$Config{obj_ext}\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | $self->run_list(link => | ||||||||||||||||||||||||||||
| 208 | map { [ | ||||||||||||||||||||||||||||
| 209 | $self->ld, | ||||||||||||||||||||||||||||
| 210 | $self->ldflags, | ||||||||||||||||||||||||||||
| 211 | 7 | $self->{platform}->flag_exe_output($xfn), | |||||||||||||||||||||||||||
| 212 | $ofn, | ||||||||||||||||||||||||||||
| 213 | @$_ | ||||||||||||||||||||||||||||
| 214 | 1 | ] } @{ $self->libs }, | |||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | ## FIXME | ||||||||||||||||||||||||||||
| 218 | 1 | ▶ | if($^O eq 'MSWin32' && $Config{ccname} eq 'cl') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O eq "MSWin32" and $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
MC/DC0%0/2
$^O eq "MSWin32" and $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
$^O eq "MSWin32"
$FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $FFI::Probe::Runner::Builder::Config{"ccname"} eq "cl"
| |||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if(-f 'dlrun.exe' && ! -f $xfn) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f "dlrun.exe" and not -f $xfn
MC/DC0%0/2
-f "dlrun.exe" and not -f $xfn
-f "dlrun.exe"
not -f $xfn
Truth table0%0/3
A and not(B)
A= -f "dlrun.exe"B= not -f $xfn
| |||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||
| 222 | 0 | rename 'dlrun.exe', $xfn; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | # verify | ||||||||||||||||||||||||||||
| 227 | 1 | ▶ | print "VV bin/dlrun$Config{exe_ext}\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 1 | my $out = $self->run(verify => $xfn, 'verify', 'self'); | |||||||||||||||||||||||||||
| 229 | 1 | ▶ | if($out !~ /dlrun verify self ok/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||
| 231 | 0 | print $out; | |||||||||||||||||||||||||||
| 232 | 0 | die "verify failed string match"; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # remove object | ||||||||||||||||||||||||||||
| 236 | 1 | ▶ | print "UN src/dlrun$Config{obj_ext}\n" unless $VERBOSE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 1 | unlink $ofn; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 1 | $xfn; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 3 | 1; | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | =pod | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | =head1 NAME | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | FFI::Probe::Runner::Builder - Probe runner builder for FFI | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | =head1 VERSION | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | version 2.12 | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | use FFI::Probe::Runner::Builder; | ||||||||||||||||||||||||||||
| 259 | my $builder = FFI::Probe::Runner::Builder->new | ||||||||||||||||||||||||||||
| 260 | dir => "/foo/bar", | ||||||||||||||||||||||||||||
| 261 | ); | ||||||||||||||||||||||||||||
| 262 | my $exe = $builder->build; | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | This is a builder class for the FFI probe runner. It is mostly only of | ||||||||||||||||||||||||||||
| 267 | interest if you are hacking on L<FFI::Platypus> itself. | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | The interface may and will change over time without notice. Use in | ||||||||||||||||||||||||||||
| 270 | external dependencies at your own peril. | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head1 CONSTRUCTORS | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | =head2 new | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | my $builder = FFI::Probe::Runner::Builder->new(%args); | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | Create a new instance. | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =over 4 | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | =item dir | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | The root directory for where to place the probe runner files. | ||||||||||||||||||||||||||||
| 285 | Will be created if it doesn't already exist. The default | ||||||||||||||||||||||||||||
| 286 | makes sense for when L<FFI::Platypus> is being built. | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =back | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =head1 METHODS | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =head2 dir | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | my $dir = $builder->dir(@subdirs); | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | Returns a subdirectory from the builder root. Directory | ||||||||||||||||||||||||||||
| 297 | will be created if it doesn't already exist. | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | =head2 cc | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | my @cc = @{ $builder->cc }; | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | The C compiler to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =head2 ccflags | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | my @ccflags = @{ $builder->ccflags }; | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | The C compiler flags to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | =head2 optimize | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | The C optimize flags to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | =head2 ld | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | my @ld = @{ $builder->ld }; | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | The linker to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =head2 ldflags | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | my @ldflags = @{ $builder->ldflags }; | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | The linker flags to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | =head2 libs | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | my @libs = @{ $builder->libs }; | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | The library flags to use. Returned as an array reference so that it may be modified. | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | =head2 file | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | my $file = $builder->file(@subdirs, $filename); | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | Returns a file in a subdirectory from the builder root. | ||||||||||||||||||||||||||||
| 338 | Directory will be created if it doesn't already exist. | ||||||||||||||||||||||||||||
| 339 | File will not be created. | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =head2 exe | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | my $exe = $builder->exe; | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | The name of the executable, once it is built. | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | =head2 source | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | my $source = $builder->source; | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | The C source for the probe runner. | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | =head2 extract | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | $builder->extract; | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | Extract the source for the probe runner. | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | =head2 run | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | $builder->run($type, @command); | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Runs the given command. Dies if the command fails. | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =head2 run_list | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | $builder->run($type, \@command, \@command, ...); | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | Runs the given commands in order until one succeeds. | ||||||||||||||||||||||||||||
| 370 | Dies if they all fail. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =head2 build | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | my $exe = $builder->build; | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | Builds the probe runner. Returns the path to the executable. | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | Author: Graham Ollis E<lt>plicease@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | Contributors: | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | Bakkiaraj Murugesan (bakkiaraj) | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | Dylan Cali (calid) | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | pipcet | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | Zaki Mughal (zmughal) | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Fitz Elliott (felliott) | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | Vickenty Fesunov (vyf) | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | Gregor Herrmann (gregoa) | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | Shlomi Fish (shlomif) | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | Damyan Ivanov | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | Ilya Pavlov (Ilya33) | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | Petr Písař (ppisar) | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | Mohammad S Anwar (MANWAR) | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | Håkon Hægland (hakonhagland, HAKONH) | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | Meredith (merrilymeredith, MHOWARD) | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | Diab Jerius (DJERIUS) | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | Eric Brine (IKEGAMI) | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | szTheory | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | José Joaquín Atria (JJATRIA) | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | Pete Houston (openstrike, HOUSTON) | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | Lukas Mai (MAUKE) | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | This software is copyright (c) 2015-2022 by Graham Ollis. | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 429 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =cut | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | __DATA__ | ||||||||||||||||||||||||||||