blib/lib/Affix/Platform/Haiku.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 55 CC 4 SCAR 23.0
CC
4
Cov
0%
find_library
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 10.0
1 package Affix::Platform::Haiku v1.3.0 {
2 use v5.40;
3 use Path::Tiny qw[path];
4 use Config qw[%Config];
5 use parent 'Affix::Platform::Unix';
6 use parent 'Exporter';
7 our @EXPORT_OK = qw[find_library];
8 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
9 my $so = $Config{so} // 'so';
10  
11 # Haiku has no separate libm/libc: the C library and the math functions are both provided by
12 # libroot.so. Linker probes for `-lm`/`-lc` therefore fail, so resolve those names to libroot
13 # instead.
14 my %alias = ( m => 'root', c => 'root' );
15 my @lib_dirs = qw[
16 /boot/system/lib
17 /boot/system/develop/lib
18 /boot/system/non-packaged/lib
19 /boot/home/config/lib
20 ];
21  
22 sub find_library ( $name, $version //= () ) {
23 my $base = $name;
24 $base =~ s[^lib][];
25 if ( my $target = $alias{$base} ) {
26 my $found = Affix::Platform::Unix::find_library( $target, $version );
27 return $found if defined $found;
28 for my $dir ( grep {-d} @lib_dirs ) {
29 my @cand = grep {/\Alib\Q$target\E\.\Q$so\E/} map { path($_) } path($dir)->children;
30 for my $cand (@cand) {
31 return $cand->realpath->stringify if -e $cand;
32 }
33 }
34 }
35 return Affix::Platform::Unix::find_library( $name, $version );
36 }
37 };
38 #
39 1;