File Coverage

blib/lib/Win32/Vcpkg.pm
Criterion Covered Total %
statement 24 37 64.8
branch 7 26 26.9
condition 1 12 8.3
subroutine 8 8 100.0
pod 3 3 100.0
total 43 86 50.0


line stmt bran cond sub pod time code
1             package Win32::Vcpkg;
2              
3 3     3   621234 use strict;
  3         19  
  3         76  
4 3     3   13 use warnings;
  3         5  
  3         62  
5 3     3   67 use 5.008001;
  3         8  
6 3     3   2232 use Path::Tiny ();
  3         31159  
  3         76  
7 3     3   23 use Config;
  3         6  
  3         1170  
8              
9             # ABSTRACT: Interface to Microsoft Vcpkg
10             our $VERSION = '0.03'; # VERSION
11              
12              
13             sub root
14             {
15 1 50   1 1 83 if(defined $ENV{PERL_WIN32_VCPKG_ROOT})
16             {
17 0         0 my $root = Path::Tiny->new($ENV{PERL_WIN32_VCPKG_ROOT});
18 0 0 0     0 if(-d $root && -f $root->child('.vcpkg-root'))
19             {
20 0         0 return $root;
21             }
22             }
23              
24             {
25 1 50       2 my $vcpkg_path_txt = Path::Tiny->new(
  1         11  
26             $^O eq 'MSWin32'
27             ? "~/AppData/Local/vcpkg/vcpkg.path.txt"
28             : "~/.vcpkg/vcpkg.path.txt",
29             );
30 1 50       161 if(-r $vcpkg_path_txt)
31             {
32 0         0 my $path = $vcpkg_path_txt->slurp; # FIXME: what is the encoding of this file?
33 0         0 chomp $path;
34 0         0 my $root = Path::Tiny->new($path);
35 0 0 0     0 if(-d $root && -f $root->child('.vcpkg-root'))
36             {
37 0         0 return $root;
38             }
39             }
40             }
41              
42 1         47 return ();
43             }
44              
45              
46             my $perl_triplet;
47              
48             sub perl_triplet
49             {
50 1 50   1 1 7 return $perl_triplet if $perl_triplet;
51              
52 1 50       4 return $perl_triplet = $ENV{VCPKG_DEFAULT_TRIPLET} if defined $ENV{VCPKG_DEFAULT_TRIPLET};
53              
54 1 50 0     15 if($Config{archname} =~ /^x86_64-linux/)
    0          
    0          
55             {
56 1         4 return $perl_triplet = 'x64-linux';
57             }
58             elsif($^O eq 'darwin' && $Config{ptrsize} == 8)
59             {
60 0         0 return $perl_triplet = 'x64-osx';
61             }
62             elsif($^O eq 'MSWin32')
63             {
64 0 0       0 if($Config{ptrsize} == 4)
    0          
65             {
66 0         0 return $perl_triplet = 'x86-windows';
67             }
68             elsif($Config{ptrsize} == 8)
69             {
70 0         0 return $perl_triplet = 'x64-windows'
71             }
72             }
73 0         0 die "no triplet for this build of Perl";
74             }
75              
76              
77             my %default_triplet = (
78             'MSWin32' => 'x86-windows',
79             'linux' => 'x64-linux',
80             'darwin' => 'x64-osx',
81             );
82              
83             sub default_triplet
84             {
85 1 50 33 1 1 12 $ENV{VCPKG_DEFAULT_TRIPLET} || $default_triplet{$^O} || die "no default triplet for $^O";
86             }
87              
88             1;
89              
90             __END__