Alien-proj
view release on metacpan or search on metacpan
my @dep_aliens = ('Alien::sqlite');
my %have;
my $lib = 'Alien::curl';
$have{$lib} = eval "require $lib";
if ($have{$lib}) {
unshift @PATH, $lib->dist_dir . '/dynamic';
}
$lib = 'Alien::libtiff';
$have{$lib} = eval "require $lib";
if ($have{$lib}) {
#say 'Adding libtiff dependency';
unshift @PATH, $lib->bin_dir;
push @dep_aliens, $lib if $lib->install_type eq 'share';
my $p;
if ($on_windows && $lib->install_type eq 'system') {
# dirty hack for strawberry perl
$p = path ($^X)->parent->parent->parent . '/c/lib/pkgconfig';
}
elsif ($lib->install_type eq 'share') {
$p = path ($lib->dist_dir, 'lib', 'pkgconfig');
}
if ($p && -e $p) {
push @PKG_CONFIG_PATH, $p;
say join ' ', @PKG_CONFIG_PATH;
}
}
say "Alien::sqlite has sqlite version " . Alien::sqlite->version;
my $min_target_version = '7.1';
plugin 'PkgConfig' => (
pkg_name => 'proj',
minimum_version => $min_target_version,
);
if ($on_windows) {
# possible GIS Internals distribution
if (my $path = `where geos_c.dll`) {
}
}
}
share {
# see if this helps with cirrus bsd builds
#$ENV{SQLITE3_CFLAGS} = Alien::sqlite->cflags;
#$ENV{SQLITE3_LIBS} = Alien::sqlite->libs;
#say "sqlite cflags: " . Alien::sqlite->cflags;
#say "sqlite libs: " . Alien::sqlite->libs;
#if ($have{'Alien::libtiff'}) {
# my $p = path ('Alien::libtiff'->dist_dir, 'lib');
# $ENV{TIFF_LIBS}
# ||= (-e $p
# ? "-L$p "
# : ''
# )
# . 'Alien::libtiff'->libs;
# say "libtiff libs: $ENV{TIFF_LIBS}";
#}
plugin 'Build::SearchDep' => (
aliens => [ grep {$_->install_type eq 'share'} @dep_aliens ],
public_I => 1,
public_l => 1,
);
if ($on_windows) {
}
start_url 'https://download.osgeo.org/proj/';
#start_url "file://$base_dir"; # debug
plugin Download => (
filter => qr/^proj-([0-9\.]+)\.tar\.gz$/,
version => qr/^proj-([0-9\.]+)\.tar\.gz$/,
);
my $proj_version = get_proj_version() // 'not yet defined';
say "Downloaded proj version is $proj_version";
die "Downloaded proj version $proj_version is too low "
. "(should be >= $min_target_version).\n"
. "Please update your Alien::Build::Fetch::Cache if using one."
if defined $proj_version
&& versioncmp ($proj_version, $min_target_version) < 0;
plugin Extract => (format => 'tar.gz');
}
elsif ($^O eq 'MSWin32') {
plugin 'Build::Make' => 'gmake';
}
my $make_cmd = '%{make}';
my $make_inst_cmd = '%{make} install';
my @make_clean;
# 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} $_;" || type build.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} $_;" || type install.log/;
#if (!$on_windows) {
# $make_cmd =~ s/%%/%/;
# $make_cmd =~ s/type/cat/;
# $make_cmd =~ s/"/'/g;
# $make_inst_cmd =~ s/%%/%/;
# $make_inst_cmd =~ s/type/cat/;
# $make_inst_cmd =~ s/"/'/g;
#}
$build->log("Setting CCACHE_BASEDIR to " . getcwd());
local $ENV{CCACHE_BASEDIR} = getcwd();
$orig->($build, @args);
}
);
# silence an undef warning
Alien::Build->log ('PKG_CONFIG_PATH:' . join ' ', grep {defined} @PKG_CONFIG_PATH);
foreach my $env_var (qw /LD_LIBRARY_PATH LDFLAGS CFLAGS CXXFLAGS/) {
say "ENV: $env_var is " . ($ENV{$env_var} // '');
}
# try to fix some rpath issues
# See also:
# https://github.com/OSGeo/gdal/issues/5413#issuecomment-1060286925
my $h = get_alien_state_hash();
my $install_path = $h->{install}{prefix};
my @rpath;
if (!$on_windows && defined $install_path && @alien_rpaths) {
my $origin_string = $^O =~ /darwin/ ? '@loader_path' : '$ORIGIN';
$orig->($build, @args);
}
sub update_pkg_conf_path {
return;
return if !$on_windows;
# should be a before or around hook
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 $r=$_; $r=~s{^([a-z]):}{/$1}i; $r} @PKG_CONFIG_PATH;
# make sure we get the dynamic libcurl
# (although the proj configure script does not currently use it)
@PKG_CONFIG_PATH
= map {my $r=$_; $r=~s{Alien-curl[/\\]lib[/\\]pkgconfig}{Alien-curl/dynamic/pkgconfig}i; $r}
@PKG_CONFIG_PATH;
$ENV{PKG_CONFIG_PATH} = join ':', @PKG_CONFIG_PATH;
say $ENV{PKG_CONFIG_PATH};
return;
}
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 update_cmake_lists_file {
my ($orig, $build, @args) = @_;
# only needed on windows for v9.0.0 or earlier
my $define_check = <<EOD
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
EOD
;
while (my $line = <$fh>) {
if ($line =~ /^\s*configure_proj_pc/) {
#say STDERR "ADDING TO CMAKE LISTS";
$line .= $define_check;
}
$file_contents .= $line;
}
$fh->close;
rename $cmake_lists_file, "$cmake_lists_file.bak";
open my $ofh, '>', $cmake_lists_file
or die "Could not open $cmake_lists_file for writing, $!";
print {$ofh} $file_contents;
t/00-load.t view on Meta::CPAN
}
sub _diag_dynamic_libs_ldd {
my $LDD = which('ldd')
or diag "ldd not found, skipping dynamic lib summary";
my @target_libs = Alien::proj->dynamic_libs;
my %seen;
while (my $lib = shift @target_libs) {
#say "ldd $lib";
my $out = qx /$LDD $lib/;
warn qq["ldd $lib" failed\n]
if not $? == 0;
diag "$lib:";
diag $out;
# much of this logic is from PAR::Packer
# https://github.com/rschupp/PAR-Packer/blob/04a133b034448adeb5444af1941a5d7947d8cafb/myldr/find_files_to_embed/ldd.pl#L47
my %dlls = $out =~ /^ \s* (\S+) \s* => \s* ( \/ \S+ ) /gmx;
t/00-load.t view on Meta::CPAN
foreach my $name (keys %dlls) {
if ($seen{$name}) {
delete $dlls{$name};
next DLL;
}
$seen{$name}++;
my $path = path($dlls{$name})->realpath;
#say "Checking $name => $path";
if (not -r $path) {
warn qq[# ldd reported strange path: $path\n];
delete $dlls{$name};
}
elsif (
$path =~ m{^(?:/usr)?/lib(?:32|64)?/} # system lib
or $name =~ m{^lib(?:c|gcc_s|stdc\+\+)\.}
) {
delete $dlls{$name};
t/00-load.t view on Meta::CPAN
}
push @target_libs, values %dlls;
}
}
sub _diag_dynamic_libs_otool {
my $OTOOL = which('otool') or diag "otool not found, skipping dynamic lib summary";
my @target_libs = Alien::proj->dynamic_libs;
my %seen;
while (my $lib = shift @target_libs) {
#say "otool -L $lib";
my @lib_arr = qx /$OTOOL -L $lib/;
note qq["otool -L $lib" failed\n]
if not $? == 0;
diag "$lib:";
diag join "", @lib_arr;
if ($ENV{DIAG_RPATH}) { # noisy so only when called for
my $rpath = qx /$OTOOL -l $lib/;
diag $rpath;
}
shift @lib_arr; # first result is dylib we called otool on
( run in 3.876 seconds using v1.01-cache-2.11-cpan-483215c6ad5 )