Alien-proj
view release on metacpan or search on metacpan
pkg_name => 'proj',
minimum_version => $min_target_version,
);
if ($on_windows) {
# possible GIS Internals distribution
if (my $path = `where geos_c.dll`) {
Alien::Build->log ('Found possible GIS Internals build');
$path = Path::Tiny::path ($path)->parent;
# could be several variants
my @proj_dlls
= map {$_->[0]}
sort { versioncmp($a->[-1], $b->[-1]) }
map { $_ =~ /(\d+)_(\d+)/; [$_, "$1.$2"] }
glob ("$path/proj*.dll");
$proj_dlls[-1] =~ /(\d+)_(\d+)/;
my $version = "$1.$2";
if (versioncmp ($version, $min_target_version) > 0) {
$path = Path::Tiny::path($proj_dlls[-1])->parent->stringify;
$path =~ s|\\|/|g; # path separators
Alien::Build->log ("Probe::CBuilder checking $path");
plugin 'Probe::CBuilder' => (
cflags => "-I$path/include",
libs => "-L$path/lib -lproj",
);
}
}
}
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) {
# there are issues with strawberry perl's gcc
plugin 'Prefer::BadVersion' => '7.1.0';
}
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');
plugin 'Build::CMake' => ();
plugin 'Build::MSYS';
if ($^O =~ /bsd|dragonfly/) {
plugin 'Build::Make' => 'gmake';
if (!-e '/usr/local/include/sqlite3.h' && Alien::sqlite->install_type eq 'system') {
warn '/usr/local/include/sqlite3.h does not exist, '
. 'you might need to install the sqlite package for your system, '
. 'or install a share version of Alien::sqlite';
}
}
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;
#}
#if (! ($ENV{TRAVIS} || $ENV{APPVEYOR})) {
# push @make_clean, '%{make} clean';
#}
# clean up the build dir on cpan testers etc
# but not github workflows
if (!$ENV{CI}) {
plugin 'Cleanse::BuildDir';
}
}
my $config_args = $ENV{ALIEN_PROJ_CONFIG_ARGS} // '';
$cmake_cmd,
$make_cmd,
#($run_tests ? '%{make} test' : ()),
$make_inst_cmd,
];
};
# 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)
if !$on_windows;
local $ENV{PATH} = $ENV{PATH};
my $msys_path = eval {
path('Alien::MSYS'->msys_path())
};
return if !defined $msys_path;
my $count = @PATH;
@PATH
= grep {path($_)->stringify =~ m|/usr/bin$| && path($_) ne $msys_path ? () : $_}
grep {length}
@PATH;
my $removed = $count - @PATH;
if ($removed) {
$build->log ("$removed additional .../usr/bin dirs were removed from the path for compilation");
}
$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
return $orig->($build, @args)
if $on_windows and versioncmp (get_proj_version(), '9.0.0') < 0;
$build->log ('updating CMakeLists.txt to properly handle proj.pc');
#my $h = $build->install_prop;
#use Data::Printer;
#p $h;
use File::Find::Rule;
my ($cmake_lists_file)
= File::Find::Rule
->file()
->name( 'CMakeLists.txt' )
->in( $build->install_prop->{extract} );
#$build->log ("====\ncmake file: $cmake_lists_file \n ====");
open my $fh , '<', $cmake_lists_file
or die "Could not open $cmake_lists_file for reading, $!";
my $file_contents;
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;
$ofh->close or die $!;
$orig->($build, @args);
}
( run in 0.691 second using v1.01-cache-2.11-cpan-02777c243ea )