line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::gdal;
|
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
654977
|
use 5.010;
|
|
4
|
|
|
|
|
45
|
|
4
|
4
|
|
|
4
|
|
22
|
use strict;
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
85
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings;
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
137
|
|
6
|
4
|
|
|
4
|
|
479
|
use parent qw( Alien::Base );
|
|
4
|
|
|
|
|
328
|
|
|
4
|
|
|
|
|
32
|
|
7
|
4
|
|
|
4
|
|
67394
|
use FFI::CheckLib;
|
|
4
|
|
|
|
|
12800
|
|
|
4
|
|
|
|
|
302
|
|
8
|
4
|
|
|
4
|
|
949
|
use Env qw ( @PATH @LD_LIBRARY_PATH @DYLD_LIBRARY_PATH );
|
|
4
|
|
|
|
|
2702
|
|
|
4
|
|
|
|
|
39
|
|
9
|
4
|
|
|
4
|
|
1074
|
use Capture::Tiny qw /:all/;
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
547
|
|
10
|
4
|
|
|
4
|
|
27
|
use Path::Tiny qw /path/;
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
164
|
|
11
|
4
|
|
|
4
|
|
2003
|
use Alien::proj;
|
|
4
|
|
|
|
|
212942
|
|
|
4
|
|
|
|
|
43
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.25';
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my ($have_geos, $have_proj, $have_spatialite);
|
16
|
|
|
|
|
|
|
my @have_aliens;
|
17
|
|
|
|
|
|
|
BEGIN {
|
18
|
4
|
|
|
4
|
|
2157
|
$have_geos = eval 'require Alien::geos::af';
|
19
|
4
|
|
|
|
|
2088
|
$have_spatialite = eval 'require Alien::spatialite';
|
20
|
4
|
|
|
|
|
26
|
foreach my $alien_lib (qw /Alien::geos::af Alien::sqlite Alien::proj Alien::freexl Alien::libtiff/) {
|
21
|
20
|
|
|
|
|
8661
|
my $have_lib = eval "require $alien_lib";
|
22
|
20
|
|
|
|
|
70
|
my $pushed_to_env = 0;
|
23
|
20
|
100
|
66
|
|
|
157
|
if ($have_lib && $alien_lib->install_type eq 'share') {
|
24
|
16
|
|
|
|
|
53740
|
push @have_aliens, $alien_lib;
|
25
|
|
|
|
|
|
|
# crude, but otherwise Geo::GDAL::FFI does not
|
26
|
|
|
|
|
|
|
# get fed all the needed info
|
27
|
|
|
|
|
|
|
#warn "Adding Alien::geos bin to path: " . Alien::geos::af->bin_dir;
|
28
|
16
|
|
|
|
|
83
|
push @PATH, $alien_lib->bin_dir;
|
29
|
|
|
|
|
|
|
#warn $ENV{PATH};
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
#
|
33
|
4
|
0
|
33
|
|
|
2443
|
if ($^O =~ /mswin/i and !$ENV{PROJSO} and Alien::gdal->version lt 3) {
|
|
|
|
33
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my $libpath;
|
35
|
0
|
|
|
|
|
0
|
$have_proj = eval 'require Alien::proj';
|
36
|
0
|
0
|
|
|
|
0
|
if ($have_proj) {
|
37
|
|
|
|
|
|
|
# make sure we get the proj lib early in the search
|
38
|
0
|
|
|
|
|
0
|
($libpath) = Alien::proj->bin_dir;
|
39
|
|
|
|
|
|
|
}
|
40
|
0
|
|
|
|
|
0
|
my $proj_lib = FFI::CheckLib::find_lib (
|
41
|
|
|
|
|
|
|
libpath => $libpath,
|
42
|
|
|
|
|
|
|
lib => 'proj',
|
43
|
|
|
|
|
|
|
);
|
44
|
|
|
|
|
|
|
#warn "PROJ_LIB FILE IS $proj_lib";
|
45
|
0
|
|
0
|
|
|
0
|
$ENV{PROJSO} //= $proj_lib;
|
46
|
|
|
|
|
|
|
}
|
47
|
4
|
50
|
|
|
|
60
|
if (Alien::gdal->version ge '3') {
|
48
|
4
|
50
|
|
|
|
143105
|
push @PATH, 'Alien::proj'->bin_dirs
|
49
|
|
|
|
|
|
|
if 'Alien::proj'->can('bin_dirs');
|
50
|
4
|
50
|
33
|
|
|
192
|
if ($have_spatialite && Alien::spatialite->version ge 5) {
|
51
|
0
|
0
|
|
|
|
0
|
push @PATH, 'Alien::spatialite'->bin_dirs
|
52
|
|
|
|
|
|
|
if 'Alien::spatialite'->can('bin_dirs');
|
53
|
0
|
|
|
|
|
0
|
push @have_aliens, 'Alien::spatialite';
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
}
|
56
|
4
|
50
|
33
|
|
|
2676
|
if ($have_geos
|
|
|
|
33
|
|
|
|
|
57
|
|
|
|
|
|
|
&& $^O =~ /bsd/
|
58
|
|
|
|
|
|
|
&& Alien::geos::af->install_type eq 'share'
|
59
|
|
|
|
|
|
|
) {
|
60
|
|
|
|
|
|
|
# underhanded, but we are getting failures if this is not set
|
61
|
|
|
|
|
|
|
# maybe should be done in A::g::af
|
62
|
0
|
|
|
|
|
0
|
my $libdir = Alien::geos::af->dist_dir . q{/lib};
|
63
|
|
|
|
|
|
|
push @LD_LIBRARY_PATH, $libdir
|
64
|
0
|
|
|
|
|
0
|
if !grep {/^$libdir$/}
|
65
|
0
|
0
|
|
|
|
0
|
grep {defined}
|
|
0
|
|
|
|
|
0
|
|
66
|
|
|
|
|
|
|
@LD_LIBRARY_PATH;
|
67
|
|
|
|
|
|
|
push @DYLD_LIBRARY_PATH, $libdir
|
68
|
0
|
|
|
|
|
0
|
if !grep {/^$libdir$/}
|
69
|
0
|
0
|
|
|
|
0
|
grep {defined}
|
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
@DYLD_LIBRARY_PATH;
|
71
|
|
|
|
|
|
|
#warn "Adding $libdir to LD_LIBRARY_PATH and DYLD_LIBRARY_PATH";
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub dynamic_libs {
|
77
|
1
|
|
|
1
|
1
|
2
|
my $self = shift;
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#warn 'LD Path is: ' . join ' ', grep {defined} @LD_LIBRARY_PATH;
|
80
|
|
|
|
|
|
|
#warn 'Bare env var: ' . ($ENV{LD_LIBRARY_PATH} // '');
|
81
|
|
|
|
|
|
|
#warn 'DYLD Path is: ' . join ' ', grep {defined} @DYLD_LIBRARY_PATH;
|
82
|
|
|
|
|
|
|
#warn 'Bare env var: ' . ($ENV{DYLD_LIBRARY_PATH} // '');
|
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
9
|
my (@libs) = $self->SUPER::dynamic_libs;
|
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
8215
|
foreach my $alien (@have_aliens) {
|
87
|
4
|
|
|
|
|
65379
|
push @libs, $alien->dynamic_libs;
|
88
|
|
|
|
|
|
|
}
|
89
|
1
|
|
|
|
|
11762
|
my (%seen, @libs2);
|
90
|
1
|
|
|
|
|
4
|
foreach my $lib (@libs) {
|
91
|
26
|
100
|
|
|
|
46
|
next if $seen{$lib};
|
92
|
17
|
|
|
|
|
27
|
push @libs2, $lib;
|
93
|
17
|
|
|
|
|
35
|
$seen{$lib}++;
|
94
|
|
|
|
|
|
|
}
|
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
25
|
return @libs2;
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub cflags {
|
100
|
2
|
|
|
2
|
1
|
1666
|
my $self = shift;
|
101
|
|
|
|
|
|
|
|
102
|
2
|
|
|
|
|
12
|
my $cflags = $self->SUPER::cflags;
|
103
|
|
|
|
|
|
|
|
104
|
2
|
50
|
|
|
|
1249
|
if ($have_geos) {
|
105
|
2
|
|
|
|
|
18
|
$cflags .= ' ' . Alien::geos::af->cflags;
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
79
|
return $cflags;
|
109
|
|
|
|
|
|
|
}
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub libs {
|
112
|
2
|
|
|
2
|
1
|
2470
|
my $self = shift;
|
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
15
|
my $cflags = $self->SUPER::libs;
|
115
|
|
|
|
|
|
|
|
116
|
2
|
50
|
|
|
|
3874
|
if ($have_geos) {
|
117
|
2
|
|
|
|
|
20
|
$cflags .= ' ' . Alien::geos::af->libs;
|
118
|
|
|
|
|
|
|
}
|
119
|
|
|
|
|
|
|
|
120
|
2
|
|
|
|
|
94
|
return $cflags;
|
121
|
|
|
|
|
|
|
}
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#sub cflags_static {
|
124
|
|
|
|
|
|
|
# my $self = shift;
|
125
|
|
|
|
|
|
|
#
|
126
|
|
|
|
|
|
|
# my $cflags = $self->SUPER::cflags_static;
|
127
|
|
|
|
|
|
|
#
|
128
|
|
|
|
|
|
|
# if ($have_geos) {
|
129
|
|
|
|
|
|
|
# $cflags .= ' ' . Alien::geos::af->cflags_static;
|
130
|
|
|
|
|
|
|
# }
|
131
|
|
|
|
|
|
|
#
|
132
|
|
|
|
|
|
|
# return $cflags;
|
133
|
|
|
|
|
|
|
#}
|
134
|
|
|
|
|
|
|
#
|
135
|
|
|
|
|
|
|
#sub libs_static {
|
136
|
|
|
|
|
|
|
# my $self = shift;
|
137
|
|
|
|
|
|
|
#
|
138
|
|
|
|
|
|
|
# my $cflags = $self->SUPER::libs_static;
|
139
|
|
|
|
|
|
|
#
|
140
|
|
|
|
|
|
|
# if ($have_geos) {
|
141
|
|
|
|
|
|
|
# $cflags .= ' ' . Alien::geos::af->libs_static;
|
142
|
|
|
|
|
|
|
# }
|
143
|
|
|
|
|
|
|
#
|
144
|
|
|
|
|
|
|
# return $cflags;
|
145
|
|
|
|
|
|
|
#}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub run_utility {
|
148
|
1
|
|
|
1
|
0
|
191
|
my ($self, $utility, @args) = @_;
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
my @alien_bins
|
151
|
5
|
|
|
|
|
594
|
= grep {defined}
|
152
|
1
|
|
|
|
|
3
|
map {$_->bin_dir}
|
|
5
|
|
|
|
|
2332
|
|
153
|
|
|
|
|
|
|
($self, @have_aliens);
|
154
|
1
|
50
|
|
|
|
14
|
push @alien_bins, Alien::proj->bin_dirs
|
155
|
|
|
|
|
|
|
if Alien::proj->can ('bin_dirs');
|
156
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
17
|
local $ENV{PATH} = $ENV{PATH};
|
158
|
1
|
50
|
|
|
|
16
|
unshift @PATH, @alien_bins
|
159
|
|
|
|
|
|
|
if @alien_bins;
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# something of a hack
|
162
|
1
|
|
|
|
|
63
|
local $ENV{LD_LIBRARY_PATH} = $ENV{LD_LIBRARY_PATH};
|
163
|
1
|
|
|
|
|
6
|
push @LD_LIBRARY_PATH, Alien::gdal->dist_dir . '/lib';
|
164
|
|
|
|
|
|
|
|
165
|
1
|
|
|
|
|
302
|
local $ENV{DYLD_LIBRARY_PATH} = $ENV{DYLD_LIBRARY_PATH};
|
166
|
1
|
|
|
|
|
5
|
push @DYLD_LIBRARY_PATH, Alien::gdal->dist_dir . '/lib';
|
167
|
|
|
|
|
|
|
|
168
|
1
|
50
|
|
|
|
276
|
if ($self->install_type eq 'share') {
|
169
|
1
|
|
|
|
|
24
|
my @bin_dirs = $self->bin_dir;
|
170
|
1
|
|
50
|
|
|
365
|
my $bin = $bin_dirs[0] // '';
|
171
|
1
|
|
|
|
|
4
|
$utility = "$bin/$utility"; # should strip path from $utility first?
|
172
|
|
|
|
|
|
|
}
|
173
|
|
|
|
|
|
|
# handle spaces in path
|
174
|
1
|
50
|
|
|
|
7
|
if ($^O =~ /mswin/i) {
|
175
|
0
|
0
|
|
|
|
0
|
if ($utility =~ /\s/) {
|
176
|
0
|
|
|
|
|
0
|
$utility = qq{"$utility"};
|
177
|
|
|
|
|
|
|
}
|
178
|
|
|
|
|
|
|
}
|
179
|
|
|
|
|
|
|
else {
|
180
|
1
|
|
|
|
|
3
|
$utility =~ s|(\s)|\$1|g;
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# user gets the pieces if it breaks
|
185
|
1
|
|
|
1
|
|
49
|
capture {system $utility, @args};
|
|
1
|
|
|
|
|
60611
|
|
186
|
|
|
|
|
|
|
}
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub data_dir {
|
189
|
1
|
|
|
1
|
0
|
615
|
my $self = shift;
|
190
|
|
|
|
|
|
|
|
191
|
1
|
|
|
|
|
8
|
my $path = $self->dist_dir . '/share/gdal';
|
192
|
|
|
|
|
|
|
|
193
|
1
|
50
|
|
|
|
416
|
if (!-d $path) {
|
194
|
|
|
|
|
|
|
# try PkgConfig
|
195
|
4
|
|
|
4
|
|
4195
|
use PkgConfig;
|
|
4
|
|
|
|
|
597259
|
|
|
4
|
|
|
|
|
1806
|
|
196
|
0
|
|
|
|
|
0
|
my %options;
|
197
|
0
|
0
|
|
|
|
0
|
if (-d $self->dist_dir . '/lib/pkgconfig') {
|
198
|
0
|
|
|
|
|
0
|
$options{search_path_override} = [$self->dist_dir . '/lib/pkgconfig'];
|
199
|
|
|
|
|
|
|
}
|
200
|
0
|
|
|
|
|
0
|
my $o = PkgConfig->find('gdal', %options);
|
201
|
0
|
0
|
|
|
|
0
|
if ($o->errmsg) {
|
202
|
0
|
|
|
|
|
0
|
warn $o->errmsg;
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
else {
|
205
|
0
|
|
|
|
|
0
|
$path = $o->get_var('datadir');
|
206
|
0
|
0
|
|
|
|
0
|
if ($path =~ m|/data$|) {
|
207
|
0
|
|
|
|
|
0
|
my $alt_path = $path;
|
208
|
0
|
|
|
|
|
0
|
$alt_path =~ s|/data$||;
|
209
|
0
|
0
|
0
|
|
|
0
|
if (!-d $path && -d $alt_path) {
|
210
|
|
|
|
|
|
|
# GDAL 2.3.x and earlier erroneously appended /data
|
211
|
0
|
|
|
|
|
0
|
$path = $alt_path;
|
212
|
|
|
|
|
|
|
}
|
213
|
|
|
|
|
|
|
}
|
214
|
|
|
|
|
|
|
}
|
215
|
|
|
|
|
|
|
}
|
216
|
|
|
|
|
|
|
|
217
|
1
|
50
|
33
|
|
|
20
|
warn "Cannot find gdal data dir"
|
218
|
|
|
|
|
|
|
if not (defined $path and -d $path);
|
219
|
|
|
|
|
|
|
|
220
|
1
|
|
|
|
|
6
|
return $path;
|
221
|
|
|
|
|
|
|
}
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1;
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
__END__
|