Skip to content

Commit

Permalink
monkeypatch ExtUtils::Manifest::manifind
Browse files Browse the repository at this point in the history
Use proposed solution from
Perl-Toolchain-Gang/ExtUtils-Manifest#16 to
work around "... is encountered a second time" problem.
  • Loading branch information
eserte committed May 22, 2022
1 parent c77a184 commit 168617b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
37 changes: 36 additions & 1 deletion BBBikeBuildUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use vars qw($VERSION @EXPORT_OK);
$VERSION = '0.06';

use Exporter 'import';
@EXPORT_OK = qw(get_pmake module_path module_version get_modern_perl);
@EXPORT_OK = qw(get_pmake module_path module_version get_modern_perl monkeypatch_manifind);

use File::Glob qw(bsd_glob);
use version ();
Expand Down Expand Up @@ -111,6 +111,41 @@ sub get_modern_perl (;@) {
return $^X;
}

# See
# https://github.com/Perl-Toolchain-Gang/ExtUtils-Manifest/issues/5
# https://github.com/Perl-Toolchain-Gang/ExtUtils-Manifest/issues/6
# https://github.com/Perl-Toolchain-Gang/ExtUtils-Manifest/issues/16
sub monkeypatch_manifind {
my(%opts) = @_;
my $v = delete $opts{v};
die 'Unhandled options: ' . join(' ', %opts) if %opts;

if (eval { require ExtUtils::Manifest; $ExtUtils::Manifest::VERSION < 1.66 }) {
if ($v) {
warn "INFO: no need to monkey-patch ExtUtils::Manifest::manifind.\n";
}
} else {
# This is a simplified version of manifind without VMS & MacOS
# support, but containing the follow_skip patch.
my $new_manifind = sub {
my $found = {};
no warnings 'once'; # because of $File::Find::name
my $wanted = sub {
return if -d $_;
(my $name = $File::Find::name) =~ s{^./}{};
$found->{$name} = "";
};
File::Find::find({wanted => $wanted, follow_fast => 1, follow_skip => 2}, '.');
$found;
};
no warnings 'redefine', 'once';
*ExtUtils::Manifest::manifind = $new_manifind;
if ($v) {
warn "INFO: monkey-patched ExtUtils::Manifest::manifind.\n";
}
}
}

1;

__END__
18 changes: 17 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BEGIN {
}

use BBBikeVar;
use BBBikeBuildUtil qw(module_path);
use BBBikeBuildUtil qw(module_path monkeypatch_manifind);

my $action;
GetOptions('action=s' => \$action)
Expand All @@ -33,6 +33,8 @@ my $author = 'Slaven Rezic (' . $BBBike::EMAIL . ')',
my $abstract = "BBBike - ein Routenplaner für Radfahrer in Berlin und Brandenburg";
my($version_major, $version_minor) = $BBBike::VERSION =~ /^(\d+)\.(\d+)/;

monkeypatch_manifind();

######################################################################
# Required modules
#
Expand Down Expand Up @@ -801,6 +803,20 @@ distdir : create_distdir
EOF
}

sub MY::dist_basics {
<<'EOF';
distclean :: realclean distcheck
$(NOECHO) $(NOOP)
distcheck :
$(PERLRUN) -I. -MBBBikeBuildUtil=monkeypatch_manifind "-MExtUtils::Manifest=fullcheck" -e "monkeypatch_manifind; fullcheck"
# not implemented
# - skipcheck: never used
# - manifest: does not work, because some files in directories listed in MANIFEST.SKIP should actually be included
# - veryclean: never used
EOF
}

sub MY::postamble {
use vars qw($bbbike_makefile_admin);
Expand Down
2 changes: 1 addition & 1 deletion Makefile_admin_PL
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ clean-cache:
-rm -rf cache/*
distcheck-fatal:
perl -MExtUtils::Manifest=fullcheck -e '($$missing,$$extra) = fullcheck; if (@$$missing) { die "Missing files found!\n" } if (@$$extra) { die "Extra files found\n" }'
perl -I. -MBBBikeBuildUtil=monkeypatch_manifind -MExtUtils::Manifest=fullcheck -e 'monkeypatch_manifind(); ($$missing,$$extra) = fullcheck; if (@$$missing) { die "Missing files found!\n" } if (@$$extra) { die "Extra files found\n" }'
######################################################################
# Towards git
Expand Down

0 comments on commit 168617b

Please sign in to comment.