| 1 | package PkgConfig::LibPkgConf::Client; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use PkgConfig::LibPkgConf::XS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | PkgConfig::LibPkgConf::Client - Query installed libraries for compiling and linking software | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | use PkgConfig::LibPkgConf::Client; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | my $client = PkgConfig::LibPkgConf::Client->new; | ||||||||||||||||||||||||||||
| 19 | $client->env; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | my $pkg = $client->find('libarchive'); | ||||||||||||||||||||||||||||
| 22 | my $cflags = $pkg->cflags; | ||||||||||||||||||||||||||||
| 23 | my $libs = $pkg->libs; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | The L<PkgConfig::LibPkgConf::Client> objects store all necessary state | ||||||||||||||||||||||||||||
| 28 | for C<libpkgconf> allowing for multiple instances to run in parallel. | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 new | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | my $client = PkgConfig::LibPkgConf::Client->new(%opts); | ||||||||||||||||||||||||||||
| 35 | my $client = PkgConfig::LibPkgConf::Client->new(\%opts); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Creates an instance of L<PkgConfig::LibPkgConf::Client>. Possible | ||||||||||||||||||||||||||||
| 38 | options include: | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =over 4 | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =item path | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | The search path to look for C<.pc> files. This may be specified | ||||||||||||||||||||||||||||
| 45 | either as a string with the appropriate path separator character, | ||||||||||||||||||||||||||||
| 46 | or as a list reference. This will override the C<pkgconf> compiled | ||||||||||||||||||||||||||||
| 47 | in defaults and the environment variables for C<PKG_CONFIG_PATH> or | ||||||||||||||||||||||||||||
| 48 | C<PKG_CONFIG_LIBDIR>. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =item filter_lib_dirs | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | List of directories to filter for libraries. This overrides the | ||||||||||||||||||||||||||||
| 53 | C<pkgconf> compiled in default and environment variable for | ||||||||||||||||||||||||||||
| 54 | C<PKG_CONFIG_SYSTEM_LIBRARY_PATH>. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =item filter_include_dirs | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | List of directories to filter for include. This overrides the | ||||||||||||||||||||||||||||
| 59 | C<pkgconf> compiled in default and environment variable for | ||||||||||||||||||||||||||||
| 60 | C<PKG_CONFIG_SYSTEM_INCLUDE_PATH>. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =back | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | environment variables honored: | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =over 4 | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =item PKG_CONFIG_PATH | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =item PKG_CONFIG_LIBDIR | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =item PKG_CONFIG_SYSTEM_LIBRARY_PATH | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =item PKG_CONFIG_SYSTEM_INCLUDE_PATH | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =item PKG_CONFIG_ALLOW_SYSTEM_CFLAGS | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item PKG_CONFIG_ALLOW_SYSTEM_LIBS | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =back | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | sub new | ||||||||||||||||||||||||||||
| 85 | 41 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 41 | my $class = shift; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $opts = ref $_[0] eq 'HASH' ? { %{$_[0]} } : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 41 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 41 | my $eh = do { | |||||||||||||||||||||||||||
| 92 | 41 | my $o = $self; | |||||||||||||||||||||||||||
| 93 | 41 | Scalar::Util::weaken($o); | |||||||||||||||||||||||||||
| 94 | 41 | ▶ | sub { $o->error($_[0]) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 25 | ▶ | my $path_cvt = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 98 | 25 | ▶ | ref $_[0] ? join(PkgConfig::LibPkgConf::Util::path_sep(), @{$_[0]}) : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 41 | }; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 41 | ▶ | if($ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} && !defined $opts->{filter_include_dirs}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"} and not defined $opts->{"filter_include_dirs"}
MC/DC0%0/2
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"} and not defined $opts->{"filter_include_dirs"}
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"}
not defined $opts->{"filter_include_dirs"}
Truth table33%1/3
A and not(B)
A= $ENV{"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"}B= not defined $opts->{"filter_include_dirs"}
| |||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||
| 103 | 0 | $opts->{filter_include_dirs} = []; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 41 | ▶ | if($ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} && !defined $opts->{filter_lib_dirs}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_LIBS"} and not defined $opts->{"filter_lib_dirs"}
MC/DC0%0/2
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_LIBS"} and not defined $opts->{"filter_lib_dirs"}
$ENV{"PKG_CONFIG_ALLOW_SYSTEM_LIBS"}
not defined $opts->{"filter_lib_dirs"}
Truth table33%1/3
A and not(B)
A= $ENV{"PKG_CONFIG_ALLOW_SYSTEM_LIBS"}B= not defined $opts->{"filter_lib_dirs"}
| |||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | 0 | $opts->{filter_lib_dirs} = []; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 41 | ▶ | local $ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} = $path_cvt->(delete $opts->{filter_lib_dirs}) if defined $opts->{filter_lib_dirs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 41 | ▶ | local $ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} = $path_cvt->(delete $opts->{filter_include_dirs}) if defined $opts->{filter_include_dirs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 41 | ▶ | _init($self, $eh, delete $opts->{maxdepth} || 2000); | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts->{'maxdepth'} || 2000
MC/DC100%1/1
delete $opts->{'maxdepth'} || 2000
delete $opts->{'maxdepth'}
Truth table100%2/2
A
A= delete $opts->{'maxdepth'}
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 41 | ▶ | if($opts->{path}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||
| 118 | 11 | local $ENV{PKG_CONFIG_PATH} = $path_cvt->(delete $opts->{path}); | |||||||||||||||||||||||||||
| 119 | 11 | $self->_dir_list_build(1); | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | else | ||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||
| 123 | 30 | $self->_dir_list_build(0); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 41 | ▶ | if(defined $ENV{PKG_CONFIG_TOP_BUILD_DIR}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||
| 128 | 0 | $self->buildroot_dir($ENV{PKG_CONFIG_TOP_BUILD_DIR}); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | 41 | ▶ | if(defined $ENV{PKG_CONFIG_SYSROOT_DIR}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||
| 132 | 0 | $self->sysroot_dir($ENV{PKG_CONFIG_SYSROOT_DIR}); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 41 | ▶ | if(my $global = delete $opts->{global}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||
| 137 | 3 | $self->global($_ => $global->{$_}) for keys %$global; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 41 | foreach my $key (sort keys %$opts) | |||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||
| 142 | 0 | require Carp; | |||||||||||||||||||||||||||
| 143 | 0 | Carp::carp("Unused unknown option $key"); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 41 | $self; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head2 path | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | my @path = $client->path; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | The search path to look for C<.pc> files. | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =head2 filter_lib_dirs | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | my @dirs = $client->filter_lib_dirs; | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | List of directories to filter for libraries. | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head2 filter_include_dirs | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | my @dirs = $client->filter_include_dirs; | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | List of directories to filter for includes. | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =head2 sysroot_dir | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | my $dir = $client->sysroot_dir; | ||||||||||||||||||||||||||||
| 172 | $client->sysroot_dir($dir); | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Get or set the sysroot directory. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =head2 buildroot_dir | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | my $dir = $client->buildroot_dir; | ||||||||||||||||||||||||||||
| 179 | $client->buildroot_dir($dir); | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | Get or set the buildroot directory. | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =head2 maxdepth | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | my $int = $client->maxdepth; | ||||||||||||||||||||||||||||
| 186 | $client->maxdepth($int); | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | Get or set the maximum dependency depth. This is 2000 by default. | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | =head1 METHODS | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head2 env | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | my $client->env; | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | This method loads settings for the client object from the environment using | ||||||||||||||||||||||||||||
| 197 | the standard C<pkg-config> or C<pkgconf> environment variables. It honors the | ||||||||||||||||||||||||||||
| 198 | following list of environment variables: | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =over 4 | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =item PKG_CONFIG_LOG | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =back | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =cut | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | # PKG_CONFIG_DEBUG_SPEW | ||||||||||||||||||||||||||||
| 209 | # PKG_CONFIG_IGNORE_CONFLICTS | ||||||||||||||||||||||||||||
| 210 | # PKG_CONFIG_PURE_DEPGRAPH | ||||||||||||||||||||||||||||
| 211 | # PKG_CONFIG_DISABLE_UNINSTALLED | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | sub env | ||||||||||||||||||||||||||||
| 214 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
env: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | 3 | my($self) = @_; | |||||||||||||||||||||||||||
| 216 | 3 | ▶ | if($ENV{PKG_CONFIG_LOG}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||
| 218 | 0 | $self->audit_set_log($ENV{PKG_CONFIG_LOG}, "w"); | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | 3 | $self; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | =head2 find | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | my $pkg = $client->find($package_name); | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | Searches the <.pc> file for the package with the given C<$package_name>. | ||||||||||||||||||||||||||||
| 228 | If found returns an instance of L<PkgConfig::LibPkgConf::Package>. If | ||||||||||||||||||||||||||||
| 229 | not found returns C<undef>. | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | =cut | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | sub _pkg | ||||||||||||||||||||||||||||
| 234 | 17 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_pkg: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 235 | 17 | my($client, $ptr, @rest) = @_; | |||||||||||||||||||||||||||
| 236 | 17 | require PkgConfig::LibPkgConf::Package; | |||||||||||||||||||||||||||
| 237 | 17 | bless { | |||||||||||||||||||||||||||
| 238 | client => $client, | ||||||||||||||||||||||||||||
| 239 | ptr => $ptr, | ||||||||||||||||||||||||||||
| 240 | @rest | ||||||||||||||||||||||||||||
| 241 | }, 'PkgConfig::LibPkgConf::Package'; | ||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | sub find | ||||||||||||||||||||||||||||
| 245 | 18 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 18 | my($self, $name) = @_; | |||||||||||||||||||||||||||
| 247 | 18 | my $ptr = _find($self, $name); | |||||||||||||||||||||||||||
| 248 | 18 | ▶ | $ptr ? _pkg($self, $ptr, name => $name) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | =head2 package_from_file | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | my $pkg = $client->package_from_file($filename); | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | Load the specific <.pc> file. | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =cut | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | sub package_from_file | ||||||||||||||||||||||||||||
| 260 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
package_from_file: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 261 | 1 | my($self, $filename) = @_; | |||||||||||||||||||||||||||
| 262 | 1 | my $ptr = _package_from_file($self, $filename); | |||||||||||||||||||||||||||
| 263 | 1 | ▶ | $ptr ? _pkg($self, $ptr, filename => $filename) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | =head2 scan_all | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | $client->scan_all(sub { | ||||||||||||||||||||||||||||
| 269 | my($client, $package) = @_; | ||||||||||||||||||||||||||||
| 270 | ... | ||||||||||||||||||||||||||||
| 271 | return $bool; | ||||||||||||||||||||||||||||
| 272 | }); | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Iterates through all packages and calls the given subroutine reference | ||||||||||||||||||||||||||||
| 275 | for each package. C<$package> isa L<PkgConfig::LibPkgConf::Package>. | ||||||||||||||||||||||||||||
| 276 | The scan will continue so long as a non true value is returned | ||||||||||||||||||||||||||||
| 277 | (as C<$bool>). | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | sub scan_all | ||||||||||||||||||||||||||||
| 282 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
scan_all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | 1 | my($self, $callback) = @_; | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 3 | ▶ | my $wrapper = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 286 | 3 | my($ptr) = @_; | |||||||||||||||||||||||||||
| 287 | 3 | my $package = _pkg($self, $ptr); | |||||||||||||||||||||||||||
| 288 | 3 | $callback->($self, $package); | |||||||||||||||||||||||||||
| 289 | 1 | }; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 1 | $self->_scan_all($wrapper); | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =head2 global | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | $client->global($key => $value); | ||||||||||||||||||||||||||||
| 297 | my $value = $client->global($key); | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | Define or get the global variable. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =cut | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | sub global | ||||||||||||||||||||||||||||
| 304 | 7 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
global: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 305 | 7 | my($self, $key, $value) = @_; | |||||||||||||||||||||||||||
| 306 | 7 | ▶ | if(defined $value) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | { | ||||||||||||||||||||||||||||
| 308 | 4 | $self->_set_global("$key=$value"); | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | 7 | $self->_get_global($key); | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =head2 error | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | my $client->error($message); | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | Called when C<libpkgconf> comes across a non-fatal error. By default | ||||||||||||||||||||||||||||
| 318 | the error is simply displayed as a warning using L<Carp>. The intention | ||||||||||||||||||||||||||||
| 319 | of this method is if you want to override that behavior, you will subclass | ||||||||||||||||||||||||||||
| 320 | L<PkgConfig::LibPkgConf::Client> and implement your own version of the | ||||||||||||||||||||||||||||
| 321 | C<error> method. | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | =cut | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | sub error | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 327 | 0 | my($self, $msg) = @_; | |||||||||||||||||||||||||||
| 328 | 0 | require Carp; | |||||||||||||||||||||||||||
| 329 | 0 | Carp::carp($msg); | |||||||||||||||||||||||||||
| 330 | 0 | 1; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 5 | 1; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | =head2 audit_set_log | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | $client->audit_set_log($filename, $mode); | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | Opens a file with the C C<fopen> style C<$mode>, and uses it for the | ||||||||||||||||||||||||||||
| 340 | audit log. The file is managed entirely by the client class and will be | ||||||||||||||||||||||||||||
| 341 | closed when the object falls out of scope. Examples: | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | $client->audit_set_log("audit.log", "a"); # append to existing file | ||||||||||||||||||||||||||||
| 344 | $client->audit_set_log("audit2.log", "w"); # new or replace file | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | IRC #native on irc.perl.org | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | Project GitHub tracker: | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | L<https://github.com/plicease/PkgConfig-LibPkgConf/issues> | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | If you want to contribute, please open a pull request on GitHub: | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | L<https://github.com/plicease/PkgConfig-LibPkgConf/pulls> | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | For additional related modules, see L<PkgConfig::LibPkgConf> | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | Graham Ollis | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | For additional contributors see L<PkgConfig::LibPkgConf> | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | This software is copyright (c) 2016 Graham Ollis. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | This is free software; you may redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 373 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | =cut | ||||||||||||||||||||||||||||