File: NeedsCompiler.pm

package info (click to toggle)
libmodule-cpants-analyse-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 312 kB
  • sloc: perl: 2,192; makefile: 2
file content (107 lines) | stat: -rw-r--r-- 2,548 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package Module::CPANTS::Kwalitee::NeedsCompiler;
use warnings;
use strict;

our $VERSION = '1.02';
$VERSION =~ s/_//; ## no critic

sub order { 200 }

##################################################################
# Analyse
##################################################################

sub analyse {
    my $class = shift;
    my $me = shift;
    
    my $files = $me->d->{files_array};
    foreach my $f (@$files) {
        if ($f =~ /\.[hc]$/i or $f =~ /\.xs$/i) {
            $me->d->{needs_compiler} = 1;
            return;
        }
    }
    if (defined ref($me->d->{prereq}) and ref($me->d->{prereq}) eq 'ARRAY') {
        for my $m (@{ $me->d->{prereq} }) {
            if ($m->{requires} =~ /^Inline::/
               or $m->{requires} eq 'ExtUtils::CBuilder'
               or $m->{requires} eq 'ExtUtils::ParseXS') {
                $me->d->{needs_compiler} = 1;
                return;
            }
        }
    }
    return;
}

##################################################################
# Kwalitee Indicators
##################################################################

sub kwalitee_indicators{
    return [
    ];
}


q{Favourite compiler:
  gcc};

__END__

=encoding UTF-8

=head1 NAME

Module::CPANTS::Kwalitee::NeedsCompiler - Checks if the module needs a (probably C) compiler

=head1 SYNOPSIS

Checks if there is some indication in the module that it needs a C compiler to build and install

=head1 DESCRIPTION

=head2 Methods

=head3 order

Defines the order in which Kwalitee tests should be run.

Returns C<200>.

=head3 analyse

Checks for file with F<.c>, F<.h> or F<.xs> extensions.
Check is the module depends on any of the Inline:: modules or
on ExtUtils::CBuilder or ExtUtils::ParseXS.

=head3 TODO:

How to recognize cases such as https://metacpan.org/release/GAAS/Perl-API-0.01/
and https://metacpan.org/release/Term-Size-Perl
that generate the .c files during installation

In addition there are modules that can work without their XS part.
E.g. Scalar-List-Utils, Net-DNS, Template-Toolkit 
For our purposes these all should be marked as "need C compiler"
as they need it for their full functionality and speed.
 
=head3 kwalitee_indicators

No Kwalitee Indicator.

=head1 SEE ALSO

L<Module::CPANTS::Analyse>

=head1 AUTHOR

L<Gábor Szabó|https://metacpan.org/author/szabgab>

=head1 COPYRIGHT AND LICENSE

Copyright © 2006–2008 L<Gábor Szabó|https://metacpan.org/author/szabgab>

You may use and distribute this module according to the same terms
that Perl is distributed under.