Skip to content

Commit

Permalink
[rt.cpan.org 46991] Don't instll PL_files in bin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@12852 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
schwern committed Jun 16, 2009
1 parent 59ab0bb commit 8a75b8a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -59,6 +59,7 @@ t/new_from_context.t
t/notes.t
t/par.t
t/parents.t
t/PL_files.t
t/pod_parser.t
t/ppm.t
t/runthrough.t
Expand Down
5 changes: 4 additions & 1 deletion lib/Module/Build/API.pod
Expand Up @@ -614,6 +614,9 @@ Here's an example of a simple PL file.
print "Hello, world!\n";
END

PL files are not installed by default, so its safe to put them in
F<lib/> and F<bin/>.


=item pm_files

Expand Down Expand Up @@ -716,7 +719,7 @@ as a string giving the name of a directory in which to find scripts,
or as a string giving the name of a single script file.

The default is to install any scripts found in a F<bin> directory at
the top level of the distribution.
the top level of the distribution, minus any keys of L<PL_files>.

For backward compatibility, you may use the parameter C<scripts>
instead of C<script_files>. Please consider this usage deprecated,
Expand Down
3 changes: 2 additions & 1 deletion lib/Module/Build/Base.pm
Expand Up @@ -3467,7 +3467,8 @@ sub script_files {
return $_ = {$_ => 1};
}

return $_ = { map {$_,1} $self->_files_in('bin') };
my $pl_files = $self->PL_files || {};
return $_ = { map {$_ => 1} grep !$pl_files->{$_}, $self->_files_in('bin') };
}
BEGIN { *scripts = \&script_files; }

Expand Down
53 changes: 53 additions & 0 deletions t/PL_files.t
@@ -0,0 +1,53 @@
#!/usr/bin/perl -w

use strict;
use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
use MBTest tests => 6;
use DistGen;
use Module::Build;


# Set up a distribution for testing
my $dist;
{
$dist = DistGen->new( dir => MBTest->tmpdir );
$dist->regen;
$dist->chdir_in;

my $distname = $dist->name;
$dist->change_build_pl({
module_name => $distname,
PL_files => {
'bin/foo.PL' => 'bin/foo',
'lib/Bar.pm.PL' => 'lib/Bar.pm',
},
});

$dist->add_file("bin/foo.PL", <<'END');
open my $fh, ">", $ARGV[0] or die $!;
print $fh "foo\n";
END

$dist->add_file("lib/Bar.pm.PL", <<'END');
open my $fh, ">", $ARGV[0] or die $!;
print $fh "bar\n";
END

$dist->regen;
}


# Test that PL files don't get installed even in bin or lib
{
my $mb = Module::Build->new_from_context( install_base => "test_install" );
$mb->dispatch("install");

ok -e "test_install/bin/foo", "Generated PL_files installed from bin";
ok -e "test_install/lib/perl5/Bar.pm", " and from lib";

ok !-e "test_install/bin/foo.PL", "PL_files not installed from bin";
ok !-e "test_install/lib/perl5/Bar.pm.PL", " nor from lib";

is slurp("test_install/bin/foo"), "foo\n", "Generated bin contains correct content";
is slurp("test_install/lib/perl5/Bar.pm"), "bar\n", " so does the lib";
}

0 comments on commit 8a75b8a

Please sign in to comment.