Skip to content

Commit

Permalink
Let add_to_cleanup() take glob-style patterns, and use this to cleanu…
Browse files Browse the repository at this point in the history
…p pod2htm* junk

git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@4967 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
kenahoo committed Sep 5, 2004
1 parent a8532e1 commit b73efc2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Build.PL
Expand Up @@ -47,6 +47,8 @@ my $build = new Module::Build
requires => { YAML => ' >= 0.35, < 0.49 ' },
},
},

add_to_cleanup => ['t/Sample/pod2htm*'],
);

$build->create_build_script;
Expand Down
5 changes: 5 additions & 0 deletions Changes
Expand Up @@ -31,6 +31,11 @@ Revision history for Perl extension Module::Build.
if there's no MANIFEST (i.e. explicitly say that a MANIFEST is
required). [Spotted by Adrian Howard]

- The add_to_cleanup() method will now accept glob()-style patterns
in addition to explicit filenames. Also documented the fact that
they can be specified in either Unix-style or native-style
notation.

- Passing a PREFIX value to a pass-through Makefile 'make install'
now has the same effect as passing it to 'perl Makefile.PL' (it
dies with a helpful message).
Expand Down
21 changes: 14 additions & 7 deletions lib/Module/Build.pm
Expand Up @@ -750,13 +750,20 @@ when the C<realclean> action is performed.
=item add_to_cleanup(@files)
You may call C<< $self->add_to_cleanup(@files) >>
to tell C<Module::Build> that certain files should be removed when the
user performs the C<Build clean> action. I decided to provide a
dynamic method, rather than just use a static list of files, because these
static lists can get difficult to manage. I usually prefer to keep
the responsibility for registering temporary files close to the code
that creates them.
You may call C<< $self->add_to_cleanup(@patterns) >> to tell
C<Module::Build> that certain files should be removed when the user
performs the C<Build clean> action. The arguments to the method are
patterns suitable for passing to Perl's C<glob()> function, specified
in either Unix format or the current machine's native format. It's
usually convenient to use Unix format when you hard-code the filenames
(e.g. in F<Build.PL>) and the native format when the names are
programmatically generated (e.g. in a testing script).
I decided to provide a dynamic method of the C<$build> object, rather
than just use a static list of files named in the F<Build.PL>, because
these static lists can get difficult to manage. I usually prefer to
keep the responsibility for registering temporary files close to the
code that creates them.
=item resume()
Expand Down
8 changes: 4 additions & 4 deletions lib/Module/Build/Base.pm
Expand Up @@ -590,7 +590,7 @@ sub _persistent_hash_restore {

sub add_to_cleanup {
my $self = shift;
my %files = map {$_, 1} @_;
my %files = map {$self->localize_file_path($_), 1} @_;
$self->_persistent_hash_write('cleanup', \%files);
}

Expand Down Expand Up @@ -1452,7 +1452,7 @@ sub _find_file_by_type {
sub localize_file_path {
my ($self, $path) = @_;
return $path unless $path =~ m{/};
return File::Spec->catfile( split qr{/}, $path );
return File::Spec->catfile( split m{/}, $path );
}

sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35
Expand Down Expand Up @@ -1619,7 +1619,7 @@ sub _htmlify_pod {
my ($self, %args) = @_;
require Pod::Html;

$self->add_to_cleanup('pod2htmd.x~~', 'pod2htmi.x~~');
$self->add_to_cleanup('pod2htm*');

my ($name, $path) = File::Basename::fileparse($args{rel_path}, qr{\..*});
my @dirs = File::Spec->splitdir($path);
Expand Down Expand Up @@ -1767,7 +1767,7 @@ sub ACTION_versioninstall {

sub ACTION_clean {
my ($self) = @_;
foreach my $item ($self->cleanup) {
foreach my $item (map glob($_), $self->cleanup) {
$self->delete_filetree($item);
}
}
Expand Down

0 comments on commit b73efc2

Please sign in to comment.