Extended build system to automatically add "use lib" where needed.
This commit is contained in:
parent
b53938127a
commit
bb10db34d9
|
@ -0,0 +1,33 @@
|
|||
package Simba::Build;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Module::Build;
|
||||
use Data::Dumper;
|
||||
|
||||
our @ISA = ('Module::Build');
|
||||
|
||||
sub ACTION_install {
|
||||
my $self = shift;
|
||||
# print STDERR Dumper($self), "\n";
|
||||
print STDERR $self->install_path->{lib}, "\n";
|
||||
print STDERR Dumper($self->install_map), "\n";
|
||||
my $lib = $self->install_map->{'blib/lib'};
|
||||
for my $script (glob('blib/script/*')) {
|
||||
open (my $in, '<', $script) or die "cannot open $script: $!";
|
||||
open (my $out, '>', "$script.$$") or die "cannot open $script.$$: $!";
|
||||
while (<$in>) {
|
||||
if (m{^use lib 'blib/lib'}) {
|
||||
print $out "use lib '$lib';\n";
|
||||
} else {
|
||||
print $out $_ or die "cannot write to $script.$$: $!";
|
||||
}
|
||||
}
|
||||
close $in or die "cannot close $script: $!";
|
||||
close $out or die "cannot close $script.$$: $!";
|
||||
rename "$script.$$", $script or die "cannot rename $script.$$ to $script: $!";
|
||||
}
|
||||
$self->SUPER::ACTION_install;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue