File Coverage

alienfile
Criterion Covered Total %
statement 29 41 70.7
branch 2 10 20.0
condition n/a
subroutine 8 10 80.0
pod n/a
total 39 61 63.9


line stmt bran cond sub pod time code
1 1     1   258798 use 5.010;
  1         4  
2 1     1   4 use alienfile;
  1         1  
  1         7  
3 1     1   555 use Sort::Versions;
  1         600  
  1         183  
4            
5             my $on_windows = $^O =~ /mswin/i;
6             my $on_automated_rig
7             = $ENV{PERL_CPAN_REPORTER_DIR}
8             || $ENV{PERL_CPAN_REPORTER_CONFIG}
9             || $ENV{AUTOMATED_TESTING}
10             || $ENV{TRAVIS}
11             || $ENV{APPVEYOR};
12            
13            
14 1     1   8 use Cwd;
  1         2  
  1         791  
15             my $base_dir = getcwd();
16            
17             # make libtool noisy for debug purposes
18             #$ENV{LTFLAGS} = "--debug --verbose" if $on_windows;
19            
20            
21            
22             my $min_target_version = '1.0.4';
23            
24             plugin 'PkgConfig' => (
25             pkg_name => 'freexl',
26             minimum_version => $min_target_version,
27             );
28            
29            
30             share {
31            
32             my $with_local = '';
33             my $with_cpp11 = '';
34            
35             # need to work out how to get latest
36             start_url 'https://www.gaia-gis.it/gaia-sins/freexl-sources/';
37             plugin Download => (
38             filter => qr/^freexl-([0-9\.]+)\.tar\.gz$/,
39             version => qr/^freexl-([0-9\.]+)\.tar\.gz$/,
40             );
41            
42             my $lib_version = get_lib_version() // 'not yet defined';
43             say "Downloaded version is $lib_version";
44            
45             plugin Extract => (format => 'tar.gz');
46            
47            
48             plugin 'Build::Autoconf' => ();
49            
50             my $build_static = ($^O =~ /mswin/i) ? '' : '--disable-shared';
51             $build_static = '';
52             $build_static = '--enable-static=no'; # override - needed? leftover from gdal
53             $build_static = '' if $ENV{FORCE_DYNAMIC};
54            
55            
56             if ($^O =~ /bsd/) {
57             plugin 'Build::Make' => 'gmake';
58             if (-d '/usr/local') {
59             $with_local = ' --with-local=/usr/local ';
60             }
61             }
62             elsif ($^O =~ /dragonfly/) {
63             # might need to be combined with bsd check above
64             # but not sure if /usr/local is needed yet
65             plugin 'Build::Make' => 'gmake';
66             }
67            
68             my $make_cmd = '%{make}';
69             my $make_inst_cmd = '%{make} install';
70             my @make_clean;
71             # try not to exceed the cpan-testers log limits
72             if ($on_automated_rig) {
73             say "Running under CI or automated testing";
74             $make_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|build.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" || type build.log/;
75             $make_inst_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|install.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" || type install.log/;
76             if (!$on_windows) {
77             $make_cmd =~ s/%%/%/;
78             $make_cmd =~ s/type/cat/;
79             $make_cmd =~ s/"/'/g;
80             $make_inst_cmd =~ s/%%/%/;
81             $make_inst_cmd =~ s/type/cat/;
82             $make_inst_cmd =~ s/"/'/g;
83             }
84             #if (! ($ENV{TRAVIS} || $ENV{APPVEYOR})) {
85             # push @make_clean, '%{make} clean';
86             #}
87             # clean up the build dir on cpan testers etc
88             plugin 'Cleanse::BuildDir';
89             }
90            
91             build [
92             "%{configure} $with_local $with_cpp11 $build_static --disable-xmldocs",
93             \&pause,
94             $make_cmd,
95             $make_inst_cmd,
96             #@make_clean
97             ];
98            
99             };
100            
101            
102             gather [
103             \&rename_la_files,
104             ];
105            
106             sub rename_la_files {
107             # need to return if not share
108 0 0   0   0 return if !$on_windows;
109            
110 1     1   618 use File::Find::Rule;
  1         11790  
  1         9  
111             my @la_files
112 0         0 = File::Find::Rule->file()
113             ->name( '*.la' )
114             ->in( '.' );
115 0         0 foreach my $file (@la_files) {
116 0         0 say "Renaming $file so it will not intefere with gdal compilation";
117 0         0 rename $file, $file . '.bak';
118             }
119            
120             }
121            
122            
123             sub pause {
124 0     0   0 return; # re-enable in case of debug
125 0 0       0 return if $on_automated_rig;
126 0 0       0 return if !$on_windows;
127            
128 0         0 say "CONTINUE?";
129 0         0 my $response = <>;
130 0         0 while (not $response =~ /yes/) {
131 0         0 $response = <>;
132             }
133             }
134            
135            
136             sub get_lib_version {
137 1     1   5 my $h = get_alien_state_hash();
138 1         21 return $h->{runtime}{version};
139             }
140            
141             sub get_alien_state_hash {
142 1     1   278 use JSON::PP;
  1         1  
  1         176  
143 1     1   4 my $root = "$base_dir/_alien";
144 1         6 my $f = "$root/state.json";
145 1         3 my $h = {};
146 1 50       58 if (-e $f) {
147 1 50       53 open my $fh, '<', $f or die $!;
148 1         3 my $d = do {
149 1         7 local $/ = undef;
150 1         27 <$fh>;
151             };
152 1         5198 $h = JSON::PP::decode_json($d);
153             }
154 1         7 return $h;
155             }
156