File Coverage

blib/lib/Win32/Vcpkg/Package.pm
Criterion Covered Total %
statement 37 37 100.0
branch 9 10 90.0
condition 2 3 66.6
subroutine 12 12 100.0
pod 7 7 100.0
total 67 69 97.1


line stmt bran cond sub pod time code
1             package Win32::Vcpkg::Package;
2              
3 2     2   422 use strict;
  2         4  
  2         54  
4 2     2   9 use warnings;
  2         4  
  2         45  
5 2     2   40 use 5.008001;
  2         6  
6 2     2   10 use Win32::Vcpkg;
  2         5  
  2         46  
7 2     2   10 use Path::Tiny ();
  2         2  
  2         721  
8              
9             # ABSTRACT: Interface to Microsoft Vcpkg Packages
10             our $VERSION = '0.02'; # VERSION
11              
12              
13             sub new
14             {
15 6     6 1 12600 my($class, %args) = @_;
16              
17 6 100       33 my $root = defined $args{root} ? Path::Tiny->new($args{root}) : Win32::Vcpkg->root;
18 6   66     441 my $triplet = $args{triplet} || Win32::Vcpkg->perl_triplet;
19 6 50       20 my @lib = @{ $args{lib} || [] };
  6         17  
20 6 100       20 my $debug = defined $args{debug} ? $args{debug} : $ENV{PERL_WIN32_VCPKG_DEBUG};
21              
22 6         10 my $cflags = "-I@{[ $root->child('installed', $triplet, 'include') ]}";
  6         16  
23              
24 6         218 my $libdir = $root->child('installed', $triplet, 'lib');
25 6 100       182 $libdir = $libdir->parent->child('debug','lib') if $debug;
26 6         174 my $libs = "-LIBPATH:$libdir";
27              
28 6         24 foreach my $lib (@lib)
29             {
30 6 100       23 if(-f $libdir->child("$lib.lib"))
31             {
32 5         268 $libs .= " $lib.lib"; # Question: should this be an absolute path?
33             }
34             else
35             {
36 1         58 require Carp;
37 1         200 Carp::croak("unable to find $lib");
38             }
39             }
40              
41             bless {
42             name => $args{_name},
43             version => $args{_version},
44 5         49 root => $root,
45             triplet => $triplet,
46             cflags => $cflags,
47             libs => $libs,
48             }, $class;
49             }
50              
51              
52 3     3 1 1151 sub name { shift->{name} }
53              
54              
55 3     3 1 506 sub version { shift->{version} }
56              
57              
58 7     7 1 940 sub root { shift->{root} }
59              
60              
61 7     7 1 1842 sub triplet { shift->{triplet} }
62              
63              
64 9     9 1 1136 sub cflags { shift->{cflags} }
65              
66              
67 9     9 1 809 sub libs { shift->{libs} }
68              
69             1;
70              
71             __END__