Skip Menu |
 

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 85475
Status: open
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: RRA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Hook to add files to realclean
Download (untitled) / with headers
text/plain 738b
I'm currently using the following subclassing so that I can add additional files to realclean: my $class = Module::Build->subclass( code => q{ __PACKAGE__->add_property('add_to_realclean'); sub ACTION_realclean { my ($self) = @_; $self->SUPER::ACTION_realclean(); my $extra = $self->add_to_realclean; if ($extra) { $self->delete_filetree(@{$extra}); } } } ); It would be great if Module::Build would support add_to_realclean (under some name) out of the box. It's useful when additional files should be created during the perl Build.PL step (because, for example, they're metadata that doesn't change during the build process).
Download (untitled) / with headers
text/plain 171b
Hi Russ, there is already a method `$m->add_to_cleanup(...)` which behaves very similarly to what you're proposing. Is there a distinction between that & what you'd like?
CC: RRA [...] cpan.org
Subject: Re: [rt.cpan.org #85475] Hook to add files to realclean
Date: Mon, 20 May 2013 13:39:45 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Russ Allbery <rra [...] stanford.edu>
"Ken Williams via RT" <bug-Module-Build@rt.cpan.org> writes: Show quoted text
Show quoted text
> Hi Russ, there is already a method `$m->add_to_cleanup(...)` which > behaves very similarly to what you're proposing. Is there a distinction > between that & what you'd like?
add_to_cleanup deletes the files on ./Build clean, which is normally what you want. But if you create files during perl Build.PL instead of via ./Build, and then remove them on ./Build clean, you get stuck; ./Build or ./Build test would now fail (assuming the files are needed for something). Of course, that prompts the question "why are you creating files during perl Build.PL"? The answer is that I need to generate some Perl scripts that are used by one of the test cases, and I couldn't figure out another good way of using fix_shebang_line to get the proper path to Perl without modifying a distributed file in place (which causes it to show up with uncommitted changes in the revision control system and just seems not very clean). It seemed easier just add Perl code to the bottom of Build.PL to create those files than to try to figure out the right ./Build target to override to create them, but then I ran into this problem. Maybe I'm just doing it wrong, though? I suppose I could override ACTION_test to create the files in advance of running the test suite, but that also seems awkward. The code I currently have in Build.PL looks like: # Create a command script that will be run by remctld during the test suite. # These scripts will be stored in the t/data directory. # # $build - Module::Build object # $name - Name of command # $code - Perl code, as a string, to put into the script # # Returns: undef # Throws: Text exceptions on I/O failures sub create_command { my ($build, $name, $code) = @_; my $path = File::Spec->catfile(qw(t data), $name); # Create the file. open(my $command, q{>}, $path) or die "Cannot create $path: $!\n"; print {$command} "#!/usr/bin/perl\nuse strict;\nuse warnings;\n" or die "Cannot write to $path: $!\n"; print {$command} $code, "\n" or die "Cannot write to $path: $!\n"; close($command) or die "Cannot write to $path: $!\n"; # Fix the shebang line. $build->fix_shebang_line($path); # Set permissions, which seems to be un-done by fix_shebang_line. chmod(0755, $path) or die "Cannot set permissions on $path: $!\n"; return; } # [...] # Generate the build script. $build->create_build_script; # Generate the commands that will be run by remctld during the test suite. ## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars) create_command($build, 'cmd-hello', 'print "hello world\n" or die "fail\n"'); create_command($build, 'cmd-sleep', 'sleep 3;'); and I then want to add t/data/cmd-hello and t/data/cmd-sleep to the files that are deleted by the realclean target. This is equivalent to the ExtUtils::MakeMaker realclean => { FILES => ''} option. -- Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.