| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::proj; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 4 |  |  | 4 |  | 422162 | use strict; | 
|  | 4 |  |  |  |  | 24 |  | 
|  | 4 |  |  |  |  | 86 |  | 
| 4 | 4 |  |  | 4 |  | 15 | use warnings; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 78 |  | 
| 5 | 4 |  |  | 4 |  | 305 | use parent qw( Alien::Base ); | 
|  | 4 |  |  |  |  | 210 |  | 
|  | 4 |  |  |  |  | 23 |  | 
| 6 | 4 |  |  | 4 |  | 45395 | use Env qw ( @PATH @LD_LIBRARY_PATH @DYLD_LIBRARY_PATH ); | 
|  | 4 |  |  |  |  | 1894 |  | 
|  | 4 |  |  |  |  | 18 |  | 
| 7 | 4 |  |  | 4 |  | 611 | use Capture::Tiny qw /:all/; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 371 |  | 
| 8 | 4 |  |  | 4 |  | 337 | use File::Which qw /which/; | 
|  | 4 |  |  |  |  | 701 |  | 
|  | 4 |  |  |  |  | 127 |  | 
| 9 | 4 |  |  | 4 |  | 17 | use List::Util qw /uniq/; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 1722 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | our $VERSION = '1.23'; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | #  adding to global {DY}LD_LIBRARY_PATH vars is icky but seems | 
| 14 |  |  |  |  |  |  | #  to be needed for utilities and downstream FFI | 
| 15 |  |  |  |  |  |  | my %also; | 
| 16 |  |  |  |  |  |  | my @alien_bins = (__PACKAGE__->bin_dir); | 
| 17 |  |  |  |  |  |  | my @ld_lib_dirs; | 
| 18 |  |  |  |  |  |  | foreach my $alien_lib (qw /Alien::libtiff Alien::sqlite/) { | 
| 19 |  |  |  |  |  |  | if (eval "require $alien_lib" && $alien_lib->install_type eq 'share') { | 
| 20 |  |  |  |  |  |  | $also{$alien_lib}++; | 
| 21 |  |  |  |  |  |  | if ($alien_lib->install_type eq 'share') { | 
| 22 |  |  |  |  |  |  | push @alien_bins, $alien_lib->bin_dir; | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  | push @ld_lib_dirs, $alien_lib->dist_dir . q{/lib}; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  | if (eval 'require Alien::curl' && 'Alien::curl'->install_type eq 'share') { | 
| 28 |  |  |  |  |  |  | #  we only compile in libcurl when there is a dynamic curl-config | 
| 29 |  |  |  |  |  |  | if (-e 'Alien::curl'->dist_dir . '/dynamic/curl-config') { | 
| 30 |  |  |  |  |  |  | $also{'Alien::curl'}++; | 
| 31 |  |  |  |  |  |  | if (Alien::curl->install_type eq 'share') { | 
| 32 |  |  |  |  |  |  | push @alien_bins,  Alien::curl->dist_dir . '/dynamic'; | 
| 33 |  |  |  |  |  |  | push @ld_lib_dirs, Alien::curl->dist_dir . '/dynamic' | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  | #if ($^O =~ /darwin/i) { | 
| 38 |  |  |  |  |  |  | #    @DYLD_LIBRARY_PATH = grep {defined} uniq (@DYLD_LIBRARY_PATH, @ld_lib_dirs); | 
| 39 |  |  |  |  |  |  | #} | 
| 40 |  |  |  |  |  |  | #elsif (not $^O =~ /mswin/i) { | 
| 41 |  |  |  |  |  |  | #    @LD_LIBRARY_PATH = grep {defined} uniq (@LD_LIBRARY_PATH, @ld_lib_dirs) | 
| 42 |  |  |  |  |  |  | #} | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub bin_dirs { | 
| 46 | 2 |  |  | 2 | 0 | 4219 | my $self = shift; | 
| 47 | 2 |  |  |  |  | 16 | return @alien_bins; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub dynamic_libs { | 
| 51 | 2 |  |  | 2 | 1 | 6735 | my ($self) = @_; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 2 |  |  |  |  | 18 | my @libs = $self->SUPER::dynamic_libs; | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 2 |  |  |  |  | 12878 | foreach my $lib (sort keys %also) { | 
| 56 | 2 |  |  |  |  | 15 | push @libs, $lib->dynamic_libs; | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 2 |  |  |  |  | 4594 | return @libs; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | sub run_utility { | 
| 63 | 1 |  |  | 1 | 0 | 118 | my ($self, $utility, @args) = @_; | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 1 | 50 | 33 |  |  | 11 | if (__PACKAGE__->install_type eq 'system' && !which 'projinfo') { | 
| 66 | 0 |  |  |  |  | 0 | warn __PACKAGE__ . " is a system install but lacks the utilities\n" | 
| 67 |  |  |  |  |  |  | . "Perhaps try a share install."; | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  |  | 
| 70 | 1 |  |  |  |  | 19 | local $ENV{PATH} = $ENV{PATH}; | 
| 71 | 1 |  |  |  |  | 4 | unshift @PATH, $self->bin_dirs; | 
| 72 |  |  |  |  |  |  | #if @alien_bins; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | #  something of a hack | 
| 75 | 1 |  |  |  |  | 29 | local $ENV{LD_LIBRARY_PATH} = $ENV{LD_LIBRARY_PATH}; | 
| 76 | 1 |  |  |  |  | 5 | push @LD_LIBRARY_PATH, $self->dist_dir . '/lib'; | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 1 |  |  |  |  | 286 | local $ENV{DYLD_LIBRARY_PATH} = $ENV{DYLD_LIBRARY_PATH}; | 
| 79 | 1 |  |  |  |  | 4 | push @DYLD_LIBRARY_PATH, $self->dist_dir . '/lib'; | 
| 80 |  |  |  |  |  |  |  | 
| 81 | 1 | 50 |  |  |  | 195 | if ($self->install_type eq 'share') { | 
| 82 | 1 |  |  |  |  | 20 | my $bin = $self->bin_dir; | 
| 83 | 1 | 50 |  |  |  | 238 | if (defined $bin) { | 
| 84 |  |  |  |  |  |  | #  should strip path from $utility | 
| 85 |  |  |  |  |  |  | #  if user specified one? | 
| 86 | 1 |  |  |  |  | 2 | $utility = "$bin/$utility"; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  | #  handle spaces in path | 
| 90 | 1 | 50 |  |  |  | 6 | if ($^O =~ /mswin/i) { | 
| 91 | 0 | 0 |  |  |  | 0 | if ($utility =~ /\s/) { | 
| 92 | 0 |  |  |  |  | 0 | $utility = qq{"$utility"}; | 
| 93 |  |  |  |  |  |  | } | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  | else { | 
| 96 | 1 |  |  |  |  | 2 | $utility =~ s|(\s)|\$1|g; | 
| 97 |  |  |  |  |  |  | } | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | #  user gets the pieces if it breaks | 
| 101 | 1 |  |  | 1 |  | 23 | capture {system $utility, @args}; | 
|  | 1 |  |  |  |  | 7421 |  | 
| 102 |  |  |  |  |  |  | } | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | 1; | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | __END__ |