summaryrefslogtreecommitdiff
path: root/regen/lib_cleanup.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-07-23 10:16:08 +0200
committerNicholas Clark <nick@ccl4.org>2013-07-24 09:36:12 +0200
commit7afc975352a5b293c8c80f132f1e3d80fb349dd4 (patch)
tree6b9805b07d2de1565b99060c47540062c55d347e /regen/lib_cleanup.pl
parent727d4ce653261272b0d555f474cf1c25d9eda827 (diff)
downloadperl-7afc975352a5b293c8c80f132f1e3d80fb349dd4.tar.gz
Generate the lib/ cleanup rules in the Win32 Makefiles from MANIFEST.
Diffstat (limited to 'regen/lib_cleanup.pl')
-rw-r--r--regen/lib_cleanup.pl36
1 files changed, 32 insertions, 4 deletions
diff --git a/regen/lib_cleanup.pl b/regen/lib_cleanup.pl
index 296724eb5f..c9d6e434bd 100644
--- a/regen/lib_cleanup.pl
+++ b/regen/lib_cleanup.pl
@@ -40,7 +40,7 @@ close $fh
my %ignore;
# Directories that the Makfiles should remove
# With a special case already :-(
-my %rmdir = ('lib/Unicode/Collate/Locale' => 1);
+my %rmdir_s = my %rmdir = ('Unicode/Collate/Locale' => 1);
FILE:
foreach my $file (@ext) {
@@ -96,11 +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"};
+ ++$rmdir{$prefix};
+ ++$rmdir_s{$prefix};
pop @parts;
while (@parts) {
$prefix .= '/' . shift @parts;
- ++$rmdir{"lib/$prefix"};
+ ++$rmdir{$prefix};
}
next FILE;
}
@@ -121,14 +122,41 @@ sub edit_makefile_SH {
qr/$start_re\n(?:\t-rmdir [^\n]+\n)+/sm,
'lib directory rmdir rules');
# Reverse sort ensures that any subdirectories are deleted first.
+ # The extensions themselves delete files with the MakeMaker generated clean
+ # targets.
$contents =~ s{\0}
{"$start\n"
- . wrap(79, "\t-rmdir ", "\t-rmdir ", reverse sort keys %rmdir)
+ . wrap(79, "\t-rmdir ", "\t-rmdir ",
+ map {"lib/$_"} reverse sort keys %rmdir)
. "\n"}e;
$contents;
}
+sub edit_win32_makefile {
+ my ($desc, $contents) = @_;
+ my $start = "\t-del /f *.def *.map";
+ my $start_re = quotemeta($start);
+ $contents = verify_contiguous($desc, $contents,
+ qr!$start_re\n(?:\t-if exist (\$\(LIBDIR\)\\\S+) rmdir /s /q \1\n)+!sm,
+ 'Win32 lib directory rmdir rules');
+ # Win32 is (currently) using rmdir /s /q which deletes recursively
+ # (seems to be analogous to rm -r) so we don't explicitly list
+ # subdirectories to delete, and don't need to ensure that subdirectories are
+ # deleted before their parents.
+ # Might be able to rely on MakeMaker generated clean targets to clean
+ # everything, but not in a position to test this.
+ my $lines = join '', map {
+ tr!/!\\!;
+ "\t-if exist \$(LIBDIR)\\$_ rmdir /s /q \$(LIBDIR)\\$_\n"
+ } sort {lc $a cmp lc $b} keys %rmdir_s;
+ $contents =~ s/\0/$start\n$lines/;
+ $contents;
+}
+
process('Makefile.SH', 'Makefile.SH', \&edit_makefile_SH, $TAP && '', $Verbose);
+foreach ('win32/Makefile', 'win32/makefile.mk') {
+ process($_, $_, \&edit_win32_makefile, $TAP && '', $Verbose);
+}
# This must come last as it can exit early:
if ($TAP && !-d '.git' && !-f 'lib/.gitignore') {