line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Build::File::Base; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
89218
|
use strict; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
234
|
|
4
|
10
|
|
|
10
|
|
37
|
use warnings; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
174
|
|
5
|
10
|
|
|
10
|
|
118
|
use 5.008001; |
|
10
|
|
|
|
|
26
|
|
6
|
10
|
|
|
10
|
|
42
|
use Carp (); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
132
|
|
7
|
10
|
|
|
10
|
|
4816
|
use File::Temp (); |
|
10
|
|
|
|
|
137296
|
|
|
10
|
|
|
|
|
218
|
|
8
|
10
|
|
|
10
|
|
64
|
use File::Basename (); |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
140
|
|
9
|
10
|
|
|
10
|
|
2984
|
use FFI::Build::Platform; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
505
|
|
10
|
10
|
|
|
10
|
|
57
|
use overload '""' => sub { $_[0]->path }; |
|
10
|
|
|
84
|
|
18
|
|
|
10
|
|
|
|
|
83
|
|
|
84
|
|
|
|
|
110214
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Base class for File::Build files |
13
|
|
|
|
|
|
|
our $VERSION = '0.11'; # VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
17
|
|
|
|
|
|
|
{ |
18
|
75
|
|
|
75
|
1
|
117333
|
my($class, $content, %config) = @_; |
19
|
|
|
|
|
|
|
|
20
|
75
|
|
50
|
|
|
461
|
my $base = $config{base} || 'ffi_build_'; |
21
|
75
|
|
|
|
|
204
|
my $dir = $config{dir}; |
22
|
75
|
|
|
|
|
143
|
my $build = $config{build}; |
23
|
75
|
|
66
|
|
|
300
|
my $platform = $config{platform} || FFI::Build::Platform->new; |
24
|
|
|
|
|
|
|
|
25
|
75
|
|
|
|
|
303
|
my $self = bless { |
26
|
|
|
|
|
|
|
platform => $platform, |
27
|
|
|
|
|
|
|
build => $build, |
28
|
|
|
|
|
|
|
}, $class; |
29
|
|
|
|
|
|
|
|
30
|
75
|
100
|
|
|
|
317
|
if(!defined $content) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
31
|
|
|
|
|
|
|
{ |
32
|
1
|
|
|
|
|
150
|
Carp::croak("content is required"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif(ref($content) eq 'ARRAY') |
35
|
|
|
|
|
|
|
{ |
36
|
37
|
|
|
|
|
1002
|
$self->{path} = File::Spec->catfile(@$content); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif(ref($content) eq 'SCALAR') |
39
|
|
|
|
|
|
|
{ |
40
|
7
|
|
|
|
|
9
|
my @args; |
41
|
7
|
|
|
|
|
25
|
push @args, "${base}XXXXXX"; |
42
|
7
|
50
|
|
|
|
20
|
push @args, DIR => $dir if $dir; |
43
|
7
|
|
|
|
|
45
|
push @args, SUFFIX => $self->default_suffix; |
44
|
|
|
|
|
|
|
|
45
|
7
|
|
|
|
|
44
|
my($fh, $filename) = File::Temp::tempfile(@args); |
46
|
|
|
|
|
|
|
|
47
|
7
|
|
|
|
|
2608
|
binmode( $fh, $self->default_encoding ); |
48
|
7
|
|
|
|
|
83
|
print $fh $$content; |
49
|
7
|
|
|
|
|
234
|
close $fh; |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
84
|
$self->{path} = $filename; |
52
|
7
|
|
|
|
|
36
|
$self->{temp} = 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif(ref($content) eq '') |
55
|
|
|
|
|
|
|
{ |
56
|
30
|
|
|
|
|
135
|
$self->{path} = $content; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
74
|
50
|
|
|
|
256
|
if($self->platform->osname eq 'MSWin32') |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
|
|
0
|
$self->{native} = File::Spec->catfile($self->{path}); |
62
|
0
|
|
|
|
|
0
|
$self->{path} =~ s{\\}{/}g; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
74
|
|
|
|
|
338
|
$self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
1
|
0
|
sub default_suffix { die "must define a default extension in subclass" } |
70
|
0
|
|
|
0
|
1
|
0
|
sub default_encoding { die "must define an encoding" } |
71
|
0
|
|
|
0
|
1
|
0
|
sub accept_suffix { () } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
205
|
|
|
205
|
1
|
3971
|
sub path { shift->{path} } |
75
|
20
|
|
|
20
|
1
|
2286
|
sub basename { File::Basename::basename shift->{path} } |
76
|
51
|
|
|
51
|
1
|
4746
|
sub dirname { File::Basename::dirname shift->{path} } |
77
|
3
|
|
|
3
|
1
|
14
|
sub is_temp { shift->{temp} } |
78
|
174
|
|
|
174
|
1
|
745
|
sub platform { shift->{platform} } |
79
|
90
|
|
|
90
|
1
|
766
|
sub build { shift->{build} } |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub native { |
83
|
2
|
|
|
2
|
1
|
557
|
my($self) = @_; |
84
|
|
|
|
|
|
|
$self->platform->osname eq 'MSWin32' |
85
|
|
|
|
|
|
|
? $self->{native} |
86
|
2
|
50
|
|
|
|
4
|
: $self->{path}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub slurp |
91
|
|
|
|
|
|
|
{ |
92
|
4
|
|
|
4
|
1
|
768
|
my($self) = @_; |
93
|
4
|
|
|
|
|
8
|
my $fh; |
94
|
4
|
50
|
|
|
|
19
|
open($fh, '<', $self->path) || Carp::croak "Error opening @{[ $self->path ]} for read $!"; |
|
0
|
|
|
|
|
0
|
|
95
|
4
|
|
|
|
|
32
|
binmode($fh, $self->default_encoding); |
96
|
4
|
|
|
|
|
37
|
my $content = do { local $/; <$fh> }; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
102
|
|
97
|
4
|
|
|
|
|
35
|
close $fh; |
98
|
4
|
|
|
|
|
32
|
$content; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub keep |
103
|
|
|
|
|
|
|
{ |
104
|
1
|
|
|
1
|
1
|
9
|
delete shift->{temp}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub build_item |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
0
|
1
|
0
|
Carp::croak("Not implemented!"); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub needs_rebuild |
115
|
|
|
|
|
|
|
{ |
116
|
0
|
|
|
0
|
1
|
0
|
my($self, @source) = @_; |
117
|
|
|
|
|
|
|
# if the target doesn't exist, then we definitely |
118
|
|
|
|
|
|
|
# need a rebuild. |
119
|
0
|
0
|
|
|
|
0
|
return 1 unless -f $self->path; |
120
|
0
|
|
|
|
|
0
|
my $target_time = [stat $self->path]->[9]; |
121
|
0
|
|
|
|
|
0
|
foreach my $source (@source) |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
|
|
0
|
my $source_time = [stat "$source"]->[9]; |
124
|
0
|
0
|
|
|
|
0
|
return 1 if $source_time > $target_time; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
0
|
return 0; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub ld |
131
|
|
|
|
|
|
|
{ |
132
|
22
|
|
|
22
|
1
|
98
|
return undef; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub DESTROY |
136
|
|
|
|
|
|
|
{ |
137
|
37
|
|
|
37
|
|
11883
|
my($self) = @_; |
138
|
|
|
|
|
|
|
|
139
|
37
|
100
|
|
|
|
730
|
if($self->{temp}) |
140
|
|
|
|
|
|
|
{ |
141
|
6
|
|
|
|
|
95
|
unlink($self->path); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |