Re: [Module-build-general] PL_files
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-05-07 22:50:46
|
On Sunday, April 27, 2003, at 04:05 PM, Dominic Mitchell wrote:
> I've got a .PL file that I'm trying to get run as part of my build.
>
> Module::Build->new(
> module_name => 'MyModule',
> PL_files => {
> 'lib/mkconst.PL' => [],
> },
> );
>
> However, the mkconst.PL script is not getting run at all. The docs
> appear to indicate that it would get run, and that there would be
> nothing to clean up, based on what I've specified. Is that right?
> Looking at process_PL_files(), it would seem that things only get run
> if
> there's something in the list.
>
> However, taking a step or two back....
>
> What I'm trying to do is rebuild the file lib/Constants.pm from
> lib/Constants.pm.in only if it's out of date. Using
> ExtUtils::MakeMaker, this was (relatively) easy. What's the best way
> to
> do this using Module::Build? I started looking at .PL files to sort it
> out, but I don't think that's the right answer. Would it be better to
> subclass Module::Build and override ACTION_build to do the right thing?
Hi Dominic,
Sorry to take a while to get back to you. The PL_files stuff wasn't
really very well thought-out when you sent your message, but I think
it's in a better state now.
I think the proper answer to your question is to do something like this:
Module::Build->new(
module_name => 'MyModule',
PL_files => {
'lib/Constants.pm.PL' => 'lib/Constants.pm',
},
);
The constants' definitions would be right in lib/Constants.pm.PL. Then
whenever Constants.pm.PL is newer than lib/Constants.pm, the .pm will
get rebuilt.
If you do want to subclass, look at the up_to_date() method in
Module::Build, which will help you know when to re-run the script.
Something like:
my $subclass = Module::Build->subclass( code => <<'EOF' );
sub ACTION_build {
my $self = shift;
$self->SUPER::ACTION_build;
$self->run_perl_script('lib/mkconst.PL', ...arguments...)
unless $self->up_to_date(['lib/mkconst.PL', 'lib/Constants.in'],
'lib/Constants.pm');
}
EOF
$subclass->new( ... )->create_build_script;
-Ken
|