| 1 | package Alien::Base; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use Path::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use Capture::Tiny 0.17 qw/capture_stdout/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use Text::ParseWords qw/shellwords/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use Alien::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # ABSTRACT: Base classes for Alien:: modules | ||||||||||||||||||||||||||||
| 14 | 14 | our $VERSION = '2.88'; # VERSION | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=33.4
| |||||||||||||||||||||||||||||
| 18 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | return if $class eq __PACKAGE__; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | return if $class->runtime_prop; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return if $class->install_type('system'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | require DynaLoader; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # Sanity check in order to ensure that dist_dir can be found. | ||||||||||||||||||||||||||||
| 29 | # This will throw an exception otherwise. | ||||||||||||||||||||||||||||
| 30 | 0 | $class->dist_dir; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # get a reference to %Alien::MyLibrary::AlienLoaded | ||||||||||||||||||||||||||||
| 33 | # which contains names of already loaded libraries | ||||||||||||||||||||||||||||
| 34 | # this logic may be replaced by investigating the DynaLoader arrays | ||||||||||||||||||||||||||||
| 35 | 0 | my $loaded = do { | |||||||||||||||||||||||||||
| 36 | 14 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 14 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 0 | \%{ $class . "::AlienLoaded" }; | |||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | my @libs = $class->split_flags( $class->libs ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | my @L = grep { s/^-L// } map { "$_" } @libs; ## no critic (ControlStructures::ProhibitMutatingListFunctions) | |||||||||||||||||||||||||||
| 44 | 0 | my @l = grep { /^-l/ } @libs; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | unshift @DynaLoader::dl_library_path, @L; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | my @libpaths; | |||||||||||||||||||||||||||
| 49 | 0 | foreach my $l (@l) { | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | next if $loaded->{$l}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | my $path = DynaLoader::dl_findfile( $l ); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless ($path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | carp "Could not resolve $l"; | |||||||||||||||||||||||||||
| 55 | 0 | next; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | push @libpaths, $path; | |||||||||||||||||||||||||||
| 59 | 0 | $loaded->{$l} = $path; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | push @DynaLoader::dl_resolve_using, @libpaths; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my @librefs = map { DynaLoader::dl_load_file( $_, 0x01 ) } grep !/\.(a|lib)$/, @libpaths; | |||||||||||||||||||||||||||
| 65 | 0 | push @DynaLoader::dl_librefs, @librefs; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub _dist_dir ($) | ||||||||||||||||||||||||||||
| 71 | 43 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_dist_dir: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 72 | 43 | my($dist_name) = @_; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 43 | my @pm = split /-/, $dist_name; | |||||||||||||||||||||||||||
| 75 | 43 | $pm[-1] .= ".pm"; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 43 | foreach my $inc (@INC) | |||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||
| 79 | 75 | my $pm = Path::Tiny->new($inc, @pm); | |||||||||||||||||||||||||||
| 80 | 75 | ▶ | if(-f $pm) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 43 | my $share = Path::Tiny->new($inc, qw( auto share dist ), $dist_name ); | |||||||||||||||||||||||||||
| 83 | 43 | ▶ | if(-d $share) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||
| 85 | 42 | return $share->absolute->stringify; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 1 | last; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 1 | Carp::croak("unable to find dist share directory for $dist_name"); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 31 | ▶ | sub dist_dir { | ||||||||||||||||||||||||||
|
Subroutine
dist_dir: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 31 | my $class = shift; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 31 | ▶ | my $dist = blessed $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($class) || $class
MC/DC0%0/2
builtin::blessed($class) || $class
builtin::blessed($class)
$class
Truth table33%1/3
A || B
A= builtin::blessed($class)B= $class
| |||||||||||||||||||||||||||||
| 97 | 31 | $dist =~ s/::/-/g; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 31 | ▶ | my $dist_dir = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | $class->config('finished_installing') | ||||||||||||||||||||||||||||
| 101 | ? _dist_dir $dist | ||||||||||||||||||||||||||||
| 102 | : $class->config('working_directory'); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 31 | ▶ | croak "Failed to find share dir for dist '$dist'" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $dist_dir and -d $dist_dir
MC/DC0%0/2
defined $dist_dir and -d $dist_dir
defined $dist_dir
-d $dist_dir
Truth table33%1/3
A and B
A= defined $dist_dirB= -d $dist_dir
| |||||||||||||||||||||||||||||
| 105 | unless defined $dist_dir && -d $dist_dir; | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 31 | return $dist_dir; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 6 | ▶ | sub new { return bless {}, $_[0] } | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | sub _flags | ||||||||||||||||||||||||||||
| 114 | 53 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_flags: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 115 | 53 | my($class, $key) = @_; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 53 | my $config = $class->runtime_prop; | |||||||||||||||||||||||||||
| 118 | 53 | my $flags = $config->{$key}; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 53 | my $prefix = $config->{prefix}; | |||||||||||||||||||||||||||
| 121 | 53 | ▶ | $prefix =~ s{\\}{/}g if $^O =~ /^(MSWin32|msys)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 53 | my $distdir = $config->{distdir}; | |||||||||||||||||||||||||||
| 123 | 53 | ▶ | $distdir =~ s{\\}{/}g if $^O =~ /^(MSWin32|msys)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 53 | ▶ | if(defined $flags && $prefix ne $distdir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $flags and $prefix ne $distdir
MC/DC50%1/2
defined $flags and $prefix ne $distdir
defined $flags
$prefix ne $distdir
Truth table66%2/3
A and B
A= defined $flagsB= $prefix ne $distdir
| |||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||
| 127 | $flags = join ' ', map { | ||||||||||||||||||||||||||||
| 128 | 36 | my $flag = $_; | |||||||||||||||||||||||||||
| 129 | 88 | $flag =~ s/^(-I|-L|-LIBPATH:)?\Q$prefix\E/$1$distdir/; | |||||||||||||||||||||||||||
| 130 | 88 | $flag =~ s/(\s)/\\$1/g; | |||||||||||||||||||||||||||
| 131 | 88 | $flag; | |||||||||||||||||||||||||||
| 132 | } $class->split_flags($flags); | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 53 | $flags; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 14 | ▶ | sub cflags { | ||||||||||||||||||||||||||
|
Subroutine
cflags: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 14 | my $class = shift; | |||||||||||||||||||||||||||
| 141 | 14 | ▶ | return $class->runtime_prop ? $class->_flags('cflags') : $class->_pkgconfig_keyword('Cflags'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 11 | ▶ | sub cflags_static { | ||||||||||||||||||||||||||
|
Subroutine
cflags_static: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 146 | 11 | my $class = shift; | |||||||||||||||||||||||||||
| 147 | 11 | ▶ | return $class->runtime_prop ? $class->_flags('cflags_static') : $class->_pkgconfig_keyword('Cflags', 'static'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 18 | ▶ | sub libs { | ||||||||||||||||||||||||||
|
Subroutine
libs: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 18 | my $class = shift; | |||||||||||||||||||||||||||
| 153 | 18 | ▶ | return $class->runtime_prop ? $class->_flags('libs') : $class->_pkgconfig_keyword('Libs'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 14 | ▶ | sub libs_static { | ||||||||||||||||||||||||||
|
Subroutine
libs_static: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 14 | my $class = shift; | |||||||||||||||||||||||||||
| 159 | 14 | ▶ | return $class->runtime_prop ? $class->_flags('libs_static') : $class->_pkgconfig_keyword('Libs', 'static'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 13 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 165 | return $self->runtime_prop | ||||||||||||||||||||||||||||
| 166 | ? $self->runtime_prop->{version} | ||||||||||||||||||||||||||||
| 167 | 13 | ▶ | : do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 2 | my $version = $self->config('version'); | |||||||||||||||||||||||||||
| 169 | 2 | chomp $version; | |||||||||||||||||||||||||||
| 170 | 2 | $version; | |||||||||||||||||||||||||||
| 171 | }; | ||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 3 | ▶ | sub atleast_version { | ||||||||||||||||||||||||||
|
Subroutine
atleast_version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | 3 | my ($wantver) = @_; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 3 | ▶ | defined(my $version = $self->version) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | croak "$self has no defined ->version"; | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 2 | return $self->version_cmp($version, $wantver) >= 0; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 2 | ▶ | sub exact_version { | ||||||||||||||||||||||||||
|
Subroutine
exact_version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 186 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 187 | 2 | my ($wantver) = @_; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2 | ▶ | defined(my $version = $self->version) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | croak "$self has no defined ->version"; | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 1 | return $self->version_cmp($version, $wantver) == 0; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 2 | ▶ | sub max_version { | ||||||||||||||||||||||||||
|
Subroutine
max_version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 196 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 197 | 2 | my ($wantver) = @_; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 2 | ▶ | defined(my $version = $self->version) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | croak "$self has no defined ->version"; | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 1 | return $self->version_cmp($version, $wantver) <= 0; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 4 | ▶ | sub version_cmp { | ||||||||||||||||||||||||||
|
Subroutine
version_cmp: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 207 | 4 | shift; | |||||||||||||||||||||||||||
| 208 | 4 | goto &Alien::Util::version_cmp; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 43 | ▶ | sub install_type { | ||||||||||||||||||||||||||
|
Subroutine
install_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 213 | 43 | my $self = shift; | |||||||||||||||||||||||||||
| 214 | 43 | my $type = $self->config('install_type'); | |||||||||||||||||||||||||||
| 215 | 43 | ▶ | return @_ ? $type eq $_[0] : $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | sub is_system_install | ||||||||||||||||||||||||||||
| 221 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_system_install: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 222 | 2 | my($self) = @_; | |||||||||||||||||||||||||||
| 223 | 2 | $self->install_type('system'); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | sub is_share_install | ||||||||||||||||||||||||||||
| 228 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_share_install: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 229 | 2 | my($self) = @_; | |||||||||||||||||||||||||||
| 230 | 2 | $self->install_type('share'); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 4 | ▶ | sub _pkgconfig_keyword { | ||||||||||||||||||||||||||
|
Subroutine
_pkgconfig_keyword: called CC=11 SCAR=25.3
| |||||||||||||||||||||||||||||
| 235 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 236 | 4 | my $keyword = shift; | |||||||||||||||||||||||||||
| 237 | 4 | my $static = shift; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # use pkg-config if installed system-wide | ||||||||||||||||||||||||||||
| 240 | 4 | ▶ | if ($self->install_type('system')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 2 | my $name = $self->config('name'); | |||||||||||||||||||||||||||
| 242 | 2 | require Alien::Base::PkgConfig; | |||||||||||||||||||||||||||
| 243 | 2 | ▶ | my $command = Alien::Base::PkgConfig->pkg_config_command . " @{[ $static ? '--static' : '' ]} --\L$keyword\E $name"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 2 | $! = 0; | |||||||||||||||||||||||||||
| 246 | 2 | ▶ | chomp ( my $pcdata = capture_stdout { system( $command ) } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | # if pkg-config fails for whatever reason, then we try to | ||||||||||||||||||||||||||||
| 249 | # fallback on alien_provides_* | ||||||||||||||||||||||||||||
| 250 | 2 | ▶ | $pcdata = '' if $! || $?; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$! or $?
MC/DC0%0/2
$! or $?
$!
$?
Truth table33%1/3
A or B
A= $!B= $?
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 2 | $pcdata =~ s/\s*$//; | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 2 | ▶ | if($self->config('system_provides')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 2 | ▶ | if(my $system_provides = $self->config('system_provides')->{$keyword}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $pcdata = length $pcdata ? "$pcdata $system_provides" : $system_provides; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 2 | return $pcdata; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | # use parsed info from build .pc file | ||||||||||||||||||||||||||||
| 264 | 2 | my $dist_dir = $self->dist_dir; | |||||||||||||||||||||||||||
| 265 | 2 | my @pc = $self->_pkgconfig(@_); | |||||||||||||||||||||||||||
| 266 | my @strings = | ||||||||||||||||||||||||||||
| 267 | grep defined, | ||||||||||||||||||||||||||||
| 268 | 2 | map { $_->keyword($keyword, | |||||||||||||||||||||||||||
| 269 | #{ pcfiledir => $dist_dir } | ||||||||||||||||||||||||||||
| 270 | ) } | ||||||||||||||||||||||||||||
| 271 | @pc; | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 2 | ▶ | if(defined $self->config('original_prefix') && $self->config('original_prefix') ne $self->dist_dir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->config("original_prefix") and $self->config("original_prefix") ne $self->dist_dir
MC/DC0%0/2
defined $self->config("original_prefix") and $self->config("original_prefix") ne $self->dist_dir
defined $self->config("original_prefix")
$self->config("original_prefix") ne $self->dist_dir
Truth table33%1/3
A and B
A= defined $self->config("original_prefix")B= $self->config("original_prefix") ne $self->dist_dir
| |||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||
| 275 | 2 | my $dist_dir = $self->dist_dir; | |||||||||||||||||||||||||||
| 276 | 2 | ▶ | $dist_dir =~ s{\\}{/}g if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 2 | my $old = quotemeta $self->config('original_prefix'); | |||||||||||||||||||||||||||
| 278 | @strings = map { | ||||||||||||||||||||||||||||
| 279 | 3 | my $flag = $_; | |||||||||||||||||||||||||||
| 280 | 3 | $flag =~ s{^(-I|-L|-LIBPATH:)?($old)}{$1.$dist_dir}e; | |||||||||||||||||||||||||||
| 281 | 3 | $flag =~ s/(\s)/\\$1/g; | |||||||||||||||||||||||||||
| 282 | 3 | $flag; | |||||||||||||||||||||||||||
| 283 | 2 | } map { $self->split_flags($_) } @strings; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 2 | return join( ' ', @strings ); | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 2 | ▶ | sub _pkgconfig { | ||||||||||||||||||||||||||
|
Subroutine
_pkgconfig: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||
| 290 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 291 | 2 | my %all = %{ $self->config('pkgconfig') }; | |||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | # merge in found pc files | ||||||||||||||||||||||||||||
| 294 | 2 | require File::Find; | |||||||||||||||||||||||||||
| 295 | 14 | ▶ | my $wanted = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||
| 296 | 14 | ▶ | return if ( -d or not /\.pc$/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-d $_ or not /\.pc$/
MC/DC0%0/2
-d $_ or not /\.pc$/
-d $_
not /\.pc$/
Truth table66%2/3
A or not(B)
A= -d $_B= not /\.pc$/
| |||||||||||||||||||||||||||||
| 297 | 0 | require Alien::Base::PkgConfig; | |||||||||||||||||||||||||||
| 298 | 0 | my $pkg = Alien::Base::PkgConfig->new($_); | |||||||||||||||||||||||||||
| 299 | 0 | $all{$pkg->{package}} = $pkg; | |||||||||||||||||||||||||||
| 300 | 2 | }; | |||||||||||||||||||||||||||
| 301 | 2 | File::Find::find( $wanted, $self->dist_dir ); | |||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 2 | ▶ | croak "No Alien::Base::PkgConfig objects are stored!" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | unless keys %all; | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | # Run through all pkgconfig objects and ensure that their modules are loaded: | ||||||||||||||||||||||||||||
| 307 | 2 | for my $pkg_obj (values %all) { | |||||||||||||||||||||||||||
| 308 | 4 | my $perl_module_name = blessed $pkg_obj; | |||||||||||||||||||||||||||
| 309 | 4 | my $pm = "$perl_module_name.pm"; | |||||||||||||||||||||||||||
| 310 | 4 | $pm =~ s/::/\//g; | |||||||||||||||||||||||||||
| 311 | 4 | eval { require $pm }; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 2 | ▶ | return @all{@_} if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 2 | my $manual = delete $all{_manual}; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 2 | ▶ | if (keys %all) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 2 | return values %all; | |||||||||||||||||||||||||||
| 320 | } else { | ||||||||||||||||||||||||||||
| 321 | 0 | return $manual; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | # helper method to call Alien::MyLib::ConfigData->config(@_) | ||||||||||||||||||||||||||||
| 327 | 100 | ▶ | sub config { | ||||||||||||||||||||||||||
|
Subroutine
config: called CC=5 SCAR=19.0
Pod
documented
| |||||||||||||||||||||||||||||
| 328 | 100 | my $class = shift; | |||||||||||||||||||||||||||
| 329 | 100 | ▶ | $class = blessed $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($class) || $class
MC/DC0%0/2
builtin::blessed($class) || $class
builtin::blessed($class)
$class
Truth table33%1/3
A || B
A= builtin::blessed($class)B= $class
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 100 | ▶ | if(my $ab_config = $class->runtime_prop) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||
| 333 | 72 | my $key = shift; | |||||||||||||||||||||||||||
| 334 | 72 | return $ab_config->{legacy}->{$key}; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 28 | my $config = $class . '::ConfigData'; | |||||||||||||||||||||||||||
| 338 | 28 | my $pm = "$class/ConfigData.pm"; | |||||||||||||||||||||||||||
| 339 | 28 | $pm =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 340 | 28 | eval { require $pm }; | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 28 | ▶ | if($@) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||
| 344 | 0 | warn "Cannot find either a share directory or a ConfigData module for $class.\n"; | |||||||||||||||||||||||||||
| 345 | 0 | my $pm = "$class.pm"; | |||||||||||||||||||||||||||
| 346 | 0 | $pm =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 347 | 0 | ▶ | warn "($class loaded from $INC{$pm})\n" if $INC{$pm}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | 0 | warn "Please see https://metacpan.org/pod/distribution/Alien-Build/lib/Alien/Build/Manual/FAQ.pod#Cannot-find-either-a-share-directory-or-a-ConfigData-module\n"; | |||||||||||||||||||||||||||
| 349 | 0 | die $@; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 28 | return $config->config(@_); | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | # helper method to split flags based on the OS | ||||||||||||||||||||||||||||
| 356 | 41 | ▶ | sub split_flags { | ||||||||||||||||||||||||||
|
Subroutine
split_flags: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 357 | 41 | my ($class, $line) = @_; | |||||||||||||||||||||||||||
| 358 | 41 | ▶ | if( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 0 | $class->split_flags_windows($line); | |||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||
| 361 | # $os eq 'Unix' | ||||||||||||||||||||||||||||
| 362 | 41 | $class->split_flags_unix($line); | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 42 | ▶ | sub split_flags_unix { | ||||||||||||||||||||||||||
|
Subroutine
split_flags_unix: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 367 | 42 | my ($class, $line) = @_; | |||||||||||||||||||||||||||
| 368 | 42 | shellwords($line); | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 3 | ▶ | sub split_flags_windows { | ||||||||||||||||||||||||||
|
Subroutine
split_flags_windows: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 372 | # NOTE a better approach would be to write a function that understands cmd.exe metacharacters. | ||||||||||||||||||||||||||||
| 373 | 3 | my ($class, $line) = @_; | |||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | # Double the backslashes so that when they are unescaped by shellwords(), | ||||||||||||||||||||||||||||
| 376 | # they become a single backslash. This should be fine on Windows since | ||||||||||||||||||||||||||||
| 377 | # backslashes are not used to escape metacharacters in cmd.exe. | ||||||||||||||||||||||||||||
| 378 | 3 | $line =~ s,\\,\\\\,g; | |||||||||||||||||||||||||||
| 379 | 3 | shellwords($line); | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 5 | ▶ | sub dynamic_libs { | ||||||||||||||||||||||||||
|
Subroutine
dynamic_libs: called CC=13 SCAR=27.5
Pod
documented
| |||||||||||||||||||||||||||||
| 384 | 5 | my ($class) = @_; | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 5 | require FFI::CheckLib; | |||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 5 | my @find_lib_flags; | |||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 5 | ▶ | if($class->install_type('system')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 4 | ▶ | if(my $prop = $class->runtime_prop) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||
| 394 | 4 | ▶ | if($prop->{ffi_checklib}->{system}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | { | ||||||||||||||||||||||||||||
| 396 | 0 | push @find_lib_flags, @{ $prop->{ffi_checklib}->{system} }; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | return FFI::CheckLib::find_lib( lib => $prop->{ffi_name}, @find_lib_flags ) | ||||||||||||||||||||||||||||
| 399 | 4 | ▶ | if defined $prop->{ffi_name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 3 | my $name = $class->config('ffi_name'); | |||||||||||||||||||||||||||
| 403 | 3 | ▶ | unless(defined $name) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||
| 405 | 3 | $name = $class->config('name'); | |||||||||||||||||||||||||||
| 406 | 3 | ▶ | $name = '' unless defined $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | # strip leading lib from things like libarchive or libffi | ||||||||||||||||||||||||||||
| 408 | 3 | $name =~ s/^lib//; | |||||||||||||||||||||||||||
| 409 | # strip trailing version numbers | ||||||||||||||||||||||||||||
| 410 | 3 | $name =~ s/-[0-9\.]+$//; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 3 | my @libpath; | |||||||||||||||||||||||||||
| 414 | 3 | ▶ | if(defined $class->libs) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||
| 416 | 3 | foreach my $flag ($class->split_flags($class->libs)) | |||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||
| 418 | 4 | ▶ | if($flag =~ /^-L(.*)$/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | { | ||||||||||||||||||||||||||||
| 420 | 1 | push @libpath, $1; | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 3 | return FFI::CheckLib::find_lib(lib => $name, libpath => \@libpath, @find_lib_flags ); | |||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | } else { | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 1 | my $dir = $class->dist_dir; | |||||||||||||||||||||||||||
| 430 | 1 | my $dynamic = Path::Tiny->new($class->dist_dir, 'dynamic'); | |||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 1 | ▶ | if(my $prop = $class->runtime_prop) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | { | ||||||||||||||||||||||||||||
| 434 | 1 | ▶ | if($prop->{ffi_checklib}->{share}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | { | ||||||||||||||||||||||||||||
| 436 | 0 | push @find_lib_flags, @{ $prop->{ffi_checklib}->{share_flags} }; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 1 | ▶ | if(-d $dynamic) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||
| 442 | 1 | return FFI::CheckLib::find_lib( | |||||||||||||||||||||||||||
| 443 | lib => '*', | ||||||||||||||||||||||||||||
| 444 | libpath => "$dynamic", | ||||||||||||||||||||||||||||
| 445 | systempath => [], | ||||||||||||||||||||||||||||
| 446 | ); | ||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | 0 | return FFI::CheckLib::find_lib( | |||||||||||||||||||||||||||
| 450 | lib => '*', | ||||||||||||||||||||||||||||
| 451 | libpath => $dir, | ||||||||||||||||||||||||||||
| 452 | systempath => [], | ||||||||||||||||||||||||||||
| 453 | recursive => 1, | ||||||||||||||||||||||||||||
| 454 | ); | ||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 13 | ▶ | sub bin_dir { | ||||||||||||||||||||||||||
|
Subroutine
bin_dir: called CC=6 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||
| 460 | 13 | my ($class) = @_; | |||||||||||||||||||||||||||
| 461 | 13 | ▶ | if($class->install_type('system')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||
| 463 | 5 | my $prop = $class->runtime_prop; | |||||||||||||||||||||||||||
| 464 | 5 | ▶ | return () unless defined $prop; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 5 | ▶ | return () unless defined $prop->{system_bin_dir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | 0 | ▶ | return ref $prop->{system_bin_dir} ? @{ $prop->{system_bin_dir} } : ($prop->{system_bin_dir}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||
| 468 | else | ||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||
| 470 | 8 | my $dir = Path::Tiny->new($class->dist_dir, 'bin'); | |||||||||||||||||||||||||||
| 471 | 8 | ▶ | return -d $dir ? ("$dir") : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 2 | ▶ | sub dynamic_dir { | ||||||||||||||||||||||||||
|
Subroutine
dynamic_dir: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 478 | 2 | my ($class) = @_; | |||||||||||||||||||||||||||
| 479 | 2 | ▶ | if($class->install_type('system')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||
| 481 | 1 | return (); | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | else | ||||||||||||||||||||||||||||
| 484 | { | ||||||||||||||||||||||||||||
| 485 | 1 | my $dir = Path::Tiny->new($class->dist_dir, 'dynamic'); | |||||||||||||||||||||||||||
| 486 | 1 | ▶ | return -d $dir ? ("$dir") : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 2 | ▶ | sub alien_helper { | ||||||||||||||||||||||||||
|
Subroutine
alien_helper: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 492 | 2 | {}; | |||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 0 | ▶ | sub inline_auto_include { | ||||||||||||||||||||||||||
|
Subroutine
inline_auto_include: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 497 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||
| 498 | 0 | ▶ | $class->runtime_prop->{inline_auto_include} || $class->config('inline_auto_include') || [] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class->runtime_prop->{"inline_auto_include"} or $class->config("inline_auto_include")
MC/DC0%0/2
$class->runtime_prop->{"inline_auto_include"} or $class->config("inline_auto_include")
$class->runtime_prop->{"inline_auto_include"}
$class->config("inline_auto_include")
Truth table0%0/3
A or B
A= $class->runtime_prop->{"inline_auto_include"}B= $class->config("inline_auto_include")
| |||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub Inline { | ||||||||||||||||||||||||||
|
Subroutine
Inline: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 502 | 0 | my ($class, $language) = @_; | |||||||||||||||||||||||||||
| 503 | 0 | ▶ | return unless defined $language; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 504 | 0 | ▶ | return if $language !~ /^(C|CPP)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 505 | 0 | my $config = { | |||||||||||||||||||||||||||
| 506 | # INC should arguably be for -I flags only, but | ||||||||||||||||||||||||||||
| 507 | # this improves compat with ExtUtils::Depends. | ||||||||||||||||||||||||||||
| 508 | # see gh#107, gh#108 | ||||||||||||||||||||||||||||
| 509 | INC => $class->cflags, | ||||||||||||||||||||||||||||
| 510 | LIBS => $class->libs, | ||||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 0 | ▶ | if (@{ $class->inline_auto_include } > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 514 | 0 | $config->{AUTO_INCLUDE} = join "\n", map { "#include \"$_\"" } @{ $class->inline_auto_include }; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | $config; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | { | ||||||||||||||||||||||||||||
| 522 | 14 | my %alien_build_config_cache; | |||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | sub runtime_prop | ||||||||||||||||||||||||||||
| 525 | 229 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
runtime_prop: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 526 | 229 | my($class) = @_; | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 229 | ▶ | if(ref($class)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||
| 530 | # called as an instance method. | ||||||||||||||||||||||||||||
| 531 | 44 | my $self = $class; | |||||||||||||||||||||||||||
| 532 | 44 | $class = ref $self; | |||||||||||||||||||||||||||
| 533 | 44 | ▶ | return $self->{_alt}->{runtime_prop} if defined $self->{_alt}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | return $alien_build_config_cache{$class} if | ||||||||||||||||||||||||||||
| 537 | 185 | ▶ | exists $alien_build_config_cache{$class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 12 | ▶ | $alien_build_config_cache{$class} ||= do { | ||||||||||||||||||||||||||
|
Condition33%1/3
$alien_build_config_cache{$class} ||= do {
my $dist = ref $class ? ref $class : $class;
$dist =~ s/::/-/g;
my $dist_dir = eval {
do {
&_dist_dir($dist)
}
};
return if $@;
my $alien_json = "Path::Tiny"->new($dist_dir, "_alien", "alien.json");
return unless -r $alien_json;
my $json = $alien_json->slurp;
require JSON::PP;
my $config = JSON::PP::decode_json($json);
$config->{"distdir"} = $dist_dir;
$config
}
MC/DC0%0/2
$alien_build_config_cache{$class} ||= do {
my $dist = ref $class ? ref $class : $class;
$dist =~ s/::/-/g;
my $dist_dir = eval {
do {
&_dist_dir($dist)
}
};
return if $@;
my $alien_json = "Path::Tiny"->new($dist_dir, "_alien", "alien.json");
return unless -r $alien_json;
my $json = $alien_json->slurp;
require JSON::PP;
my $config = JSON::PP::decode_json($json);
$config->{"distdir"} = $dist_dir;
$config
}
$alien_build_config_cache{$class}
do {
my $dist = ref $class ? ref $class : $class;
$dist =~ s/::/-/g;
my $dist_dir = eval {
do {
&_dist_dir($dist)
}
};
return if $@;
my $alien_json = "Path::Tiny"->new($dist_dir, "_alien", "alien.json");
return unless -r $alien_json;
my $json = $alien_json->slurp;
require JSON::PP;
my $config = JSON::PP::decode_json($json);
$config->{"distdir"} = $dist_dir;
$config
}
Truth table33%1/3
A ||= B
A= $alien_build_config_cache{$class}B= do {
my $dist = ref $class ? ref $class : $class;
$dist =~ s/::/-/g;
my $dist_dir = eval {
do {
&_dist_dir($dist)
}
};
return if $@;
my $alien_json = "Path::Tiny"->new($dist_dir, "_alien", "alien.json");
return unless -r $alien_json;
my $json = $alien_json->slurp;
require JSON::PP;
my $config = JSON::PP::decode_json($json);
$config->{"distdir"} = $dist_dir;
$config
}
| |||||||||||||||||||||||||||||
| 540 | 12 | ▶ | my $dist = ref $class ? ref $class : $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 541 | 12 | $dist =~ s/::/-/g; | |||||||||||||||||||||||||||
| 542 | 12 | my $dist_dir = eval { _dist_dir $dist }; | |||||||||||||||||||||||||||
| 543 | 12 | ▶ | return if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 544 | 11 | my $alien_json = Path::Tiny->new($dist_dir, '_alien', 'alien.json'); | |||||||||||||||||||||||||||
| 545 | 11 | ▶ | return unless -r $alien_json; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 546 | 10 | my $json = $alien_json->slurp; | |||||||||||||||||||||||||||
| 547 | 10 | require JSON::PP; | |||||||||||||||||||||||||||
| 548 | 10 | my $config = JSON::PP::decode_json($json); | |||||||||||||||||||||||||||
| 549 | 10 | $config->{distdir} = $dist_dir; | |||||||||||||||||||||||||||
| 550 | 10 | $config; | |||||||||||||||||||||||||||
| 551 | }; | ||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | sub alt | ||||||||||||||||||||||||||||
| 557 | 14 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alt: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 558 | 6 | my($old, $name) = @_; | |||||||||||||||||||||||||||
| 559 | 6 | ▶ | my $new = ref $old ? (ref $old)->new : $old->new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 6 | my $orig; | |||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | 6 | ▶ | if(ref($old) && defined $old->{_alt}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $old and defined $old->{"_alt"}
MC/DC50%1/2
ref $old and defined $old->{"_alt"}
ref $old
defined $old->{"_alt"}
Truth table66%2/3
A and B
A= ref $oldB= defined $old->{"_alt"}
| |||||||||||||||||||||||||||||
| 564 | 1 | { $orig = $old->{_alt}->{orig} } | |||||||||||||||||||||||||||
| 565 | else | ||||||||||||||||||||||||||||
| 566 | 5 | { $orig = $old->runtime_prop } | |||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 6 | require Storable; | |||||||||||||||||||||||||||
| 569 | 6 | my $runtime_prop = Storable::dclone($orig); | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 6 | ▶ | if($runtime_prop->{alt}->{$name}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||
| 573 | 5 | foreach my $key (keys %{ $runtime_prop->{alt}->{$name} }) | |||||||||||||||||||||||||||
| 574 | { | ||||||||||||||||||||||||||||
| 575 | 23 | $runtime_prop->{$key} = $runtime_prop->{alt}->{$name}->{$key}; | |||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | else | ||||||||||||||||||||||||||||
| 579 | { | ||||||||||||||||||||||||||||
| 580 | 1 | Carp::croak("no such alt: $name"); | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | $new->{_alt} = { | ||||||||||||||||||||||||||||
| 584 | 5 | runtime_prop => $runtime_prop, | |||||||||||||||||||||||||||
| 585 | orig => $orig, | ||||||||||||||||||||||||||||
| 586 | }; | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 5 | $new; | |||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | sub alt_names | ||||||||||||||||||||||||||||
| 593 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alt_names: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 594 | 3 | my($class) = @_; | |||||||||||||||||||||||||||
| 595 | 3 | my $alts = $class->runtime_prop->{alt}; | |||||||||||||||||||||||||||
| 596 | 3 | ▶ | defined $alts | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 597 | ? sort keys %$alts | ||||||||||||||||||||||||||||
| 598 | : (); | ||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | sub alt_exists | ||||||||||||||||||||||||||||
| 603 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alt_exists: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 604 | 4 | my($class, $alt_name) = @_; | |||||||||||||||||||||||||||
| 605 | 4 | my $alts = $class->runtime_prop->{alt}; | |||||||||||||||||||||||||||
| 606 | defined $alts | ||||||||||||||||||||||||||||
| 607 | 4 | ▶ | ? exists $alts->{$alt_name} && defined $alts->{$alt_name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $alts->{$alt_name} and defined $alts->{$alt_name}
MC/DC50%1/2
exists $alts->{$alt_name} and defined $alts->{$alt_name}
exists $alts->{$alt_name}
defined $alts->{$alt_name}
Truth table66%2/3
A and B
A= exists $alts->{$alt_name}B= defined $alts->{$alt_name}
| |||||||||||||||||||||||||||||
| 608 | : 0; | ||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | 14 | 1; | |||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | =pod | ||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | =head1 NAME | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | Alien::Base - Base classes for Alien:: modules | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | =head1 VERSION | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | version 2.88 | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | package Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | use strict; | ||||||||||||||||||||||||||||
| 630 | use warnings; | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | use parent 'Alien::Base'; | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | 1; | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | (for details on the C<Makefile.PL> or C<Build.PL> and L<alienfile> | ||||||||||||||||||||||||||||
| 637 | that should be bundled with your L<Alien::Base> subclass, please see | ||||||||||||||||||||||||||||
| 638 | L<Alien::Build::Manual::AlienAuthor>). | ||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | Then a C<MyLibrary::XS> can use C<Alien::MyLibrary> in its C<Makefile.PL>: | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | use Alien::MyLibrary | ||||||||||||||||||||||||||||
| 643 | use ExtUtils::MakeMaker; | ||||||||||||||||||||||||||||
| 644 | use Alien::Base::Wrapper qw( Alien::MyLibrary !export ); | ||||||||||||||||||||||||||||
| 645 | use Config; | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | WriteMakefile( | ||||||||||||||||||||||||||||
| 648 | ... | ||||||||||||||||||||||||||||
| 649 | Alien::Base::Wrapper->mm_args, | ||||||||||||||||||||||||||||
| 650 | ... | ||||||||||||||||||||||||||||
| 651 | ); | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | Or if you prefer L<Module::Build>, in its C<Build.PL>: | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | use Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 656 | use Module::Build 0.28; # need at least 0.28 | ||||||||||||||||||||||||||||
| 657 | use Alien::Base::Wrapper qw( Alien::MyLibrary !export ); | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | my $builder = Module::Build->new( | ||||||||||||||||||||||||||||
| 660 | ... | ||||||||||||||||||||||||||||
| 661 | Alien::Base::Wrapper->mb_args, | ||||||||||||||||||||||||||||
| 662 | ... | ||||||||||||||||||||||||||||
| 663 | ); | ||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||
| 665 | $builder->create_build_script; | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | Or if you are using L<ExtUtils::Depends>: | ||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | use ExtUtils::MakeMaker; | ||||||||||||||||||||||||||||
| 670 | use ExtUtils::Depends; | ||||||||||||||||||||||||||||
| 671 | my $eud = ExtUtils::Depends->new(qw( MyLibrary::XS Alien::MyLibrary )); | ||||||||||||||||||||||||||||
| 672 | WriteMakefile( | ||||||||||||||||||||||||||||
| 673 | ... | ||||||||||||||||||||||||||||
| 674 | $eud->get_makefile_vars | ||||||||||||||||||||||||||||
| 675 | ); | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | If you are using L<Alien::Base::ModuleBuild> instead of the recommended L<Alien::Build> | ||||||||||||||||||||||||||||
| 678 | and L<alienfile>, then in your C<MyLibrary::XS> module, you may need something like | ||||||||||||||||||||||||||||
| 679 | this in your main C<.pm> file IF your library uses dynamic libraries: | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | package MyLibrary::XS; | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | use Alien::MyLibrary; # may only be needed if you are using Alien::Base::ModuleBuild | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | ... | ||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | Or you can use it from an FFI module: | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | package MyLibrary::FFI; | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | use Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 692 | use FFI::Platypus; | ||||||||||||||||||||||||||||
| 693 | use FFI::CheckLib 0.28 qw( find_lib_or_die ); | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | my $ffi = FFI::Platypus->new; | ||||||||||||||||||||||||||||
| 696 | $ffi->lib(find_lib_or_die lib => 'mylib', alien => ['Alien::MyLibrary']); | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | $ffi->attach( 'my_library_function' => [] => 'void' ); | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | You can even use it with L<Inline> (C and C++ languages are supported): | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | package MyLibrary::Inline; | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | use Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 705 | # Inline 0.56 or better is required | ||||||||||||||||||||||||||||
| 706 | use Inline 0.56 with => 'Alien::MyLibrary'; | ||||||||||||||||||||||||||||
| 707 | ... | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | B<NOTE>: L<Alien::Base::ModuleBuild> is no longer bundled with L<Alien::Base> and has been spun off into a separate distribution. | ||||||||||||||||||||||||||||
| 712 | L<Alien::Base::ModuleBuild> will be a prerequisite for L<Alien::Base> until October 1, 2017. If you are using L<Alien::Base::ModuleBuild> | ||||||||||||||||||||||||||||
| 713 | you need to make sure it is declared as a C<configure_requires> in your C<Build.PL>. You may want to also consider using L<Alien::Base> and | ||||||||||||||||||||||||||||
| 714 | L<alienfile> as a more modern alternative. | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | L<Alien::Base> comprises base classes to help in the construction of C<Alien::> modules. Modules in the L<Alien> namespace are used to locate and install (if necessary) external libraries needed by other Perl modules. | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | This is the documentation for the L<Alien::Base> module itself. If you | ||||||||||||||||||||||||||||
| 719 | are starting out you probably want to do so from one of these documents: | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | =over 4 | ||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | =item L<Alien::Build::Manual::AlienUser> | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | For users of an C<Alien::libfoo> that is implemented using L<Alien::Base>. | ||||||||||||||||||||||||||||
| 726 | (The developer of C<Alien::libfoo> I<should> provide the documentation | ||||||||||||||||||||||||||||
| 727 | necessary, but if not, this is the place to start). | ||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||
| 729 | =item L<Alien::Build::Manual::AlienAuthor> | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | If you are writing your own L<Alien> based on L<Alien::Build> and L<Alien::Base>. | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | =item L<Alien::Build::Manual::FAQ> | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | If you have a common question that has already been answered, like | ||||||||||||||||||||||||||||
| 736 | "How do I use L<alienfile> with some build system". | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | =item L<Alien::Build::Manual::PluginAuthor> | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | This is for the brave souls who want to write plugins that will work with | ||||||||||||||||||||||||||||
| 741 | L<Alien::Build> + L<alienfile>. | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | =back | ||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||
| 745 | Before using an L<Alien::Base> based L<Alien> directly, please consider the following advice: | ||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||
| 747 | If you are wanting to use an L<Alien::Base> based L<Alien> with an XS module using L<ExtUtils::MakeMaker> or L<Module::Build>, it is highly | ||||||||||||||||||||||||||||
| 748 | recommended that you use L<Alien::Base::Wrapper>, rather than using the L<Alien> directly, because it handles a number of sharp edges and avoids | ||||||||||||||||||||||||||||
| 749 | pitfalls common when trying to use an L<Alien> directly with L<ExtUtils::MakeMaker>. | ||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | In the same vein, if you are wanting to use an L<Alien::Base> based L<Alien> with an XS module using L<Dist::Zilla> it is highly recommended | ||||||||||||||||||||||||||||
| 752 | that you use L<Dist::Zilla::Plugin::AlienBase::Wrapper> for the same reasons. | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | As of version 0.28, L<FFI::CheckLib> has a good interface for working with L<Alien::Base> based L<Alien>s in fallback mode, which is | ||||||||||||||||||||||||||||
| 755 | recommended. | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | You should typically only be using an L<Alien::Base> based L<Alien> directly, if you need to integrate it with some other system, or if it | ||||||||||||||||||||||||||||
| 758 | is a tool based L<Alien> that you don't need to link. | ||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | The above synopsis and linked manual documents will lead you down the right path, but it is worth knowing before you read further in this | ||||||||||||||||||||||||||||
| 761 | document. | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | =head1 METHODS | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | In the example snippets here, C<Alien::MyLibrary> represents any | ||||||||||||||||||||||||||||
| 766 | subclass of L<Alien::Base>. | ||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||
| 768 | =head2 dist_dir | ||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | my $dir = Alien::MyLibrary->dist_dir; | ||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||
| 772 | Returns the directory that contains the install root for | ||||||||||||||||||||||||||||
| 773 | the packaged software, if it was built from install (i.e., if | ||||||||||||||||||||||||||||
| 774 | C<install_type> is C<share>). | ||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||
| 776 | =head2 new | ||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | my $alien = Alien::MyLibrary->new; | ||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||
| 780 | Creates an instance of an L<Alien::Base> object. This is typically | ||||||||||||||||||||||||||||
| 781 | unnecessary. | ||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | =head2 cflags | ||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||
| 785 | my $cflags = Alien::MyLibrary->cflags; | ||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | use Text::ParseWords qw( shellwords ); | ||||||||||||||||||||||||||||
| 788 | my @cflags = shellwords( Alien::MyLibrary->cflags ); | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | Returns the C compiler flags necessary to compile an XS | ||||||||||||||||||||||||||||
| 791 | module using the alien software. If you need this in list | ||||||||||||||||||||||||||||
| 792 | form (for example if you are calling system with a list | ||||||||||||||||||||||||||||
| 793 | argument) you can pass this value into C<shellwords> from | ||||||||||||||||||||||||||||
| 794 | the Perl core L<Text::ParseWords> module. | ||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||
| 796 | =head2 cflags_static | ||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | my $cflags = Alien::MyLibrary->cflags_static; | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | Same as C<cflags> above, but gets the static compiler flags, | ||||||||||||||||||||||||||||
| 801 | if they are different. | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | =head2 libs | ||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | my $libs = Alien::MyLibrary->libs; | ||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | use Text::ParseWords qw( shellwords ); | ||||||||||||||||||||||||||||
| 808 | my @cflags = shellwords( Alien::MyLibrary->libs ); | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | Returns the library linker flags necessary to link an XS | ||||||||||||||||||||||||||||
| 811 | module against the alien software. If you need this in list | ||||||||||||||||||||||||||||
| 812 | form (for example if you are calling system with a list | ||||||||||||||||||||||||||||
| 813 | argument) you can pass this value into C<shellwords> from | ||||||||||||||||||||||||||||
| 814 | the Perl core L<Text::ParseWords> module. | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | =head2 libs_static | ||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | my $libs = Alien::MyLibrary->libs_static; | ||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||
| 820 | Same as C<libs> above, but gets the static linker flags, | ||||||||||||||||||||||||||||
| 821 | if they are different. | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | =head2 version | ||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||
| 825 | my $version = Alien::MyLibrary->version; | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | Returns the version of the alienized library or tool that was | ||||||||||||||||||||||||||||
| 828 | determined at install time. | ||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||
| 830 | =head2 atleast_version | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | =head2 exact_version | ||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | =head2 max_version | ||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||
| 836 | my $ok = Alien::MyLibrary->atleast_version($wanted_version); | ||||||||||||||||||||||||||||
| 837 | my $ok = Alien::MyLibrary->exact_version($wanted_version); | ||||||||||||||||||||||||||||
| 838 | my $ok = Alien::MyLibrary->max_version($wanted_version); | ||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||
| 840 | Returns true if the version of the alienized library or tool is at least, | ||||||||||||||||||||||||||||
| 841 | exactly, or at most the version specified, respectively. | ||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||
| 843 | =head2 version_cmp | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | $cmp = Alien::MyLibrary->version_cmp($x, $y) | ||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | Comparison method used by L</atleast_version>, L</exact_version> and | ||||||||||||||||||||||||||||
| 848 | L</max_version>. May be useful to implement custom comparisons, or for | ||||||||||||||||||||||||||||
| 849 | subclasses to overload to get different version comparison semantics than the | ||||||||||||||||||||||||||||
| 850 | default rules, for packages that have some other rules than the F<pkg-config> | ||||||||||||||||||||||||||||
| 851 | behaviour. | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | Should return a number less than, equal to, or greater than zero; similar in | ||||||||||||||||||||||||||||
| 854 | behaviour to the C<< <=> >> and C<cmp> operators. | ||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||
| 856 | =head2 install_type | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | my $install_type = Alien::MyLibrary->install_type; | ||||||||||||||||||||||||||||
| 859 | my $bool = Alien::MyLibrary->install_type($install_type); | ||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||
| 861 | Returns the install type that was used when C<Alien::MyLibrary> was | ||||||||||||||||||||||||||||
| 862 | installed. | ||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | If a type is provided (the second form in the synopsis) | ||||||||||||||||||||||||||||
| 865 | returns true if the actual install type matches. | ||||||||||||||||||||||||||||
| 866 | For this use case it is recommended to use C<is_system_install> | ||||||||||||||||||||||||||||
| 867 | or C<is_share_install> instead as these are less prone to | ||||||||||||||||||||||||||||
| 868 | typographical errors. | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | Types include: | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | =over 4 | ||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||
| 874 | =item system | ||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||
| 876 | The library was provided by the operating system | ||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||
| 878 | =item share | ||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||
| 880 | The library was not available when C<Alien::MyLibrary> was installed, so | ||||||||||||||||||||||||||||
| 881 | it was built from source code, either downloaded from the Internet | ||||||||||||||||||||||||||||
| 882 | or bundled with C<Alien::MyLibrary>. | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | =back | ||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||
| 886 | =head2 is_system_install | ||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||
| 888 | my $type = $build->is_system_install; | ||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||
| 890 | Returns true if the alien is a system install type. | ||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||
| 892 | =head2 is_share_install | ||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||
| 894 | my $type = $build->is_share_install; | ||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||
| 896 | Returns true if the alien is a share install type. | ||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | =head2 config | ||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||
| 900 | my $value = Alien::MyLibrary->config($key); | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | Returns the configuration data as determined during the install | ||||||||||||||||||||||||||||
| 903 | of C<Alien::MyLibrary>. For the appropriate config keys, see | ||||||||||||||||||||||||||||
| 904 | L<Alien::Base::ModuleBuild::API/"CONFIG DATA">. | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | This is not typically used by L<Alien::Base> and L<alienfile>, | ||||||||||||||||||||||||||||
| 907 | but a compatible interface will be provided. | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | =head2 dynamic_libs | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | my @dlls = Alien::MyLibrary->dynamic_libs; | ||||||||||||||||||||||||||||
| 912 | my($dll) = Alien::MyLibrary->dynamic_libs; | ||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||
| 914 | Returns a list of the dynamic library or shared object files for the | ||||||||||||||||||||||||||||
| 915 | alien software. | ||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||
| 917 | =head2 bin_dir | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | my(@dir) = Alien::MyLibrary->bin_dir | ||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | Returns a list of directories with executables in them. For a C<system> | ||||||||||||||||||||||||||||
| 922 | install this will be an empty list. For a C<share> install this will be | ||||||||||||||||||||||||||||
| 923 | a directory under C<dist_dir> named C<bin> if it exists. You may wish | ||||||||||||||||||||||||||||
| 924 | to override the default behavior if you have executables or scripts that | ||||||||||||||||||||||||||||
| 925 | get installed into non-standard locations. | ||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||
| 927 | Example usage: | ||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||
| 929 | use Env qw( @PATH ); | ||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||
| 931 | unshift @PATH, Alien::MyLibrary->bin_dir; | ||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||
| 933 | =head2 dynamic_dir | ||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||
| 935 | my(@dir) = Alien::MyLibrary->dynamic_dir | ||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | Returns the dynamic dir for a dynamic build (if the main | ||||||||||||||||||||||||||||
| 938 | build is static). For a C<share> install this will be a | ||||||||||||||||||||||||||||
| 939 | directory under C<dist_dir> named C<dynamic> if it exists. | ||||||||||||||||||||||||||||
| 940 | System builds return an empty list. | ||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||
| 942 | Example usage: | ||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | use Env qw( @PATH ); | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | unshift @PATH, Alien::MyLibrary->dynamic_dir; | ||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||
| 948 | =head2 alien_helper | ||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||
| 950 | my $helpers = Alien::MyLibrary->alien_helper; | ||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||
| 952 | Returns a hash reference of helpers provided by the Alien module. | ||||||||||||||||||||||||||||
| 953 | The keys are helper names and the values are code references. The | ||||||||||||||||||||||||||||
| 954 | code references will be executed at command time and the return value | ||||||||||||||||||||||||||||
| 955 | will be interpolated into the command before execution. The default | ||||||||||||||||||||||||||||
| 956 | implementation returns an empty hash reference, and you are expected | ||||||||||||||||||||||||||||
| 957 | to override the method to create your own helpers. | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | For use with commands specified in and L<alienfile> or in your C<Build.Pl> | ||||||||||||||||||||||||||||
| 960 | when used with L<Alien::Base::ModuleBuild>. | ||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | Helpers allow users of your Alien module to use platform or environment | ||||||||||||||||||||||||||||
| 963 | determined logic to compute command names or arguments in your installer | ||||||||||||||||||||||||||||
| 964 | logic. Helpers allow you to do this without making your Alien module a | ||||||||||||||||||||||||||||
| 965 | requirement when a build from source code is not necessary. | ||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||
| 967 | As a concrete example, consider L<Alien::gmake>, which provides the | ||||||||||||||||||||||||||||
| 968 | helper C<gmake>: | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | package Alien::gmake; | ||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||
| 972 | ... | ||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||
| 974 | sub alien_helper { | ||||||||||||||||||||||||||||
| 975 | my($class) = @_; | ||||||||||||||||||||||||||||
| 976 | return { | ||||||||||||||||||||||||||||
| 977 | gmake => sub { | ||||||||||||||||||||||||||||
| 978 | # return the executable name for GNU make, | ||||||||||||||||||||||||||||
| 979 | # usually either make or gmake depending on | ||||||||||||||||||||||||||||
| 980 | # the platform and environment | ||||||||||||||||||||||||||||
| 981 | $class->exe; | ||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||
| 983 | }, | ||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||
| 986 | Now consider L<Alien::nasm>. C<nasm> requires GNU Make to build from | ||||||||||||||||||||||||||||
| 987 | source code, but if the system C<nasm> package is installed we don't | ||||||||||||||||||||||||||||
| 988 | need it. From the L<alienfile> of C<Alien::nasm>: | ||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||
| 990 | use alienfile; | ||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||
| 992 | plugin 'Probe::CommandLine' => ( | ||||||||||||||||||||||||||||
| 993 | command => 'nasm', | ||||||||||||||||||||||||||||
| 994 | args => ['-v'], | ||||||||||||||||||||||||||||
| 995 | match => qr/NASM version/, | ||||||||||||||||||||||||||||
| 996 | ); | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | share { | ||||||||||||||||||||||||||||
| 999 | ... | ||||||||||||||||||||||||||||
| 1000 | plugin 'Extract' => 'tar.gz'; | ||||||||||||||||||||||||||||
| 1001 | plugin 'Build::MSYS'; | ||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||
| 1003 | build [ | ||||||||||||||||||||||||||||
| 1004 | 'sh configure --prefix=%{alien.install.prefix}', | ||||||||||||||||||||||||||||
| 1005 | '%{gmake}', | ||||||||||||||||||||||||||||
| 1006 | '%{gmake} install', | ||||||||||||||||||||||||||||
| 1007 | ]; | ||||||||||||||||||||||||||||
| 1008 | }; | ||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||
| 1010 | ... | ||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||
| 1012 | =head2 inline_auto_include | ||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | my(@headers) = Alien::MyLibrary->inline_auto_include; | ||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||
| 1016 | List of header files to automatically include in inline C and C++ | ||||||||||||||||||||||||||||
| 1017 | code when using L<Inline::C> or L<Inline::CPP>. This is provided | ||||||||||||||||||||||||||||
| 1018 | as a public interface primarily so that it can be overridden at run | ||||||||||||||||||||||||||||
| 1019 | time. This can also be specified in your C<Build.PL> with | ||||||||||||||||||||||||||||
| 1020 | L<Alien::Base::ModuleBuild> using the C<alien_inline_auto_include> | ||||||||||||||||||||||||||||
| 1021 | property. | ||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||
| 1023 | =head2 runtime_prop | ||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||
| 1025 | my $hashref = Alien::MyLibrary->runtime_prop; | ||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||
| 1027 | Returns a hash reference of the runtime properties computed by L<Alien::Build> during its | ||||||||||||||||||||||||||||
| 1028 | install process. If the L<Alien::Base> based L<Alien> was not built using L<Alien::Build>, | ||||||||||||||||||||||||||||
| 1029 | then this will return undef. | ||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||
| 1031 | =head2 alt | ||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||
| 1033 | my $new_alien = Alien::MyLibrary->alt($alt_name); | ||||||||||||||||||||||||||||
| 1034 | my $new_alien = $old_alien->alt($alt_name); | ||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||
| 1036 | Returns an L<Alien::Base> instance with the alternate configuration. | ||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||
| 1038 | Some packages come with multiple libraries, and multiple C<.pc> files to | ||||||||||||||||||||||||||||
| 1039 | use with them. This method can be used with C<pkg-config> plugins to | ||||||||||||||||||||||||||||
| 1040 | access different configurations. (It could also be used with non-pkg-config | ||||||||||||||||||||||||||||
| 1041 | based packages too, though there are not as of this writing any build | ||||||||||||||||||||||||||||
| 1042 | time plugins that take advantage of this feature). | ||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||
| 1044 | From your L<alienfile> | ||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||
| 1046 | use alienfile; | ||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||
| 1048 | plugin 'PkgConfig' => ( | ||||||||||||||||||||||||||||
| 1049 | pkg_name => [ 'libfoo', 'libbar', ], | ||||||||||||||||||||||||||||
| 1050 | ); | ||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||
| 1052 | Then in your base class works like normal: | ||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||
| 1054 | package Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||
| 1056 | use parent qw( Alien::Base ); | ||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||
| 1058 | 1; | ||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||
| 1060 | Then you can use it: | ||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||
| 1062 | use Alien::MyLibrary; | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | my $cflags = Alien::MyLibrary->alt('foo1')->cflags; | ||||||||||||||||||||||||||||
| 1065 | my $libs = Alien::MyLibrary->alt('foo1')->libs; | ||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||
| 1067 | =head2 alt_names | ||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||
| 1069 | my @alt_names = Alien::MyLibrary->alt_names | ||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||
| 1071 | Returns the list of all available alternative configuration names. | ||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||
| 1073 | =head2 alt_exists | ||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||
| 1075 | my $bool = Alien::MyLibrary->alt_exists($alt_name) | ||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||
| 1077 | Returns true if the given alternative configuration exists. | ||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||
| 1079 | =head1 SUPPORT AND CONTRIBUTING | ||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||
| 1081 | First check the L<Alien::Build::Manual::FAQ> for questions that have already been answered. | ||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||
| 1083 | IRC: #native on irc.perl.org | ||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||
| 1085 | L<(click for instant chatroom login)|http://chat.mibbit.com/#native@irc.perl.org> | ||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||
| 1087 | If you find a bug, please report it on the projects issue tracker on GitHub: | ||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||
| 1089 | =over 4 | ||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||
| 1091 | =item L<https://github.com/PerlAlien/Alien-Build/issues> | ||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||
| 1093 | =back | ||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||
| 1095 | Development is discussed on the projects google groups. This is also | ||||||||||||||||||||||||||||
| 1096 | a reasonable place to post a question if you don't want to open an issue | ||||||||||||||||||||||||||||
| 1097 | in GitHub. | ||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||
| 1099 | =over 4 | ||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||
| 1101 | =item L<https://groups.google.com/forum/#!forum/perl5-alien> | ||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||
| 1103 | =back | ||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||
| 1105 | If you have implemented a new feature or fixed a bug, please open a pull | ||||||||||||||||||||||||||||
| 1106 | request. | ||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||
| 1108 | =over 4 | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | =item L<https://github.com/PerlAlien/Alien-Build/pulls> | ||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||
| 1112 | =back | ||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||
| 1114 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||
| 1116 | =over | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | =item * | ||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||
| 1120 | L<Alien::Build> | ||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||
| 1122 | =item * | ||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||
| 1124 | L<alienfile> | ||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||
| 1126 | =item * | ||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||
| 1128 | L<Alien> | ||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||
| 1130 | =item * | ||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||
| 1132 | L<Alien::Build::Manual::FAQ> | ||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||
| 1134 | =back | ||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||
| 1136 | =head1 THANKS | ||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||
| 1138 | C<Alien::Base> was originally written by Joel Berger, and that | ||||||||||||||||||||||||||||
| 1139 | code is still Copyright (C) 2012-2017 Joel Berger. It has the | ||||||||||||||||||||||||||||
| 1140 | same license as the rest of the L<Alien::Build>. | ||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||
| 1142 | Special thanks for the early development of C<Alien::Base> go to: | ||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||
| 1144 | =over | ||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||
| 1146 | =item Christian Walde (Mithaldu) | ||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||
| 1148 | For productive conversations about component interoperability. | ||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | =item kmx | ||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||
| 1152 | For writing Alien::Tidyp from which I drew many of my initial ideas. | ||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||
| 1154 | =item David Mertens (run4flat) | ||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||
| 1156 | For productive conversations about implementation. | ||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||
| 1158 | =item Mark Nunberg (mordy, mnunberg) | ||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||
| 1160 | For graciously teaching me about rpath and dynamic loading, | ||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||
| 1162 | =back | ||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||
| 1164 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||
| 1166 | Author: Graham Ollis E<lt>plicease@cpan.orgE<gt> | ||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||
| 1168 | Contributors: | ||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||
| 1170 | Diab Jerius (DJERIUS) | ||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||
| 1172 | Roy Storey (KIWIROY) | ||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||
| 1174 | Ilya Pavlov | ||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||
| 1176 | David Mertens (run4flat) | ||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||
| 1178 | Mark Nunberg (mordy, mnunberg) | ||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||
| 1180 | Christian Walde (Mithaldu) | ||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||
| 1182 | Brian Wightman (MidLifeXis) | ||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||
| 1184 | Zaki Mughal (zmughal) | ||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||
| 1186 | mohawk (mohawk2, ETJ) | ||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||
| 1188 | Vikas N Kumar (vikasnkumar) | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | Flavio Poletti (polettix) | ||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||
| 1192 | Salvador Fandiño (salva) | ||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||
| 1194 | Gianni Ceccarelli (dakkar) | ||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||
| 1196 | Pavel Shaydo (zwon, trinitum) | ||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||
| 1198 | Kang-min Liu (劉康民, gugod) | ||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||
| 1200 | Nicholas Shipp (nshp) | ||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||
| 1202 | Juan Julián Merelo Guervós (JJ) | ||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | Joel Berger (JBERGER) | ||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||
| 1206 | Petr Písař (ppisar) | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | Lance Wicks (LANCEW) | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | Ahmad Fatoum (a3f, ATHREEF) | ||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||
| 1212 | José Joaquín Atria (JJATRIA) | ||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||
| 1214 | Duke Leto (LETO) | ||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||
| 1216 | Shoichi Kaji (SKAJI) | ||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||
| 1218 | Shawn Laffan (SLAFFAN) | ||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||
| 1220 | Paul Evans (leonerd, PEVANS) | ||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||
| 1222 | Håkon Hægland (hakonhagland, HAKONH) | ||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||
| 1224 | nick nauwelaerts (INPHOBIA) | ||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||
| 1226 | Florian Weimer | ||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||
| 1228 | Marcel Telka (mtelka) | ||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||
| 1230 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||
| 1232 | This software is copyright (c) 2011-2022 by Graham Ollis. | ||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||
| 1234 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 1235 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||
| 1237 | =cut | ||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||
| 1239 | __END__ | ||||||||||||||||||||||||||||