line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Project::Libs; |
2
|
3
|
|
|
3
|
|
1358
|
use 5.008001; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
111
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
88
|
|
5
|
3
|
|
|
3
|
|
12
|
use Cwd; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
189
|
|
6
|
3
|
|
|
3
|
|
1670
|
use FindBin; |
|
3
|
|
|
|
|
2334
|
|
|
3
|
|
|
|
|
138
|
|
7
|
3
|
|
|
3
|
|
3136
|
use FindBin::libs; |
|
3
|
|
|
|
|
44553
|
|
|
3
|
|
|
|
|
50
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @PROJECT_ROOT_FILES = qw( |
12
|
|
|
|
|
|
|
.git |
13
|
|
|
|
|
|
|
.gitmodules |
14
|
|
|
|
|
|
|
Makefile.PL |
15
|
|
|
|
|
|
|
Build.PL |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
3
|
|
|
3
|
|
43
|
my ($class, %args) = @_; |
20
|
3
|
|
|
|
|
70
|
my $current_dir = getcwd; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
100
|
|
|
39
|
my $lib_dirs = delete $args{lib_dirs} || []; |
23
|
3
|
|
50
|
|
|
24
|
my $project_root_files = delete $args{project_root_files} || []; |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
7
|
push @PROJECT_ROOT_FILES, @$project_root_files; |
26
|
3
|
|
|
|
|
16
|
my @inc = find_inc($FindBin::Bin, $lib_dirs, ()); |
27
|
|
|
|
|
|
|
|
28
|
3
|
50
|
|
|
|
13
|
if (scalar @inc) { |
29
|
3
|
|
|
|
|
9
|
my $inc = join ' ', @inc; |
30
|
3
|
|
|
3
|
|
37
|
eval "use lib qw($inc)"; |
|
3
|
|
|
|
|
29
|
|
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
255
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
13224
|
chdir $current_dir; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub find_inc { |
37
|
5
|
|
|
5
|
0
|
1944
|
my ($current_dir, $lib_dirs, @inc) = @_; |
38
|
5
|
50
|
|
|
|
23
|
return @inc if $current_dir eq '/'; |
39
|
5
|
|
|
|
|
166
|
chdir $current_dir; |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
14
|
my $glob_expanded_lib_dirs = [ map { glob($_) } @$lib_dirs ]; |
|
4
|
|
|
|
|
466
|
|
42
|
5
|
|
|
|
|
15
|
my @found = grep { -e File::Spec->catfile($current_dir, $_)} @$glob_expanded_lib_dirs; |
|
5
|
|
|
|
|
197
|
|
43
|
5
|
|
|
|
|
38
|
push @inc, map { File::Spec->catfile($current_dir, $_)} @found; |
|
5
|
|
|
|
|
221
|
|
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
16
|
my @root_files = grep { -e $_ } @PROJECT_ROOT_FILES; |
|
20
|
|
|
|
|
315
|
|
46
|
5
|
50
|
|
|
|
20
|
if (!@root_files) { |
47
|
0
|
|
|
|
|
0
|
chdir '..'; |
48
|
0
|
|
|
|
|
0
|
$current_dir = getcwd; |
49
|
0
|
|
|
|
|
0
|
return find_inc($current_dir, $lib_dirs, @inc); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
16
|
for my $file (@root_files) { |
53
|
5
|
50
|
|
|
|
20
|
if ($file eq '.gitmodules') { |
54
|
5
|
|
|
|
|
88
|
push @inc, find_git_submodules( |
55
|
|
|
|
|
|
|
$current_dir, |
56
|
|
|
|
|
|
|
File::Spec->catfile($current_dir, '.gitmodules'), |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
31
|
@inc; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub find_git_submodules { |
65
|
6
|
|
|
6
|
0
|
603
|
my ($current_dir, $gitsubmodule) = @_; |
66
|
6
|
50
|
|
|
|
402
|
open my $fh, "< $gitsubmodule" or die $!; |
67
|
6
|
|
|
|
|
12
|
my $content = do { local $/ = undef; <$fh> }; |
|
6
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
183
|
|
68
|
6
|
|
|
|
|
68
|
close $fh; |
69
|
6
|
|
|
|
|
73
|
my @submodules = ($content =~ /\[submodule "([^"]+)"\]/g); |
70
|
6
|
|
|
|
|
14
|
map { File::Spec->catfile($current_dir, "$_/lib") } @submodules; |
|
12
|
|
|
|
|
166
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
!!1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |