Skip to content

Commit

Permalink
Disable shared linkage
Browse files Browse the repository at this point in the history
PLplot build currently only supports building one of shared or static
linkage, not both.
  • Loading branch information
zmughal committed Sep 28, 2021
1 parent 1036bef commit 571431e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 34 deletions.
3 changes: 3 additions & 0 deletions alienfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ share {
? ( '-DPKG_CONFIG_EXECUTABLE=' . File::Which::which('pkg-config'), )
: ()
),
qw(
-DBUILD_SHARED_LIBS=OFF
),
@{ meta->prop->{plugin_build_cmake}->{args} },
'%{.install.extract}'
],
Expand Down
34 changes: 0 additions & 34 deletions t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,10 @@ use Test::Alien;
use Test::Alien::Diag;
use Alien::PLplot;

use Env qw(@LD_LIBRARY_PATH @DYLD_FALLBACK_LIBRARY_PATH @PATH);
use DynaLoader;
use File::Basename qw(dirname);

alien_diag 'Alien::PLplot';
alien_ok 'Alien::PLplot';

if( Alien::PLplot->install_type('share') ) {
my $rpath = dirname( ( Alien::PLplot->dynamic_libs )[0] );
unshift @LD_LIBRARY_PATH, $rpath;
unshift @DYLD_FALLBACK_LIBRARY_PATH, $rpath;
unshift @PATH, $rpath;
unshift @DynaLoader::dl_library_path, $rpath;
# load shared object dependencies
for my $lib ( qw(-lcsirocsa -lqsastime -lplplot) ) {
my @files = DynaLoader::dl_findfile($lib);
DynaLoader::dl_load_file($files[0]) if @files;
}
}

my $version_re = qr/^(\d+)\.(\d+)\.(\d+)$/;

my $xs = do { local $/; <DATA> };
Expand All @@ -31,24 +15,6 @@ xs_ok $xs, with_subtest {
like $module->version, $version_re;
};

ffi_ok { symbols => ['c_plgver'] }, with_subtest {
my ($ffi) = @_;
eval q{
use FFI::Platypus::Memory qw( malloc free );
use FFI::Platypus::Buffer qw( scalar_to_buffer );
1; } or skip "$@";
my $get_version = $ffi->function( c_plgver => ['opaque'] => 'void' );

my $buffer = malloc(80);
$get_version->call($buffer);
my $version = $ffi->cast( 'opaque' => 'string', $buffer );

note "version: $version";
like $version, $version_re;

free($buffer);
};

done_testing;
__DATA__
#include "EXTERN.h"
Expand Down
50 changes: 50 additions & 0 deletions t/ffi.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use Test2::V0;
use Test::Alien;
use Alien::PLplot;

use Env qw(@LD_LIBRARY_PATH @DYLD_FALLBACK_LIBRARY_PATH @PATH);
use DynaLoader;
use File::Basename qw(dirname);

if( Alien::PLplot->install_type('share') ) {
if( Alien::PLplot->dynamic_libs ) {
my $rpath = dirname( ( Alien::PLplot->dynamic_libs )[0] );
unshift @LD_LIBRARY_PATH, $rpath;
unshift @DYLD_FALLBACK_LIBRARY_PATH, $rpath;
unshift @PATH, $rpath;
unshift @DynaLoader::dl_library_path, $rpath;
# load shared object dependencies
for my $lib ( qw(-lcsirocsa -lqsastime -lplplot) ) {
my @files = DynaLoader::dl_findfile($lib);
DynaLoader::dl_load_file($files[0]) if @files;
}
} else {
plan skip_all => 'share install does not support dynamic linkage';
}

}

alien_ok 'Alien::PLplot';

my $version_re = qr/^(\d+)\.(\d+)\.(\d+)$/;

ffi_ok { symbols => ['c_plgver'] }, with_subtest {
my ($ffi) = @_;
eval q{
use FFI::Platypus::Memory qw( malloc free );
use FFI::Platypus::Buffer qw( scalar_to_buffer );
1; } or skip "$@";
my $get_version = $ffi->function( c_plgver => ['opaque'] => 'void' );

my $buffer = malloc(80);
$get_version->call($buffer);
my $version = $ffi->cast( 'opaque' => 'string', $buffer );

note "version: $version";
like $version, $version_re;

free($buffer);
};


done_testing;

0 comments on commit 571431e

Please sign in to comment.