summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-07-22 22:10:09 +0200
committerNicholas Clark <nick@ccl4.org>2013-07-24 09:36:12 +0200
commit727d4ce653261272b0d555f474cf1c25d9eda827 (patch)
tree340acf052d1c27f3b66d5c0be1b7136acc580458 /regen
parent5daeb5b0949c8927e159000017a70c6fc5545030 (diff)
downloadperl-727d4ce653261272b0d555f474cf1c25d9eda827.tar.gz
Generate the lib/ cleanup rules in Makefile.SH automatically from MANIFEST.
Diffstat (limited to 'regen')
-rw-r--r--regen/lib_cleanup.pl36
1 files changed, 33 insertions, 3 deletions
diff --git a/regen/lib_cleanup.pl b/regen/lib_cleanup.pl
index ff756a760c..296724eb5f 100644
--- a/regen/lib_cleanup.pl
+++ b/regen/lib_cleanup.pl
@@ -1,7 +1,8 @@
#!perl -w
use strict;
require 'regen/regen_lib.pl';
-use vars '$TAP';
+require 'Porting/pod_lib.pl';
+use vars qw($TAP $Verbose);
# For processing later
my @ext;
@@ -15,7 +16,7 @@ while (<$fh>) {
if (m<^((?:cpan|dist|ext)/[^/]+/ # In an extension directory
(?!t/|private/|corpus/|demo/|testdir/) # but not a test or similar
\S+ # filename characters
- (?:\.pm|\.pod|_pm\.PL|_pod\.PL)) # useful ending
+ (?:\.pm|\.pod|_pm\.PL|_pod\.PL|\.yml)) # useful ending
(?:\s|$) # whitespace or end of line
>x) {
push @ext, $1;
@@ -37,13 +38,18 @@ close $fh
# Lines we need in lib/.gitignore
my %ignore;
+# Directories that the Makfiles should remove
+# With a special case already :-(
+my %rmdir = ('lib/Unicode/Collate/Locale' => 1);
FILE:
foreach my $file (@ext) {
my ($extname, $path) = $file =~ m!^(?:cpan|dist|ext)/([^/]+)/(.*)!
or die "Can't parse '$file'";
- if ($path =~ /\.pod$/) {
+ if ($path =~ /\.yml$/) {
+ next unless $path =~ s!^lib/!!;
+ } elsif ($path =~ /\.pod$/) {
unless ($path =~ s!^lib/!!) {
# ExtUtils::MakeMaker will install it to a path based on the
# extension name:
@@ -90,6 +96,12 @@ foreach my $file (@ext) {
if (!$libdirs{$prefix}) {
# It is a directory that we will create. Ignore everything in it:
++$ignore{"/$prefix/"};
+ ++$rmdir{"lib/$prefix"};
+ pop @parts;
+ while (@parts) {
+ $prefix .= '/' . shift @parts;
+ ++$rmdir{"lib/$prefix"};
+ }
next FILE;
}
$prefix .= '/' . shift @parts;
@@ -101,6 +113,24 @@ foreach my $file (@ext) {
++$ignore{"/$path"};
}
+sub edit_makefile_SH {
+ my ($desc, $contents) = @_;
+ my $start_re = qr/(\trm -f so_locations[^\n]+)/;
+ my ($start) = $contents =~ $start_re;
+ $contents = verify_contiguous($desc, $contents,
+ qr/$start_re\n(?:\t-rmdir [^\n]+\n)+/sm,
+ 'lib directory rmdir rules');
+ # Reverse sort ensures that any subdirectories are deleted first.
+ $contents =~ s{\0}
+ {"$start\n"
+ . wrap(79, "\t-rmdir ", "\t-rmdir ", reverse sort keys %rmdir)
+ . "\n"}e;
+ $contents;
+}
+
+process('Makefile.SH', 'Makefile.SH', \&edit_makefile_SH, $TAP && '', $Verbose);
+
+# This must come last as it can exit early:
if ($TAP && !-d '.git' && !-f 'lib/.gitignore') {
print "ok # skip not being run from a git checkout, hence no lib/.gitignore\n";
exit 0;