alienfile

filter: Statementstmt 46.2% 31 / 67 Branchbran 12.5% 2 / 16 Conditioncond 8.3% 1 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 50.0% 5 / 10 Podpod n/a totaltotal 34.8% 39 / 112 CC 14 SCAR 34.1
CC
14
Cov
36%
__ANON__
72.0
__ANON__
20.0
__ANON__
7.9
CRAP 30.4
↑ Summary blib/lib/Alien/Libxml2/Install/Files.pm »
1 1 ▶use alienfile;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶configure { requires 'Alien::Build' => '2.37' };
Subroutine __ANON__: called CC=1 SCAR=0.0
5  
6 1 my $test_program = <<'EOF';
7 #include <stdio.h>
8 #include <libxml/xmlversion.h>
9 #include <libxml/parser.h>
10 #include <libxml/tree.h>
11  
12 int
13 main(int argc, char *argv[])
14 {
15 xmlDoc *doc = NULL;
16 /*
17 * xmlRead should fail, but having this call ensures
18 * that the we have access to the symbols in -lxml2
19 * (LIBXML_DOTTED_VERSION below is in the header file)
20 */
21 doc = xmlReadFile("foo.xml", NULL, 0);
22 printf("xml version = '%s'\n", LIBXML_DOTTED_VERSION);
23 }
24 EOF
25  
26 1 my @try_flags = (
27 { cflags => '', libs => '-lxml2' },
28 { cflags => '-I/usr/include/libxml2', libs => '-lxml2' },
29 { cflags => '-I/usr/local/include/libxml2', libs => '-lxml2' },
30 );
31  
32 1 plugin 'Probe::Vcpkg' => 'libxml2';
33  
34 1 probe [
35 ['xml2-config', '--version' => \'%{.install.my_version}'],
36 ['xml2-config', '--cflags' => \'%{.install.my_cflags}'],
37 ['xml2-config', '--libs' => \'%{.install.my_libs}'],
38 ];
39  
40 1 plugin 'PkgConfig' => 'libxml-2.0';
41  
42 plugin 'Probe::CBuilder' => (
43 cflags => $_->{cflags},
44 libs => $_->{libs},
45 program => $test_program,
46 version => qr{xml version = '(.*?)'},
47 1 ) for @try_flags;
48 1 plugin 'PkgConfig::MakeStatic' => ();
49  
50 119 my %bad_versions = map { $_ => 1 } (
51 # known bad versions
52 # may have some extras, and may be incomplete.
53 # but probably sufficient.
54 # computed using maint/tags-to-versions.pl and the git repository
55 # for libxml2.
56 '2.0.0',
57 '2.1.0','2.1.1',
58 '2.2.0','2.2.1','2.2.2','2.2.3','2.2.4','2.2.5','2.2.6','2.2.7','2.2.8',
59 '2.3.0','2.3.1','2.3.2','2.3.3','2.3.4','2.3.5','2.3.6','2.3.7','2.3.8','2.3.9','2.3.10','2.3.11','2.3.12','2.3.13','2.3.14',
60 '2.4.0','2.4.1','2.4.2','2.4.3','2.4.4','2.4.5','2.4.6','2.4.7','2.4.8','2.4.9','2.4.10','2.4.11','2.4.12','2.4.13','2.4.14','2.4.15','2.4.16','2.4.17','2.4.18','2.4.19','2.4.20','2.4.21','2.4.22','2.4.23','2.4.24','2.4.25','2.4.26','2.4.27','2.4.28','2.4.29','2.4.30',
61 '2.5.0','2.5.1','2.5.2','2.5.3','2.5.4','2.5.5','2.5.6','2.5.7','2.5.8','2.5.9','2.5.10','2.5.11',
62 '2.6.0','2.6.1','2.6.2','2.6.3','2.6.4','2.6.5','2.6.6','2.6.7','2.6.8','2.6.9','2.6.10','2.6.11','2.6.12','2.6.13','2.6.14','2.6.15','2.6.19','2.6.20','2.6.25',
63 '2.7.0','2.7.1',
64 '2.9.4',
65 # The next set have reported CVEs
66 10 (map {'2.11.' . $_} (0 .. 9)),
67 10 (map {'2.12.' . $_} (0 .. 9)),
68 1 (map {'2.13.' . $_} (0 .. 6)),
69 );
70  
71 meta->around_hook(
72 0 ▶ probe => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
73 0 my $orig = shift;
74 0 my $build = shift;
75 0 my $install_type = $orig->($build, @_);
76 # if the system type is install, make sure the version isn't on the
77 # blacklist.
78 # Honor $ENV{FORCE} used in the Makefile.PL for XML-LibXML to allow
79 # versions on the blacklist.
80 0 ▶ if($install_type eq 'system' && !$ENV{FORCE})
Branch: 1 branch
BranchTrueFalseTotal
if ($install_type eq "system" and not $ENV{"FORCE"}) 0 0 0
Condition0%0/3
$install_type eq "system" and not $ENV{"FORCE"}
!ll&&!rl&&r
000
MC/DC0%0/2
$install_type eq "system" and not $ENV{"FORCE"}
$install_type eq "system" not $ENV{"FORCE"}
Truth table0%0/3
A and not(B)
A= $install_type eq "system"B= not $ENV{"FORCE"}
ABresult
0X0
100
111
81 {
82 # the first is provided by Probe::CBuilder, or pkg-config plugins for AB >= 1.61
83 # the second is generated by the Probe::CBuilder plugin since forever (or thereabouts)
84 # the thirds is from this alienfile, (see above with the xml2-config probe).
85 my $version = $build->hook_prop->{version} ||
86 $build->install_prop->{plugin_probe_cbuilder_gather}->{version} ||
87 0 ▶ $build->install_prop->{my_version};
Condition0%0/6
$build->hook_prop->{'version'} || $build->install_prop->{'plugin_probe_cbuilder_gather'}{'version'} || $build->install_prop->{'my_version'}
l!l&&r!l&&!r
000
$build->hook_prop->{"version"} or $build->install_prop->{"plugin_probe_cbuilder_gather"}{"version"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$build->hook_prop->{'version'} || $build->install_prop->{'plugin_probe_cbuilder_gather'}{'version'} || $build->install_prop->{'my_version'}
$build->hook_prop->{"version"} $build->install_prop->{"plugin_probe_cbuilder_gather"}{"version"} $build->install_prop->{'my_version'}
Truth table0%0/4
A or B || C
A= $build->hook_prop->{"version"}B= $build->install_prop->{"plugin_probe_cbuilder_gather"}{"version"}C= $build->install_prop->{'my_version'}
ABCresult
1XX1
01X1
0011
0000
88  
89 0 $version =~ s/-.*$//g;
90  
91 0 ▶ unless(defined $version)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $version) 0 0 0
92 {
93 0 print STDERR "Unfortunately, Alien::Libxml2 requires the version from the system libxml2 in\n",
94 "order to determine if it is acceptible for use, but Alien::Build prior to 1.61\n",
95 "did not provide this information in the probe step. Alien::Libxml2 can still\n",
96 "find the system libxml2 on systems with xml2-config in the PATH, or if libxml2\n",
97 "is available from one of the commonly known locations. If you want to detect\n",
98 "the system libxml2 with a .pc file via pkg-config, then please upgrade\n",
99 "Alien::Build to 1.61 or better\n";
100 0 return 'share';
101 }
102  
103 0 ▶ if($bad_versions{$version})
Branch: 1 branch
BranchTrueFalseTotal
if ($bad_versions{$version}) 0 0 0
104 {
105 0 print STDERR "Alien::Libxml2 is designed to work with XML::LibXML.\n\n".
106 "The installed system version of libxml2 $version is not compatible with XML::LibXML (and probably buggy)!\n\n".
107 " - don't expect XML::LibXML to build or work correctly with this version of libxml2!\n" .
108 " - don't report errors with this version of libxml2!\n" .
109 " - don't send patches for this version of libxml2!\n\n";
110 0 ▶ if($version eq '2.9.4')
Branch: 1 branch
BranchTrueFalseTotal
if ($version eq '2.9.4') { } 0 0 0
111 {
112 0 print STDERR "XML::LibXML typically attempts to install with this version anyway, so will we.\n";
113 }
114 else
115 {
116 0 print STDERR "XML::LibXML typcially refuses to install with this version unless forced, so we will\n";
117 0 print STDERR "attempt to download a newer version from the internet. If you prefer you can force\n";
118 0 print STDERR "Alien::Libxml2 to install with this possibly buggy version using:\n";
119 0 print STDERR "env FORCE=1 perl Makefile.PL\n";
120 0 print STDERR "or\n";
121 0 print STDERR "env FORCE=1 cpanm Alien::Libxml2\n";
122 0 return 'share';
123 }
124 }
125 }
126 0 $install_type;
127 },
128 1 );
129  
130 1 plugin 'Prefer::BadVersion' => [ keys %bad_versions ];
131  
132 1 ▶share {
Subroutine __ANON__: called CC=4 SCAR=20.7
133  
134 # out of source build is borked on Windows, so we turn it
135 # off there. Turn it on elsewhere as it saves a copy.
136 1 ▶ meta->prop->{out_of_source} = $^O eq 'MSWin32' ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 1 1
137  
138 plugin 'Download::GitLab' => (
139 gitlab_host => 'https://gitlab.gnome.org',
140 gitlab_user => 'GNOME',
141 gitlab_project => 'libxml2',
142 type => 'link',
143 format => 'tar.xz',
144 version_from => 'tag_name',
145 0 ▶ convert_version => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
146 0 my $version = shift;
147 0 $version =~ s/^v//;
148 0 $version;
149 },
150 1 );
151  
152 1 ▶ if($^O eq 'MSWin32' && $Config{ccname} eq 'cl')
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32' and $Alien::Build::Auto::X0::Alienfile::Config{'ccname'} eq 'cl') { } 0 1 1
Condition33%1/3
$^O eq "MSWin32" and $Alien::Build::Auto::X0::Alienfile::Config{"ccname"} eq "cl"
!ll&&!rl&&r
100
MC/DC0%0/2
$^O eq "MSWin32" and $Alien::Build::Auto::X0::Alienfile::Config{"ccname"} eq "cl"
$^O eq "MSWin32" $Alien::Build::Auto::X0::Alienfile::Config{"ccname"} eq "cl"
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $Alien::Build::Auto::X0::Alienfile::Config{"ccname"} eq "cl"
ABresult
0X0
100
111
153 {
154 build [
155 0 ▶ sub { shift->install_prop->{prefix} =~ s/\//\\/g;},
Subroutine __ANON__: not called CC=1 SCAR=6.9
156 0 'cd win32',
157 'cscript configure.js prefix=%{.install.prefix} iconv=no compiler=msvc static=yes',
158 'nmake -f Makefile.msvc',
159 'nmake -f Makefile.msvc install',
160 ];
161  
162 0 plugin 'Gather::IsolateDynamic';
163  
164 0 ▶ gather sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
165 0 my($build) = @_;
166 0 my $prefix = $build->runtime_prop->{prefix};
167 0 $build->runtime_prop->{cflags} = "-I$prefix/include/libxml2";
168 0 $build->runtime_prop->{libs} = "-L$prefix/lib libxml2_a.lib";
169 0 };
170 }
171 else
172 {
173 1 plugin 'Build::Autoconf' => ();
174  
175 1 build [
176 '%{configure} --prefix=%{.install.autoconf_prefix} --without-python --disable-shared --enable-static',
177 '%{make}',
178 '%{make} install',
179 ];
180  
181 1 plugin 'PkgConfig::MakeStatic' => ();
182 }
183  
184 1 };
185  
186 1 ▶sys {
Subroutine __ANON__: called CC=1 SCAR=5.3
187  
188 meta->after_hook(
189 0 ▶ gather_system => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
190 0 my($build) = @_;
191 0 ▶ return if defined $build->runtime_prop->{libs};
Branch: 1 branch
BranchTrueFalseTotal
if defined $build->runtime_prop->{"libs"} 0 0 0
192 0 ▶ if($build->install_prop->{my_libs})
Branch: 1 branch
BranchTrueFalseTotal
if ($build->install_prop->{"my_libs"}) 0 0 0
193 {
194 0 $build->runtime_prop->{$_} = $build->install_prop->{"my_$_"} for qw( version cflags libs );
195 }
196 },
197 1 );
198  
199 1 };
↑ Summary blib/lib/Alien/Libxml2/Install/Files.pm »