line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::whichdll; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
223584
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
47
|
use 5.008001; |
|
2
|
|
|
|
|
7
|
|
6
|
2
|
|
|
2
|
|
960
|
use FFI::CheckLib 0.05 qw( find_lib ); |
|
2
|
|
|
|
|
4866
|
|
|
2
|
|
|
|
|
130
|
|
7
|
2
|
|
|
2
|
|
3886
|
use Getopt::Std qw( getopts ); |
|
2
|
|
|
|
|
101
|
|
|
2
|
|
|
|
|
124
|
|
8
|
2
|
|
|
2
|
|
1708
|
use Path::Tiny qw( path ); |
|
2
|
|
|
|
|
22789
|
|
|
2
|
|
|
|
|
1130
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Find dynamic libraries |
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub main |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
0
|
|
local @ARGV; |
17
|
0
|
|
|
|
|
|
(undef, @ARGV) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my %opts; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
getopts('avsx', \%opts) || return _usage(); |
22
|
0
|
0
|
|
|
|
|
return _version() if $opts{v}; |
23
|
0
|
0
|
|
|
|
|
return _usage() unless @ARGV; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my %seen; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
foreach my $name (@ARGV) |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
|
|
|
my @result; |
30
|
0
|
0
|
0
|
|
|
|
if($opts{a} || $name eq '*') |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
0
|
|
0
|
|
|
@result = find_lib( lib => '*', verify => sub { ($name eq '*') || ($_[0] eq $name) }); |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
|
my $result = find_lib( lib => $name ); |
37
|
0
|
0
|
|
|
|
|
push @result, $result if defined $result; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
unless($opts{s}) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
|
foreach my $path (map { path($_) } @result) |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
|
my $dir = path($path)->parent->realpath; |
45
|
0
|
|
|
|
|
|
$path = $dir->child($path->basename); |
46
|
0
|
0
|
|
|
|
|
if(-l $path) |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
|
|
|
my $target = path(readlink $path)->absolute($dir); |
49
|
0
|
0
|
|
|
|
|
if(-e $target) |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
|
$target = $target->realpath; |
52
|
0
|
0
|
0
|
|
|
|
next if (!$opts{x}) && $seen{$target}++; |
53
|
0
|
|
|
|
|
|
print "$path => $target\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
0
|
0
|
|
|
|
next if (!$opts{x}) && $seen{$target}++; |
58
|
0
|
|
|
|
|
|
print "$path => !! $target !!\n"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
0
|
0
|
|
|
|
next if (!$opts{x}) && $seen{$path}++; |
64
|
0
|
|
|
|
|
|
print "$path\n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
unless(@result) |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
0
|
|
|
|
|
print STDERR "$0: no $name in dynamic library path\n" unless $opts{s}; |
72
|
0
|
|
|
|
|
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _version |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
0
|
0
|
|
|
my $my_version = $App::whichdll::VERSION || 'dev'; |
82
|
0
|
|
|
|
|
|
print <<"EOF"; |
83
|
|
|
|
|
|
|
whichdll running FFI::CheckLib $FFI::CheckLib::VERSION |
84
|
|
|
|
|
|
|
App::whichdll $my_version |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Copyright 2017 Graham Ollis |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This program is free software; you may redistribute it and/or modify |
89
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
90
|
|
|
|
|
|
|
EOF |
91
|
0
|
|
|
|
|
|
2; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _usage |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
0
|
|
|
print <<"EOF"; |
97
|
|
|
|
|
|
|
Usage: $0 [-a] [-s] [-v] dllname [dllname ...] |
98
|
|
|
|
|
|
|
-a Print all matches in dynamic library path. |
99
|
|
|
|
|
|
|
-v Prints version and exits |
100
|
|
|
|
|
|
|
-s Silent mode |
101
|
|
|
|
|
|
|
-x Do not prune duplicates (due to symlinks, etc.) |
102
|
|
|
|
|
|
|
EOF |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |