Alien-Libarchive-Installer
view release on metacpan or search on metacpan
lib/Alien/Libarchive/Installer.pm view on Meta::CPAN
my $alien = Alien::Libarchive->new;
require File::Spec;
my $dir;
my(@dlls) = map {
my($v,$d,$f) = File::Spec->splitpath($_);
$dir = [$v,File::Spec->splitdir($d)];
$f;
} $alien->dlls;
my $build = bless {
cflags => [$alien->cflags],
libs => [$alien->libs],
dll_dir => $dir,
dlls => \@dlls,
prefix => File::Spec->rootdir,
}, $class;
eval {
$build->test_compile_run || die $build->error if $options{test} =~ /^(compile|both)$/;
$build->test_ffi || die $build->error if $options{test} =~ /^(ffi|both)$/;
};
return $build unless $@;
}
my $build = bless {
cflags => _try_pkg_config(undef, 'cflags', '', ''),
libs => _try_pkg_config(undef, 'libs', '-larchive', ''),
}, $class;
if($options{test} =~ /^(ffi|both)$/)
{
my @dir_search_list;
if($^O eq 'MSWin32')
{
lib/Alien/Libarchive/Installer.pm view on Meta::CPAN
s/^Libs: /Libs: -L\${libdir} /;
}
push @content, "Cflags: -I\${includedir}\n";
}
open my $fh, '>', $pcfile;
print $fh @content;
close $fh;
};
my $build = bless {
cflags => _try_pkg_config($pkg_config_dir, 'cflags', '-I' . File::Spec->catdir($prefix, 'include'), '--static'),
libs => _try_pkg_config($pkg_config_dir, 'libs', '-L' . File::Spec->catdir($prefix, 'lib'), '--static'),
prefix => $prefix,
dll_dir => [ 'dll' ],
dlls => do {
opendir(my $dh, File::Spec->catdir($prefix, 'dll'));
[grep { ! -l File::Spec->catfile($prefix, 'dll', $_) } grep { /\.so/ || /\.(dll|dylib)$/ } grep !/^\./, readdir $dh];
},
}, $class;
t/test_compile_run.t view on Meta::CPAN
BEGIN {
plan skip_all => 'test requires Devel::CheckLib'
unless eval q{ use Devel::CheckLib; 1};
}
plan skip_all => 'requires libarchive already installed'
unless check_lib( lib => 'archive', header => 'archive.h' );
plan tests => 1;
my $installer = bless { cflags => [], libs => ['-larchive'] }, 'Alien::Libarchive::Installer';
my $version = $installer->test_compile_run;
like $version, qr{^[1-9][0-9]*(\.[0-9]+){2}$}, "version = $version";
t/test_ffi.t view on Meta::CPAN
use Alien::Libarchive::Installer;
use DynaLoader;
plan skip_all => 'test requires FFI::Raw'
unless eval { require FFI::Raw };
plan skip_all => 'test requires dynamic libarchive'
unless (defined DynaLoader::dl_findfile('-larchive')) || ($^O eq 'cygwin' && -e '/usr/bin/cygarchive-13.dll');
plan tests => 1;
my $installer = bless { cflags => [], libs => ['-larchive'] }, 'Alien::Libarchive::Installer';
my $version = $installer->test_ffi;
like $version, qr{^[1-9][0-9]*(\.[0-9]+){2}$}, "version = $version";
( run in 1.169 second using v1.01-cache-2.11-cpan-de7293f3b23 )