Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / inc / Perl / Critic / BuildUtilities.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/inc/Perl/Critic/BuildUtilities.pm $
3 #     $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
4 #   $Author: clonezone $
5 # $Revision: 2489 $
6 ##############################################################################
7
8 package Perl::Critic::BuildUtilities;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13
14 use English q<-no_match_vars>;
15
16 our $VERSION = '1.088';
17
18 use base qw{ Exporter };
19
20 our @EXPORT_OK = qw<
21     recommended_module_versions
22     test_wrappers_to_generate
23     get_PL_files
24     dump_unlisted_or_optional_module_versions
25     emit_tar_warning_if_necessary
26 >;
27
28
29 use lib 't/tlib';
30
31 use Devel::CheckOS qw< os_is >;
32
33
34 sub recommended_module_versions {
35     return (
36         'File::HomeDir'         => 0,
37         'Perl::Tidy'            => 0,
38         'Readonly::XS'          => 0,
39         'Regexp::Parser'        => '0.20',
40         'Term::ANSIColor'       => 0,
41
42         # All of these are for Documentation::PodSpelling
43         'File::Which'           => 0,
44         'IPC::Open2'            => 1,
45         'Pod::Spell'            => 1,
46         'Text::ParseWords'      => 3,
47     );
48 }
49
50
51 sub test_wrappers_to_generate {
52     my @tests_to_be_wrapped = qw<
53         t/00_modules.t
54         t/01_config.t
55         t/01_config_bad_perlcriticrc.t
56         t/01_policy_config.t
57         t/02_policy.t
58         t/03_pragmas.t
59         t/04_optionsprocessor.t
60         t/05_utils.t
61         t/05_utils_ppi.t
62         t/05_utils_pod.t
63         t/06_violation.t
64         t/07_perlcritic.t
65         t/08_document.t
66         t/09_theme.t
67         t/10_userprofile.t
68         t/11_policyfactory.t
69         t/12_policylisting.t
70         t/12_themelisting.t
71         t/13_bundled_policies.t
72         t/14_policy_parameters.t
73         t/15_statistics.t
74         t/20_policy_podspelling.t
75         t/20_policy_requiretidycode.t
76         xt/author/80_policysummary.t
77         t/92_memory_leaks.t
78         xt/author/94_includes.t
79     >;
80
81     return
82         map
83             { "xt/author/generated/${_}_without_optional_dependencies.t" }
84             @tests_to_be_wrapped;
85 }
86
87 my @TARGET_FILES = qw<
88     lib/Perl/Critic/PolicySummary.pod
89     t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run
90     t/Variables/RequireLocalizedPunctuationVars.run
91 >;
92
93 sub get_PL_files {
94     my %PL_files = map { ( "$_.PL" => $_ ) } @TARGET_FILES;
95
96     $PL_files{'t/generate_without_optional_dependencies_wrappers.PL'} =
97         [ test_wrappers_to_generate() ];
98
99     return \%PL_files;
100 }
101
102 sub dump_unlisted_or_optional_module_versions {
103     print
104         "\nVersions of optional/unlisted/indirect dependencies:\n\n";
105
106     my @unlisted_modules = (
107         qw<
108         >,
109         keys %{ { recommended_module_versions() } },
110     );
111
112     foreach my $module (sort @unlisted_modules) {
113         my $version;
114
115         if ($module eq 'Readonly::XS') {
116             eval 'use Readonly; use Readonly::XS; $version = $Readonly::XS::VERSION;';
117         }
118         else {
119             eval "use $module; \$version = \$${module}::VERSION;";
120         }
121         if ($EVAL_ERROR) {
122             $version = 'not installed';
123         } elsif (not defined $version) {
124             $version = 'undef';
125         }
126
127         print "    $module = $version\n";
128     }
129
130     print "\n";
131
132     return;
133 }
134
135 sub emit_tar_warning_if_necessary {
136     if ( os_is( qw<Solaris> ) ) {
137         print <<'END_OF_TAR_WARNING';
138 NOTE: tar(1) on some Solaris systems cannot deal well with long file
139 names.
140
141 If you get warnings about missing files below, please ensure that you
142 extracted the Perl::Critic tarball using GNU tar.
143
144 END_OF_TAR_WARNING
145     }
146 }
147
148 1;
149
150 __END__
151
152 =head1 NAME
153
154 Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
155
156
157 =head1 DESCRIPTION
158
159 Various utilities used in assembling Perl::Critic, primary for use by
160 *.PL programs that generate code.
161
162
163 =head1 IMPORTABLE SUBROUTINES
164
165 =over
166
167 =item C<recommended_module_versions()>
168
169 Returns a hash mapping between recommended (but not required) modules
170 for Perl::Critic and the minimum version required of each module,
171
172
173 =item C<test_wrappers_to_generate()>
174
175 Returns a list of test wrappers to be generated by
176 F<t/generate_without_optional_dependencies_wrappers.PL>.
177
178
179 =item C<get_PL_files()>
180
181 Returns a reference to a hash with a mapping from the name of a .PL
182 program to an array of the parameters to be passed to it, suited for
183 use by L<Module::Build::API/"PL_files"> or
184 L<ExtUtils::MakeMaker/"PL_FILES">.  May print to C<STDOUT> messages
185 about what it is doing.
186
187
188 =item C<dump_unlisted_or_optional_module_versions()>
189
190 Prints to C<STDOUT> a list of all the unlisted (e.g. things in core
191 like L<Exporter>), optional (e.g. L<File::Which>), or potentially
192 indirect (e.g. L<Readonly::XS>) dependencies, plus their versions, if
193 they're installed.
194
195
196 =item C<emit_tar_warning_if_necessary()>
197
198 On some Solaris systems, C<tar(1)> can't deal with long file names and
199 thus files are not correctly extracted from the tarball.  So this
200 prints a warning if the current system is Solaris.
201
202
203 =back
204
205
206 =head1 AUTHOR
207
208 Elliot Shank  C<< <perl@galumph.com> >>
209
210
211 =head1 LICENCE AND COPYRIGHT
212
213 Copyright (c) 2007, Elliot Shank C<< <perl@galumph.com> >>. All rights
214 reserved.
215
216 This program is free software; you can redistribute it and/or modify
217 it under the same terms as Perl itself.  The full text of this license
218 can be found in the LICENSE file included with this module.
219
220 =cut
221
222 ##############################################################################
223 # Local Variables:
224 #   mode: cperl
225 #   cperl-indent-level: 4
226 #   fill-column: 78
227 #   indent-tabs-mode: nil
228 #   c-indentation-style: bsd
229 # End:
230 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :