line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FFI::Build::File::C; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
223309
|
use strict; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
320
|
|
4
|
10
|
|
|
10
|
|
54
|
use warnings; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
263
|
|
5
|
10
|
|
|
10
|
|
188
|
use 5.008004; |
|
10
|
|
|
|
|
39
|
|
6
|
10
|
|
|
10
|
|
442
|
use parent qw( FFI::Build::File::Base ); |
|
10
|
|
|
|
|
340
|
|
|
10
|
|
|
|
|
73
|
|
7
|
10
|
|
|
10
|
|
710
|
use constant default_suffix => '.c'; |
|
10
|
|
|
|
|
112
|
|
|
10
|
|
|
|
|
756
|
|
8
|
10
|
|
|
10
|
|
61
|
use constant default_encoding => ':utf8'; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
452
|
|
9
|
10
|
|
|
10
|
|
67
|
use Capture::Tiny (); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
169
|
|
10
|
10
|
|
|
10
|
|
52
|
use File::Path (); |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
188
|
|
11
|
10
|
|
|
10
|
|
3768
|
use FFI::Build::File::Object; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
11842
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Class to track C source file in FFI::Build |
14
|
|
|
|
|
|
|
our $VERSION = '2.06_01'; # TRIAL VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub accept_suffix |
18
|
|
|
|
|
|
|
{ |
19
|
73
|
|
|
73
|
1
|
326
|
(qr/\.(c|i)$/) |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub build_item |
23
|
|
|
|
|
|
|
{ |
24
|
32
|
|
|
32
|
1
|
119
|
my($self) = @_; |
25
|
|
|
|
|
|
|
|
26
|
32
|
|
|
|
|
193
|
my $oname = $self->basename; |
27
|
32
|
|
|
|
|
420
|
$oname =~ s/\.(c(xx|pp)|i)?$//; |
28
|
32
|
|
|
|
|
171
|
$oname .= $self->platform->object_suffix; |
29
|
|
|
|
|
|
|
|
30
|
32
|
|
|
|
|
156
|
my $buildname = '_build'; |
31
|
32
|
100
|
|
|
|
184
|
$buildname = $self->build->buildname if $self->build; |
32
|
|
|
|
|
|
|
|
33
|
32
|
|
|
|
|
218
|
my $object = FFI::Build::File::Object->new( |
34
|
|
|
|
|
|
|
[ $self->dirname, $buildname, $oname ], |
35
|
|
|
|
|
|
|
platform => $self->platform, |
36
|
|
|
|
|
|
|
build => $self->build, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
32
|
50
|
33
|
|
|
160
|
return $object if -f $object->path && !$object->needs_rebuild($self->_deps); |
40
|
|
|
|
|
|
|
|
41
|
32
|
|
|
|
|
215
|
File::Path::mkpath($object->dirname, { verbose => 0, mode => oct(700) }); |
42
|
|
|
|
|
|
|
|
43
|
32
|
|
|
|
|
318
|
my @cmd = ( |
44
|
|
|
|
|
|
|
$self->_base_args, |
45
|
|
|
|
|
|
|
-c => $self->path, |
46
|
|
|
|
|
|
|
$self->platform->flag_object_output($object->path), |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my($out, $exit) = Capture::Tiny::capture_merged(sub { |
50
|
32
|
|
|
32
|
|
38723
|
$self->platform->run(@cmd); |
51
|
32
|
|
|
|
|
1604
|
}); |
52
|
|
|
|
|
|
|
|
53
|
32
|
100
|
66
|
|
|
52414
|
if($exit || !-f $object->path) |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
|
|
52
|
print $out; |
56
|
1
|
|
|
|
|
25
|
die "error building $object from $self"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
elsif($self->build && $self->build->verbose >= 2) |
59
|
|
|
|
|
|
|
{ |
60
|
16
|
|
|
|
|
928
|
print $out; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif($self->build && $self->build->verbose >= 1) |
63
|
|
|
|
|
|
|
{ |
64
|
11
|
|
|
|
|
74
|
print "CC @{[ $self->path ]}\n"; |
|
11
|
|
|
|
|
88
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
31
|
|
|
|
|
12392
|
$object; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub cc |
71
|
|
|
|
|
|
|
{ |
72
|
31
|
|
|
31
|
0
|
83
|
my($self) = @_; |
73
|
31
|
|
|
|
|
108
|
$self->platform->cc; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _base_args |
77
|
|
|
|
|
|
|
{ |
78
|
34
|
|
|
34
|
|
125
|
my($self) = @_; |
79
|
34
|
|
|
|
|
165
|
my @cmd = ($self->cc); |
80
|
34
|
100
|
|
|
|
1187
|
push @cmd, $self->build->cflags_I if $self->build; |
81
|
34
|
|
|
|
|
131
|
push @cmd, $self->platform->ccflags; |
82
|
34
|
100
|
|
|
|
143
|
push @cmd, @{ $self->build->cflags } if $self->build; |
|
30
|
|
|
|
|
104
|
|
83
|
34
|
|
|
|
|
178
|
@cmd; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _base_args_cpp |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
0
|
|
0
|
my($self) = @_; |
89
|
0
|
|
|
|
|
0
|
my @cmd = ($self->platform->cpp); |
90
|
0
|
0
|
|
|
|
0
|
push @cmd, $self->build->cflags_I if $self->build; |
91
|
0
|
|
|
|
|
0
|
push @cmd, grep /^-[DI]/, $self->platform->ccflags; |
92
|
0
|
0
|
|
|
|
0
|
push @cmd, grep /^-D/, @{ $self->build->cflags } if $self->build; |
|
0
|
|
|
|
|
0
|
|
93
|
0
|
|
|
|
|
0
|
@cmd; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub build_item_cpp |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
0
|
my $oname = $self->basename; |
101
|
0
|
|
|
|
|
0
|
$oname =~ s/\.(c(xx|pp)|i)$?$//; |
102
|
0
|
|
|
|
|
0
|
$oname .= '.i'; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
my $buildname = '_build'; |
105
|
0
|
0
|
|
|
|
0
|
$buildname = $self->build->buildname if $self->build; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
my $ifile = FFI::Build::File::C->new( |
108
|
|
|
|
|
|
|
[ $self->dirname, $buildname, $oname ], |
109
|
|
|
|
|
|
|
platform => $self->platform, |
110
|
|
|
|
|
|
|
build => $self->build, |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
File::Path::mkpath($ifile->dirname, { verbose => 0, mode => oct(700) }); |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
my @cmd = ( |
116
|
|
|
|
|
|
|
$self->_base_args_cpp, |
117
|
|
|
|
|
|
|
$self->path, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my($out, $err, $exit) = Capture::Tiny::capture(sub { |
121
|
0
|
|
|
0
|
|
0
|
$self->platform->run(@cmd); |
122
|
0
|
|
|
|
|
0
|
}); |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
0
|
if($exit) |
125
|
|
|
|
|
|
|
{ |
126
|
0
|
0
|
0
|
|
|
0
|
print "[out]\n$out\n" if defined $out && $out ne ''; |
127
|
0
|
0
|
0
|
|
|
0
|
print "[err]\n$err\n" if defined $err && $err ne ''; |
128
|
0
|
|
|
|
|
0
|
die "error building $ifile from $self"; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
else |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
|
|
|
|
0
|
my $fh; |
133
|
0
|
|
|
|
|
0
|
open($fh, '>', $ifile->path); |
134
|
0
|
|
|
|
|
0
|
print $fh $out; |
135
|
0
|
|
|
|
|
0
|
close $fh; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
0
|
$ifile; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _deps |
142
|
|
|
|
|
|
|
{ |
143
|
2
|
|
|
2
|
|
33
|
my($self) = @_; |
144
|
|
|
|
|
|
|
|
145
|
2
|
50
|
|
|
|
10
|
return $self->path unless $self->platform->cc_mm_works; |
146
|
|
|
|
|
|
|
|
147
|
2
|
|
|
|
|
98
|
my @cmd = ( |
148
|
|
|
|
|
|
|
$self->_base_args, |
149
|
|
|
|
|
|
|
'-MM', |
150
|
|
|
|
|
|
|
$self->path, |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my($out,$err,$exit) = Capture::Tiny::capture(sub { |
154
|
2
|
|
|
2
|
|
2653
|
$self->platform->run(@cmd); |
155
|
2
|
|
|
|
|
188
|
}); |
156
|
|
|
|
|
|
|
|
157
|
2
|
50
|
|
|
|
2578
|
if($exit) |
158
|
|
|
|
|
|
|
{ |
159
|
0
|
|
|
|
|
0
|
print $out; |
160
|
0
|
|
|
|
|
0
|
print $err; |
161
|
0
|
|
|
|
|
0
|
warn "error computing dependencies for $self"; |
162
|
0
|
|
|
|
|
0
|
return ($self->path); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else |
165
|
|
|
|
|
|
|
{ |
166
|
2
|
|
|
|
|
55
|
$out =~ s/^\+.*\n//; # remove the command line |
167
|
|
|
|
|
|
|
# which on windows could have an confusing : |
168
|
2
|
|
|
|
|
28
|
my(undef, $deps) = split /:/, $out, 2; |
169
|
2
|
|
|
|
|
28
|
$deps =~ s/^\s+//; |
170
|
2
|
|
|
|
|
29
|
$deps =~ s/\s+$//; |
171
|
2
|
|
|
|
|
100
|
return grep !/^\\$/, split /\s+/, $deps; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
__END__ |