line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Libarchive; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
34771
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
154
|
|
4
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
100
|
|
5
|
4
|
|
|
4
|
|
2096
|
use File::ShareDir (); |
|
4
|
|
|
|
|
22537
|
|
|
4
|
|
|
|
|
104
|
|
6
|
4
|
|
|
4
|
|
33
|
use File::Spec; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
78
|
|
7
|
4
|
|
|
4
|
|
2024
|
use Alien::Libarchive::ConfigData; |
|
4
|
|
|
|
|
473
|
|
|
4
|
|
|
|
|
163
|
|
8
|
4
|
|
|
4
|
|
20
|
use constant _share_dir => File::ShareDir::dist_dir('Alien-Libarchive'); |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
16
|
|
9
|
4
|
|
|
4
|
|
550
|
use constant _alien_libarchive019 => 1; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
3028
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Build and make available libarchive |
12
|
|
|
|
|
|
|
our $VERSION = '0.26'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $cf = 'Alien::Libarchive::ConfigData'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _catfile { |
17
|
0
|
|
|
0
|
|
0
|
my $path = File::Spec->catfile(@_); |
18
|
0
|
0
|
|
|
|
0
|
$path =~ s{\\}{/}g if $^O eq 'MSWin32'; |
19
|
0
|
|
|
|
|
0
|
$path; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _catdir { |
23
|
0
|
|
|
0
|
|
0
|
my $path = File::Spec->catdir(@_); |
24
|
0
|
0
|
|
|
|
0
|
$path =~ s{\\}{/}g if $^O eq 'MSWin32'; |
25
|
0
|
|
|
|
|
0
|
$path; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
|
|
1
|
0
|
1021
|
my($class) = @_; |
32
|
1
|
|
|
|
|
6
|
bless {}, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub cflags |
37
|
|
|
|
|
|
|
{ |
38
|
1
|
|
|
1
|
1
|
176
|
my($class) = @_; |
39
|
1
|
|
|
|
|
3
|
my @cflags = @{ $cf->config("cflags") }; |
|
1
|
|
|
|
|
11
|
|
40
|
0
|
0
|
|
|
|
|
unshift @cflags, '-I' . _catdir(_share_dir, 'libarchive019', 'include' ) |
41
|
|
|
|
|
|
|
if $class->install_type eq 'share'; |
42
|
0
|
0
|
|
|
|
|
wantarray ? @cflags : "@cflags"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub libs |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
|
my($class) = @_; |
49
|
0
|
|
|
|
|
|
my @libs = @{ $cf->config("libs") }; |
|
0
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if($class->install_type eq 'share') |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
0
|
|
|
|
|
if($cf->config('msvc')) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
|
unshift @libs, '/libpath:' . _catdir(_share_dir, 'libarchive019', 'lib'); |
55
|
0
|
0
|
|
|
|
|
@libs = map { s{^.*(\\|/)}{} if m/archive_static\.lib$/; $_ } @libs; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
|
unshift @libs, '-L' . _catdir(_share_dir, 'libarchive019', 'lib'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
0
|
0
|
|
|
|
|
wantarray ? @libs : "@libs"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub dlls |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
0
|
1
|
|
my($class) = @_; |
69
|
0
|
|
|
|
|
|
my @list; |
70
|
0
|
0
|
|
|
|
|
if($class->install_type eq 'system') |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
|
|
|
require Alien::Libarchive::Installer; |
73
|
0
|
|
|
|
|
|
@list = Alien::Libarchive::Installer->system_install( alien => 0, test => 'ffi' )->dlls; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
|
|
|
@list = map { _catfile(_share_dir, 'libarchive019', 'dll', $_) } |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
@{ $cf->config("dlls") }; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
0
|
|
|
|
|
wantarray ? @list : $list[0]; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub version |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
0
|
1
|
|
$cf->config("version"); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub install_type |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
0
|
1
|
|
$cf->config("install_type"); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub pkg_config_dir |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
1
|
|
_catdir(_share_dir, 'libarchive019', 'lib', 'pkgconfig'); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub pkg_config_name |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
0
|
1
|
|
'libarchive'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# extract the macros from the header files, this is a private function |
108
|
|
|
|
|
|
|
# because it may not be portable. Used by the Archive::Libarchive::XS |
109
|
|
|
|
|
|
|
# build process (and maybe Archive::Libarchive::FFI) to automatically |
110
|
|
|
|
|
|
|
# generate constants |
111
|
|
|
|
|
|
|
# UPDATE: this maybe should use C::Scan or C::Scan::Constants |
112
|
|
|
|
|
|
|
sub _macro_list |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
|
|
require Config; |
115
|
0
|
|
|
|
|
|
require File::Temp; |
116
|
0
|
|
|
|
|
|
require File::Spec; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $alien = Alien::Libarchive->new; |
119
|
0
|
|
|
|
|
|
my $cc = "$Config::Config{ccname} $Config::Config{ccflags} " . $alien->cflags; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $fn = File::Spec->catfile(File::Temp::tempdir( CLEANUP => 1 ), "test.c"); |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
do { |
124
|
0
|
|
|
|
|
|
open my $fh, '>', $fn; |
125
|
0
|
|
|
|
|
|
print $fh "#include \n"; |
126
|
0
|
|
|
|
|
|
print $fh "#include \n"; |
127
|
0
|
|
|
|
|
|
close $fh; |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my @list; |
131
|
0
|
|
|
|
|
|
my $cmd = "$cc -E -dM $fn"; |
132
|
0
|
|
|
|
|
|
foreach my $line (`$cmd`) |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
0
|
|
|
|
|
if($line =~ /^#define ((AE|ARCHIVE)_\S+)/) |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
|
push @list, $1; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
0
|
|
|
|
|
|
sort @list; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |