App-Chart
view release on metacpan or search on metacpan
devel/makefile-from-grep.pl view on Meta::CPAN
#!/usr/bin/perl -w
# Copyright 2008, 2009, 2010, 2011, 2012, 2016 Kevin Ryde
# This file is part of Chart.
#
# Chart is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3, or (at your option) any later version.
#
# Chart is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Chart. If not, see <http://www.gnu.org/licenses/>.
# Usage: ./makefile-from-grep.pl
#
# Grep through the sources in the MANIFEST file and compare the modules and
# their versions against what's in Makefile.PL.
#
use strict;
use warnings;
use ExtUtils::Manifest;
use File::chdir;
use File::Find;
use File::Spec;
use FindBin;
use Module::CoreList;
use Module::Depends::Intrusive;
use Perl6::Slurp; # for :gzip layer
use version;
use YAML;
# uncomment this to run the ### lines
#use Smart::Comments;
# use lib::abs File::Spec->catdir ($FindBin::Bin, 'lib');
use lib::abs $FindBin::RealBin;
use MyExtractUse;
my $verbose = 0;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my $minimum_perl_version = version->new('5');
# version->new('v5.6.0');
if (@ARGV && $ARGV[0] eq '--verbose') {
$verbose = 1;
shift @ARGV;
}
my $toplevel_dir = File::Spec->curdir;
# File::Spec->catdir ($FindBin::Bin, File::Spec->updir);
print "toplevel $toplevel_dir\n";
# for Module::Depends::Intrusive ...
push @INC, File::Spec->catdir ($toplevel_dir, 'inc');
my $makefile_filename = File::Spec->catdir ($toplevel_dir, 'Makefile.PL');
my $makefile_contents = Perl6::Slurp::slurp ($makefile_filename);
if ($makefile_contents =~ /^(use|require) (5\.[0-9.]+)/m) {
$minimum_perl_version = version->new ($2);
print "Makefile.PL: perl version $minimum_perl_version\n";
}
my $manifest_file = File::Spec->catfile ($toplevel_dir, 'MANIFEST');
# hash of { FILENAME => COMMENT }
my $manifest = ExtUtils::Manifest::maniread ($manifest_file);
my @main_files = sort keys %$manifest;
sub split_out {
my ($dest, $regexp) = @_;
@main_files = grep { $_ =~ $regexp ? do{push @$dest,$_;0} : 1 } @main_files;
}
my @test_files;
split_out (\@test_files, qr{^t/});
@test_files = grep { /\.pm$|\.t$/ } @test_files; # not data files
@test_files = grep { ! m{MyTestHelpers} } @test_files;
my @devel_files;
split_out (\@devel_files, qr{^devel/|^inc/my_|^xt/});
my @examples_files;
split_out (\@examples_files, qr{^examples/});
@main_files = grep { ! m{^xt/} } @main_files;
@main_files = grep { ! m{^misc/} } @main_files;
@main_files = grep { ! m{^maybe/} } @main_files;
@main_files = grep { /\.pm$|\.t$|^chart$/ } @main_files;
unshift @main_files, makefile_exe_files();
@main_files = map { File::Spec->catfile ($toplevel_dir, $_) } @main_files;
#
# splice @main_files,3;
print "Check: \n ",join("\n ",@main_files),"\n";
sub makefile_exe_files {
$makefile_contents =~ /EXE_FILES.*=>.*(\[.*)/ or return;
return @{eval $1};
}
my %own_module;
( run in 2.395 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )