Alien-spatialite
view release on metacpan or search on metacpan
return if !$on_windows;
use File::Find::Rule;
my @la_files
= File::Find::Rule->file()
->name( '*.la' )
->in( '.' );
foreach my $file (@la_files) {
Alien::Build->log("Renaming $file so it will not interfere with gdal compilation");
rename $file, $file . '.bak';
}
}
# should be a gather hook working on the stage dir
sub patch_rpaths {
my ($build) = @_;
# only run on unices - incomplete check but
# I don't think aliens work on VMS or zOS
return if ($on_windows or $^O =~ /darwin/i);
my $h = get_alien_state_hash();
my $install_path = $h->{install}{prefix};
return if !defined $install_path;
my @alien_rpaths;
for my $alien (@alien_deps) {
next if not $alien->install_type('share');
push @alien_rpaths, $alien->dist_dir . '/lib';
}
if (!@alien_rpaths) {
$build->log('No shared alien deps found, not updating rpaths');
return;
}
my $origin_string = $^O =~ /darwin/ ? '@loader_path' : '${ORIGIN}';
my $alien_rpath_text
= join ':', (
(map {$origin_string . '/../' . path ($_)->relative($install_path)->stringify} @alien_rpaths),
@alien_rpaths
);
$build->log ("Prepending rpaths with $alien_rpath_text");
use File::Find::Rule;
my (@so_files)
= grep {not -l $_}
File::Find::Rule
->file()
->name( qr/^(lib|mod_)spatialite.so.?/ )
->in( getcwd() );
eval 'require Alien::patchelf'
or do {
warn 'Unable to load Alien::patchelf ($@), cannot update rpaths';
return;
};
my $pe = Alien::patchelf->new;
foreach my $so_file (@so_files) {
my ($old_rpath, $result, $stderr, @errors);
($old_rpath, $stderr, @errors)
= $pe->patchelf ('--print-rpath', $so_file);
$old_rpath //= '';
# prepend our paths
my $rpath = $alien_rpath_text . ($old_rpath ? (':' . $old_rpath) : '');
$build->log("Updating rpath for $so_file to $rpath, was $old_rpath");
($result, $stderr, @errors)
= $pe->patchelf ('--set-rpath', $rpath, $so_file);
warn $stderr if $stderr;
}
return;
}
sub set_compiler_flags {
my ($orig, $build, @args) = @_;
local $ENV{CFLAGS} = "-O2 " . ($ENV{CFLAGS} // '');
local $ENV{CXXFLAGS} = '-O2 ' . ($ENV{CXXFLAGS} // '');
$build->log ("Setting compiler flag env vars to -O2");
$orig->($build, @args);
}
sub pause {
return; # re-enable in case of debug
return if $on_automated_rig;
return if !$on_windows;
say "CONTINUE?";
my $response = <>;
while (not $response =~ /yes/) {
$response = <>;
}
}
sub get_lib_version {
my $h = get_alien_state_hash();
return $h->{runtime}{version};
}
sub get_alien_state_hash {
use JSON::PP;
my $root = "$base_dir/_alien";
my $f = "$root/state.json";
my $h = {};
if (-e $f) {
open my $fh, '<', $f or die $!;
my $d = do {
local $/ = undef;
<$fh>;
};
$h = JSON::PP::decode_json($d);
}
return $h;
}
( run in 1.230 second using v1.01-cache-2.11-cpan-f6376fbd888 )