Alien-gdal
view release on metacpan or search on metacpan
# add existing alien files to path etc
# not very elegant...
# disable for now - config tests fail
# it looks to be already noted in https://github.com/Perl5-Alien/Alien-Build/issues/12
# might also be able to access via old hash via https://metacpan.org/pod/Alien::Build#install_prop
my $have_alien_gdal = eval 'require Alien::gdal';
my $copy_from_dir;
if ($ENV{ALIEN_SHARE_RECYCLE} && $have_alien_gdal && Alien::gdal->install_type eq 'share') {
my $ag_version = Alien::gdal->version;
say "Found existing gdal via alien ($ag_version) in " . Alien::gdal->dist_dir;
# append the relevant path
if (versioncmp($ag_version, $min_target_version) >= 0) {
$copy_from_dir = Alien::gdal->dist_dir;
}
}
if ($copy_from_dir) {
# files are copied in the extract hook
meta->register_hook(download => sub {
Path::Tiny->new ('fauxdownload.txt')->touch;
}
}
my $make_cmd = '%{make}';
my $make_inst_cmd = '%{make} install';
my @automated_rig_config_args;
# try not to exceed the cpan-testers log limits
if ($on_automated_rig) {
say "Running under CI or automated testing";
$make_cmd .= q/ | perl -ne "BEGIN {$|=1; open our $log, q|>|, q|build.log|}; print qq|\n| if 0 == ($. %% 100); print q|.|; print {$log} $_;" /;
$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} $_;" /;
if (!$on_windows) {
$make_cmd =~ s/%%/%/;
$make_cmd =~ s/"/'/g;
$make_cmd .= ' || (E=$? && cat build.log && exit $E)';
$make_inst_cmd =~ s/%%/%/;
$make_inst_cmd =~ s/"/'/g;
$make_inst_cmd .= ' || (E=$? && cat install.log && exit $E)';
}
if ($^O =~ /darwin/) {
push @DYLD_LIBRARY_PATH, @ld_lib_path;
Alien::Build->log('DYLD_LIBRARY_PATH: ' . join ':', grep {defined} @DYLD_LIBRARY_PATH);
}
else {
push @LD_LIBRARY_PATH, @ld_lib_path;
Alien::Build->log('LD_LIBRARY_PATH: ' . join ':', grep {defined} @LD_LIBRARY_PATH);
}
#foreach my $env_var (qw /LD_LIBRARY_PATH DYLD_LIBRARY_PATH LDFLAGS CFLAGS CXXFLAGS/) {
# say "ENV: $env_var is " . ($ENV{$env_var} // '');
#}
if (@cmake_prefix_path) {
my $path = join $Config{path_sep}, @cmake_prefix_path;
meta->around_hook(
build => sub {
my ($orig, $build, @args) = @_;
$build->log("Setting CMAKE_PREFIX_PATH to $path");
local $ENV{CMAKE_PREFIX_PATH} = $path;
$orig->($build, @args);
}
}
#$orig->($build, @args);
return;
}
sub update_pkg_conf_path {
return if !$on_windows;
use Env qw /@PKG_CONFIG_PATH/;
say 'Modifying drive paths in PKG_CONFIG_PATH';
say $ENV{PKG_CONFIG_PATH};
# msys-ificate drive paths
@PKG_CONFIG_PATH = map {my $x = $_; $x =~ s{^([a-z]):}{/$1}i; $x} @PKG_CONFIG_PATH;
say $ENV{PKG_CONFIG_PATH};
return;
}
# git for windows clashes with MSYS
# if its /usr/bin dir is in the path
sub remove_gitfw_from_path {
my ($orig, $build, @args) = @_;
return $orig->($build, @args)
}
$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 patch_pkgconfig {
#my $gdal_config_file = 'bin/gdal-config';
#my $pkg_config_file = 'lib/pkgconfig/gdal.pc';
use File::Find::Rule;
my @gdal_configs
= File::Find::Rule->file()
->name( 'gdal-config' )
->in( '.' );
my @pkg_configs
= File::Find::Rule->file()
->name( 'gdal.pc' )
->in( '.' );
say 'gdal-configs: ' . join ' ', @gdal_configs;
say 'pkg-configs: ' . join ' ', @pkg_configs;
return if !@gdal_configs || !@pkg_configs;
open my $gc_fh, '<', $gdal_configs[0] or die $!;
my $dep_libs = '';
while (defined (my $line = <$gc_fh>)) {
if ($line =~ /CONFIG_DEP_LIBS=(.+)$/) {
$dep_libs = $1;
last;
}
open my $pk_fh, '<', $pkg_configs[0] or die $!;
my @pkg_conf;
while (defined (my $line = <$pk_fh>)) {
push @pkg_conf, $line;
}
close $pk_fh;
# change all (we should be more nuanced and do only the one that matters)
foreach my $pkg_config_file (@pkg_configs) {
say "Adding gdal dep_libs to $pkg_config_file";
# now add the dep libs to the pkg_conf file
open $pk_fh, '>', $pkg_config_file or die $!;
foreach my $line (@pkg_conf) {
if ($line =~ /^CONFIG_INST_LIBS/) {
chomp $line;
$line .= " $dep_libs\n";
}
print {$pk_fh} $line;
}
close $pk_fh;
( run in 1.091 second using v1.01-cache-2.11-cpan-483215c6ad5 )