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) $
6 ##############################################################################
8 package Perl::Critic::BuildUtilities;
14 use English q<-no_match_vars>;
16 our $VERSION = '1.088';
18 use base qw{ Exporter };
21 recommended_module_versions
22 test_wrappers_to_generate
24 dump_unlisted_or_optional_module_versions
25 emit_tar_warning_if_necessary
31 use Devel::CheckOS qw< os_is >;
34 sub recommended_module_versions {
39 'Regexp::Parser' => '0.20',
40 'Term::ANSIColor' => 0,
42 # All of these are for Documentation::PodSpelling
46 'Text::ParseWords' => 3,
51 sub test_wrappers_to_generate {
52 my @tests_to_be_wrapped = qw<
55 t/01_config_bad_perlcriticrc.t
59 t/04_optionsprocessor.t
71 t/13_bundled_policies.t
72 t/14_policy_parameters.t
74 t/20_policy_podspelling.t
75 t/20_policy_requiretidycode.t
76 xt/author/80_policysummary.t
78 xt/author/94_includes.t
83 { "xt/author/generated/${_}_without_optional_dependencies.t" }
87 my @TARGET_FILES = qw<
88 lib/Perl/Critic/PolicySummary.pod
89 t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run
90 t/Variables/RequireLocalizedPunctuationVars.run
94 my %PL_files = map { ( "$_.PL" => $_ ) } @TARGET_FILES;
96 $PL_files{'t/generate_without_optional_dependencies_wrappers.PL'} =
97 [ test_wrappers_to_generate() ];
102 sub dump_unlisted_or_optional_module_versions {
104 "\nVersions of optional/unlisted/indirect dependencies:\n\n";
106 my @unlisted_modules = (
109 keys %{ { recommended_module_versions() } },
112 foreach my $module (sort @unlisted_modules) {
115 if ($module eq 'Readonly::XS') {
116 eval 'use Readonly; use Readonly::XS; $version = $Readonly::XS::VERSION;';
119 eval "use $module; \$version = \$${module}::VERSION;";
122 $version = 'not installed';
123 } elsif (not defined $version) {
127 print " $module = $version\n";
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
141 If you get warnings about missing files below, please ensure that you
142 extracted the Perl::Critic tarball using GNU tar.
154 Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
159 Various utilities used in assembling Perl::Critic, primary for use by
160 *.PL programs that generate code.
163 =head1 IMPORTABLE SUBROUTINES
167 =item C<recommended_module_versions()>
169 Returns a hash mapping between recommended (but not required) modules
170 for Perl::Critic and the minimum version required of each module,
173 =item C<test_wrappers_to_generate()>
175 Returns a list of test wrappers to be generated by
176 F<t/generate_without_optional_dependencies_wrappers.PL>.
179 =item C<get_PL_files()>
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.
188 =item C<dump_unlisted_or_optional_module_versions()>
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
196 =item C<emit_tar_warning_if_necessary()>
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.
208 Elliot Shank C<< <perl@galumph.com> >>
211 =head1 LICENCE AND COPYRIGHT
213 Copyright (c) 2007, Elliot Shank C<< <perl@galumph.com> >>. All rights
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.
222 ##############################################################################
225 # cperl-indent-level: 4
227 # indent-tabs-mode: nil
228 # c-indentation-style: bsd
230 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :