blib/lib/PkgConfig/LibPkgConf/Package.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 9 / 9 totaltotal 100% 58 / 58 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« LibPkgConf.xs ↑ Summary blib/lib/PkgConfig/LibPkgConf/Test.pm »
1 package PkgConfig::LibPkgConf::Package;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use PkgConfig::LibPkgConf::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION = '0.11';
8  
9 =head1 NAME
10  
11 PkgConfig::LibPkgConf::Package - Represents a package
12  
13 =head1 SYNOPSIS
14  
15 use PkgConfig::LibPkgConf::Client;
16
17 my $client = PkgConfig::LibPkgConf::Client->new;
18 $client->env;
19
20 my $pkg = $client->find('libarchive');
21
22 # use with system in scalar form:
23 my $cflags = $pkg->cflags;
24 my $libs = $pkg->libs;
25 system "$cc $cflags foo.c";
26 system "$cc -o foo foo.o $libs";
27
28 # use with system in list form:
29 my @cflags = $pkg->list_cflags;
30 my @libs = $pkg->list_libs;
31 system $cc, @cflags, 'foo.c';
32 system $cc, -p => 'foo', 'foo.o', @libs;
33  
34 =head1 DESCRIPTION
35  
36 The L<PkgConfig::LibPkgConf::Package> object stores package information. Part
37 of the package information is the compiler and linker flags. This can be fetched
38 as strings with C<cflags> and C<libs> and as a list with C<list_cflags> and
39 C<list_libs>. In the string form, escapes are retained, but in list form the
40 white space escapes are converted into spaces. That means if you are using the
41 string form of C<system>/C<exec> you should use the string accessors, and if you
42 are using the list form of C<system>/C<exec> you should use the list accessors.
43  
44 =head1 ATTRIBUTES
45  
46 =head2 refcount
47  
48 Internal reference count used by C<pkgconf>.
49  
50 =head2 id
51  
52 The id of the package.
53  
54 =head2 filename
55  
56 The filename of the C<.pc> file.
57  
58 =head2 realname
59  
60 The real name for the package.
61  
62 =head2 version
63  
64 The version of the package.
65  
66 =head2 description
67  
68 Description of the package.
69  
70 =head2 url
71  
72 URL for the package.
73  
74 =head2 pc_filedir
75  
76 TODO
77  
78 =head1 METHODS
79  
80 =head2 libs
81  
82 Library flags. This usually includes things like C<-L/foo/lib> and C<-lfoo>.
83  
84 =cut
85  
86 sub libs
87 8 ▶{
Subroutine libs: called CC=1 SCAR=0.0
Pod documented
88 8 my($self) = @_;
89 8 $self->_get_string($self->{client}, 0);
90 }
91  
92 =head2 libs_static
93  
94 Static library flags.
95  
96 =cut
97  
98 sub libs_static
99 4 ▶{
Subroutine libs_static: called CC=1 SCAR=0.0
Pod documented
100 4 my($self) = @_;
101 4 $self->_get_string($self->{client}, 1);
102 }
103  
104 =head2 cflags
105  
106 Compiler flags. This usually includes things like C<-I/foo/include> and C<-DFOO=1>.
107  
108 =cut
109  
110 sub cflags
111 9 ▶{
Subroutine cflags: called CC=1 SCAR=0.0
Pod documented
112 9 my($self) = @_;
113 9 $self->_get_string($self->{client}, 2);
114 }
115  
116 =head2 cflags_static
117  
118 Static compiler flags.
119  
120 =cut
121  
122 sub cflags_static
123 6 ▶{
Subroutine cflags_static: called CC=1 SCAR=0.0
Pod documented
124 6 my($self) = @_;
125 6 $self->_get_string($self->{client}, 3);
126 }
127  
128 =head2 list_libs
129  
130 my @fragments = $package->list_libs;
131  
132 Library flags as a list of fragments L<PkgConfig::LibPkgConf::Fragment>. This is similar
133 to the C<libs> method above, but since it returns a list instead of a single string, it can
134 be used to filter for specific flags. For example:
135  
136 # equivalent to pkgconf --libs-only-L
137 my @lib_dirs = grep { $_->type eq 'L' } $package->list_libs;
138 # equivalent to pkgconf --libs-only-l
139 my @libs = grep { $_->type eq 'l' } $package->list_libs;
140  
141 =cut
142  
143 sub list_libs
144 4 ▶{
Subroutine list_libs: called CC=1 SCAR=0.0
Pod documented
145 4 my($self) = @_;
146 4 require PkgConfig::LibPkgConf::Fragment;
147 4 map { bless $_, 'PkgConfig::LibPkgConf::Fragment' } $self->_get_list($self->{client}, 0);
148 }
149  
150 =head2 list_libs_static
151  
152 my @fragments = $package->list_libs_static;
153  
154 Similar to C<list_libs>, but for the static libs flags.
155  
156 =cut
157  
158 sub list_libs_static
159 1 ▶{
Subroutine list_libs_static: called CC=1 SCAR=0.0
Pod documented
160 1 my($self) = @_;
161 1 require PkgConfig::LibPkgConf::Fragment;
162 1 map { bless $_, 'PkgConfig::LibPkgConf::Fragment' } $self->_get_list($self->{client}, 1);
163 }
164  
165 =head2 list_cflags
166  
167 my @fragments = $package->list_cflags;
168  
169 Compiler flags as a list of fragments L<PkgConfig::LibPkgConf::Fragment>. This is similar
170 to the C<cflags> method above, but since it returns a list instead of a single string, it
171 can be used to filter for specific flags. For example:
172  
173 # equivalent to pkgconf --cflags-only-I
174 my @include_dirs = grep { $_->type eq 'I' } $package->list_cflags;
175 # equivalent to pkgconf --cflags-only-other
176 my @other_cflags = grep { $_->type ne 'I' } $package->list_cflags;
177  
178 =cut
179  
180 sub list_cflags
181 4 ▶{
Subroutine list_cflags: called CC=1 SCAR=0.0
Pod documented
182 4 my($self) = @_;
183 4 require PkgConfig::LibPkgConf::Fragment;
184 4 map { bless $_, 'PkgConfig::LibPkgConf::Fragment' } $self->_get_list($self->{client}, 2);
185 }
186  
187 =head2 list_cflags_static
188  
189 my @fragments = $package->list_cflags_static;
190  
191 Similar to C<list_cflags>, but for the static compiler flags.
192  
193 =cut
194  
195 sub list_cflags_static
196 3 ▶{
Subroutine list_cflags_static: called CC=1 SCAR=0.0
Pod documented
197 3 my($self) = @_;
198 3 require PkgConfig::LibPkgConf::Fragment;
199 3 map { bless $_, 'PkgConfig::LibPkgConf::Fragment' } $self->_get_list($self->{client}, 3);
200 }
201  
202 =head2 variable
203  
204 my $value = $package->variable($key);
205  
206 Look up the value for the given variable. Returns the value if found,
207 otherwise it will return undef (technically empty list).
208  
209 =cut
210  
211 sub variable
212 4 ▶{
Subroutine variable: called CC=1 SCAR=0.0
Pod documented
213 4 my($self, $name) = @_;
214 4 $self->_get_variable($name);
215 }
216  
217 =head1 SUPPORT
218  
219 IRC #native on irc.perl.org
220  
221 Project GitHub tracker:
222  
223 L<https://github.com/plicease/PkgConfig-LibPkgConf/issues>
224  
225 If you want to contribute, please open a pull request on GitHub:
226  
227 L<https://github.com/plicease/PkgConfig-LibPkgConf/pulls>
228  
229 =head1 SEE ALSO
230  
231 For additional related modules, see L<PkgConfig::LibPkgConf>
232  
233 =head1 AUTHOR
234  
235 Graham Ollis
236  
237 For additional contributors see L<PkgConfig::LibPkgConf>
238  
239 =head1 COPYRIGHT AND LICENSE
240  
241 This software is copyright (c) 2016 Graham Ollis.
242  
243 This is free software; you may redistribute it and/or modify it under
244 the same terms as the Perl 5 programming language system itself.
245  
246 =cut
247
248 4 1;
« LibPkgConf.xs ↑ Summary blib/lib/PkgConfig/LibPkgConf/Test.pm »