Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up new dynamics loading code (DynaLoader-style). This should ho…

…pefully fix #10
  • Loading branch information...
commit c1378f80bac1833bb9d3466b22fdbc4c8aae373c 1 parent 95131c8
@jberger jberger authored
Showing with 22 additions and 15 deletions.
  1. +22 −15 lib/Alien/Base.pm
View
37 lib/Alien/Base.pm
@@ -19,6 +19,14 @@ use Capture::Tiny qw/capture_merged/;
sub import {
my $class = shift;
+ # get a reference to %Alien::MyLibrary::AlienLoaded
+ # which contains names of already loaded libraries
+ # this logic may be replaced by investigating the DynaLoader arrays
+ my $loaded = do {
+ no strict 'refs';
+ \%{ $class . "::AlienLoaded" };
+ };
+
return if $class->install_type('system');
my $libs = $class->libs;
@@ -27,26 +35,25 @@ sub import {
my @l = $libs =~ /(-l\S+)/g;
push @DynaLoader::dl_library_path, @L;
- my @libpaths = map { DynaLoader::dl_findfile( $_ ) } @l;
- my @unresolved = grep { ! -e } @libpaths;
- carp "Could not resolve libraries @unresolved" if @unresolved;
-
- push @DynaLoader::dl_resolve_using, @libpaths;
- my @librefs = map { DynaLoader::dl_load_file( $_ ) } @libpaths;
- push @DynaLoader::dl_librefs, @librefs;
+ my @libpaths;
+ foreach my $l (@l) {
+ next if $loaded->{$l};
- #TODO investigate using Env module for this (VMS problems?)
- #my $var = is_os_type('Windows') ? 'PATH' : 'LD_RUN_PATH';
+ my $path = DynaLoader::dl_findfile( $l );
+ unless ($path) {
+ carp "Could not resolve $l";
+ next;
+ }
- #unshift @L, $ENV{$var} if $ENV{$var};
+ push @libpaths, $path;
+ $loaded->{$l} = $path;
+ }
- #TODO check if existsin $ENV{$var} to prevent "used once" warnings
+ push @DynaLoader::dl_resolve_using, @libpaths;
- #no strict 'refs';
- #$ENV{$var} = join( $Config::Config{path_sep}, @L )
- # unless ${ $class . "::AlienEnv" }{$var}++;
- # %Alien::MyLib::AlienEnv has keys like ENV_VAR => int (true if loaded)
+ my @librefs = map { DynaLoader::dl_load_file( $_ ) } @libpaths;
+ push @DynaLoader::dl_librefs, @librefs;
}
Please sign in to comment.
Something went wrong with that request. Please try again.