| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SPVM::Builder::LibInfo; |
|
2
|
|
|
|
|
|
|
|
|
3
|
283
|
|
|
283
|
|
1941
|
use strict; |
|
|
283
|
|
|
|
|
618
|
|
|
|
283
|
|
|
|
|
8149
|
|
|
4
|
283
|
|
|
283
|
|
1468
|
use warnings; |
|
|
283
|
|
|
|
|
714
|
|
|
|
283
|
|
|
|
|
6364
|
|
|
5
|
283
|
|
|
283
|
|
2378
|
use Config; |
|
|
283
|
|
|
|
|
772
|
|
|
|
283
|
|
|
|
|
10150
|
|
|
6
|
283
|
|
|
283
|
|
1776
|
use Carp 'confess'; |
|
|
283
|
|
|
|
|
728
|
|
|
|
283
|
|
|
|
|
13599
|
|
|
7
|
283
|
|
|
283
|
|
2994
|
use File::Basename 'dirname'; |
|
|
283
|
|
|
|
|
3307
|
|
|
|
283
|
|
|
|
|
25639
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
283
|
|
|
283
|
|
2063
|
use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; |
|
|
283
|
|
|
0
|
|
705
|
|
|
|
283
|
|
|
0
|
|
2800
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Fields |
|
12
|
|
|
|
|
|
|
sub name { |
|
13
|
7
|
|
|
7
|
1
|
22
|
my $self = shift; |
|
14
|
7
|
100
|
|
|
|
44
|
if (@_) { |
|
15
|
3
|
|
|
|
|
28
|
$self->{name} = $_[0]; |
|
16
|
3
|
|
|
|
|
28
|
return $self; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
else { |
|
19
|
4
|
|
|
|
|
21
|
return $self->{name}; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub file { |
|
24
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
25
|
0
|
0
|
|
|
|
0
|
if (@_) { |
|
26
|
0
|
|
|
|
|
0
|
$self->{file} = $_[0]; |
|
27
|
0
|
|
|
|
|
0
|
return $self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
else { |
|
30
|
0
|
|
|
|
|
0
|
return $self->{file}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_static { |
|
35
|
10
|
|
|
10
|
1
|
28
|
my $self = shift; |
|
36
|
10
|
100
|
|
|
|
80
|
if (@_) { |
|
37
|
3
|
|
|
|
|
30
|
$self->{is_static} = $_[0]; |
|
38
|
3
|
|
|
|
|
15
|
return $self; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
7
|
|
|
|
|
182
|
return $self->{is_static}; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub is_abs { |
|
46
|
10
|
|
|
10
|
1
|
33
|
my $self = shift; |
|
47
|
10
|
100
|
|
|
|
45
|
if (@_) { |
|
48
|
3
|
|
|
|
|
27
|
$self->{is_abs} = $_[0]; |
|
49
|
3
|
|
|
|
|
18
|
return $self; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
else { |
|
52
|
7
|
|
|
|
|
39
|
return $self->{is_abs}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub static_option_cb { |
|
57
|
6
|
|
|
6
|
1
|
28
|
my $self = shift; |
|
58
|
6
|
100
|
|
|
|
30
|
if (@_) { |
|
59
|
3
|
|
|
|
|
26
|
$self->{static_option_cb} = $_[0]; |
|
60
|
3
|
|
|
|
|
21
|
return $self; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
else { |
|
63
|
3
|
|
|
|
|
32
|
return $self->{static_option_cb}; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Class Methods |
|
68
|
|
|
|
|
|
|
sub new { |
|
69
|
3
|
|
|
3
|
1
|
23
|
my $class = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
22
|
my $self = {@_}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
35
|
bless $self, $class; |
|
74
|
|
|
|
|
|
|
|
|
75
|
3
|
50
|
|
|
|
49
|
unless (defined $self->is_static) { |
|
76
|
3
|
|
|
|
|
24
|
$self->is_static(0); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
3
|
50
|
|
|
|
31
|
unless (defined $self->is_abs) { |
|
80
|
3
|
|
|
|
|
16
|
$self->is_abs(0); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
50
|
|
|
|
31
|
unless (defined $self->static_option_cb) { |
|
84
|
|
|
|
|
|
|
my $default_static_option_cb = sub { |
|
85
|
0
|
|
|
0
|
|
0
|
my ($self, $name) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
$name = "-Wl,-Bstatic -l$name -Wl,-Bdynamic"; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
return $name; |
|
90
|
3
|
|
|
|
|
58
|
}; |
|
91
|
3
|
|
|
|
|
28
|
$self->static_option_cb($default_static_option_cb); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
3
|
|
|
|
|
24
|
return $self; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Instance Methods |
|
98
|
|
|
|
|
|
|
sub to_arg { |
|
99
|
4
|
|
|
4
|
1
|
18
|
my ($self) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
4
|
|
|
|
|
259
|
my $link_command_arg; |
|
102
|
|
|
|
|
|
|
|
|
103
|
4
|
50
|
|
|
|
31
|
if ($self->is_abs) { |
|
104
|
0
|
0
|
|
|
|
0
|
if (defined $self->file) { |
|
105
|
0
|
|
|
|
|
0
|
$link_command_arg = $self->file; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
else { |
|
108
|
0
|
|
|
|
|
0
|
$link_command_arg = ""; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
else { |
|
112
|
4
|
|
|
|
|
39
|
my $name = $self->name; |
|
113
|
4
|
50
|
|
|
|
29
|
if ($self->is_static) { |
|
114
|
0
|
|
|
|
|
0
|
$link_command_arg = $self->static_option_cb->($self, $name); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
else { |
|
117
|
4
|
|
|
|
|
22
|
$link_command_arg = "-l$name"; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
4
|
|
|
|
|
22
|
return $link_command_arg; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub to_string { |
|
125
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return $self->name; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 Name |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
SPVM::Builder::LibInfo - Library Information |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 Description |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The SPVM::Builder::LibInfo class has methods to manipulate library information. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 Usage |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my $lib_info = SPVM::Builder::LibInfo->new(%fields); |
|
143
|
|
|
|
|
|
|
my $lib_arg = $lib_info->to_arg; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 Fields |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 name |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my $name = $lib_info->name; |
|
150
|
|
|
|
|
|
|
$lib_info->name($name); |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Gets and sets the C field. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This field is a library name. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Examples: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
$lib_info->name('z'); |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
$lib_info->name('png'); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 file |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $file = $lib_info->file; |
|
165
|
|
|
|
|
|
|
$lib_info->file($file); |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Gets and sets the C field. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This field is the absolute path of the library file like C, C. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 is_static |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
my $is_static = $lib_info->is_static; |
|
174
|
|
|
|
|
|
|
$lib_info->is_static($is_static); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Gets and sets the C field. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
If this field is a true value, a static library is linked. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 is_abs |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
my $is_abs = $lib_info->is_abs; |
|
183
|
|
|
|
|
|
|
$lib_info->is_abs($is_abs); |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Gets and sets the C field. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
If this field is a true value, the library is linked by the library name like C<-lfoo>. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Otherwise the library is linked by the absolute path of the library like C. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 static_option_cb |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
my $static_option_cb = $lib_info->static_option_cb; |
|
194
|
|
|
|
|
|
|
$lib_info->static_option_cb($static_option_cb); |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Gets and sets the C field. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This field is the callback to create a linker option to link a static library. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 Class Methods |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 new |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $lib_info = SPVM::Builder::LibInfo->new(%fields); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Creates a L object with L"Fields">. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Default Field Values: |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
If a field is not defined, the field is set to the following default value. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=over 2 |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * L"name"> |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
undef |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * L"file"> |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
undef |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * L"is_static"> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
0 |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * L"is_abs"> |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
0 |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * L"static_option_cb"> |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub { |
|
233
|
|
|
|
|
|
|
my ($self, $name) = @_; |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
$name = "-Wl,-Bstatic -l$name -Wl,-Bdynamic"; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
return $name; |
|
238
|
|
|
|
|
|
|
}; |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 Instance Methods |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 to_arg |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
my $link_command_arg = $lib_info->to_arg; |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Creates an argument of the link command from the L"is_abs"> field and L"is_static"> field, and returns it. |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
The following ones are examples of the return value. |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
-lfoo |
|
253
|
|
|
|
|
|
|
-Wl,-Bstatic -lfoo -Wl,-Bdynamic |
|
254
|
|
|
|
|
|
|
/path/foo.so |
|
255
|
|
|
|
|
|
|
/path/foo.a |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head2 to_string |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
my $lib_name = $lib_info->to_string; |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Returns the L"name"> field. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 Operators |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Overloads the following operators. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head2 bool |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my $bool = !!$lib_info; |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Always true. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 stringify |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
my $lib_name = "$lib_info"; |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Alias for the L"to_string"> method. |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 Copyright & License |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
MIT License |