File Coverage

blib/lib/Win32/Vcpkg/Package.pm
Criterion Covered Total %
statement 39 42 92.8
branch 10 14 71.4
condition 2 3 66.6
subroutine 12 12 100.0
pod 7 7 100.0
total 70 78 89.7


line stmt bran cond sub pod time code
1             package Win32::Vcpkg::Package;
2              
3 2     2   496 use strict;
  2         4  
  2         56  
4 2     2   9 use warnings;
  2         4  
  2         47  
5 2     2   45 use 5.008001;
  2         5  
6 2     2   8 use Win32::Vcpkg;
  2         4  
  2         43  
7 2     2   9 use Path::Tiny ();
  2         3  
  2         921  
8              
9             # ABSTRACT: Interface to Microsoft Vcpkg Packages
10             our $VERSION = '0.04'; # VERSION
11              
12              
13             sub new
14             {
15 6     6 1 13207 my($class, %args) = @_;
16              
17 6 100       45 my $root = defined $args{root} ? Path::Tiny->new($args{root}) : Win32::Vcpkg->root;
18 6   66     453 my $triplet = $args{triplet} || Win32::Vcpkg->perl_triplet;
19 6 50       17 my @lib = @{ $args{lib} || [] };
  6         18  
20 6 100       17 my $debug = defined $args{debug} ? $args{debug} : $ENV{PERL_WIN32_VCPKG_DEBUG};
21              
22 6         22 my $libdir = $root->child('installed', $triplet, 'lib');
23 6 100       200 $libdir = $libdir->parent->child('debug','lib') if $debug;
24 6         159 my $libs = "-LIBPATH:$libdir";
25              
26 6         23 my $cflags = "-I@{[ $root->child('installed', $triplet, 'include') ]}";
  6         12  
27              
28             my @include =
29             defined $args{include}
30 6 0       242 ? (ref $args{include} eq 'ARRAY' ? @{$args{include}} : ($args{include}))
  0 50       0  
31             : ();
32              
33 6         15 foreach my $include (@include)
34             {
35 0         0 $cflags .= " -I@{[ $root->child('installed', $triplet, 'include', $include) ]}";
  0         0  
36             }
37              
38 6         9 foreach my $lib (@lib)
39             {
40 6 100       15 if(-f $libdir->child("$lib.lib"))
41             {
42 5         268 $libs .= " $lib.lib"; # Question: should this be an absolute path?
43             }
44             else
45             {
46 1         74 require Carp;
47 1         196 Carp::croak("unable to find $lib");
48             }
49             }
50              
51             bless {
52             name => $args{_name},
53             version => $args{_version},
54 5         50 root => $root,
55             triplet => $triplet,
56             cflags => $cflags,
57             libs => $libs,
58             }, $class;
59             }
60              
61              
62 3     3 1 1138 sub name { shift->{name} }
63              
64              
65 3     3 1 475 sub version { shift->{version} }
66              
67              
68 7     7 1 578 sub root { shift->{root} }
69              
70              
71 7     7 1 1829 sub triplet { shift->{triplet} }
72              
73              
74 9     9 1 1135 sub cflags { shift->{cflags} }
75              
76              
77 9     9 1 841 sub libs { shift->{libs} }
78              
79             1;
80              
81             __END__