mirror of
https://git.proxmox.com/git/perlmod
synced 2025-10-04 22:07:05 +00:00
genpackage: change library loading
Replace the 'libdirs()' function with a 'libfile()' function. To text a fixed file, we should only place that one file in there in test suites. Additionally, search LD_LIBRARY_PATH before the auto-dirs, which should make custom testing via the command line easier as well. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
fa7d62bf37
commit
c6d49a8cde
@ -135,20 +135,26 @@ use warnings;
|
|||||||
|
|
||||||
use DynaLoader;
|
use DynaLoader;
|
||||||
|
|
||||||
sub library {
|
sub library { '{{LIBRARY}}' }
|
||||||
return '{{LIBRARY}}';
|
|
||||||
|
sub autodirs { map { "$_/auto" } @INC; }
|
||||||
|
sub envdirs { grep { length($_) } split(/:+/, $ENV{LD_LIBRARY_PATH} // '') }
|
||||||
|
|
||||||
|
sub find_lib {
|
||||||
|
my ($mod_name) = @_;
|
||||||
|
my @dirs = map { "-L$_" } (envdirs(), autodirs());
|
||||||
|
return DynaLoader::dl_findfile(@dirs, $mod_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Keep on a single line, modified by testsuite!
|
# Keep on a single line, potentially modified by testsuite!
|
||||||
sub libdirs { return (map "-L$_/auto", @INC); }
|
sub libfile { find_lib() }
|
||||||
|
|
||||||
sub load : prototype($) {
|
sub load : prototype($) {
|
||||||
my ($pkg) = @_;
|
my ($pkg) = @_;
|
||||||
|
|
||||||
my $mod_name = $pkg->library();
|
my $mod_name = $pkg->library();
|
||||||
|
|
||||||
my @dirs = $pkg->libdirs();
|
my $mod_file = find_lib($mod_name);
|
||||||
my $mod_file = DynaLoader::dl_findfile({{DEBUG_LIBPATH}}@dirs, $mod_name);
|
|
||||||
die "failed to locate shared library for $mod_name (lib${mod_name}.so)\n" if !$mod_file;
|
die "failed to locate shared library for $mod_name (lib${mod_name}.so)\n" if !$mod_file;
|
||||||
|
|
||||||
my $lib = DynaLoader::dl_load_file($mod_file)
|
my $lib = DynaLoader::dl_load_file($mod_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user