Alien-libtermkey
view release on metacpan or search on metacpan
inc/Alien/make/Module/Build.pm view on Meta::CPAN
my $dstfile = File::Spec->catfile( $blib, "lib", @module_file );
unless( $self->up_to_date( $srcfile, $dstfile ) ) {
my %replace = (
USE_BUNDLED => $self->notes( 'use_bundled' ),
PKGCONFIG_MODULE => $pkgconfig_module,
);
# Turn ' into \' in replacements
s/'/\\'/g for values %replace;
$self->cp_file_with_replacement(
srcfile => $srcfile,
dstfile => $dstfile,
replace => \%replace,
);
}
}
sub cp_file_with_replacement
{
my $self = shift;
my %args = @_;
my $srcfile = $args{srcfile};
my $dstfile = $args{dstfile};
my $replace = $args{replace};
make_path( dirname( $dstfile ), { mode => 0777 } );
open( my $inh, "<", $srcfile ) or die "Cannot read $srcfile - $!";
open( my $outh, ">", $dstfile ) or die "Cannot write $dstfile - $!";
while( my $line = <$inh> ) {
$line =~ s/\@$_\@/$replace->{$_}/g for keys %$replace;
print $outh $line;
}
}
sub ACTION_test
{
my $self = shift;
return unless $self->notes( 'use_bundled' );
$self->apply_extra_pkgconfig_paths;
$self->depends_on( "code" );
$self->make_in_srcdir( "test" );
}
sub ACTION_install
{
my $self = shift;
$self->apply_extra_pkgconfig_paths;
# There's two bugs in just doing this:
# 1) symlinks (e.g. libfoo.so => libfoo.so.1) get copied as new files
# 2) needlessly considers the .pc file different and copies/relocates it
# every time.
# Both of these are still under investigation
$self->SUPER::ACTION_install;
# The .pc file that 'ACTION_install' has written contains the build-time
# blib paths in it. We need that rewritten for the real install location
#
# We don't do this at 'ACTION_code' time, because of one awkward cornercase.
# When 'cpan> test Foo' is testing an entire tree of dependent modules, it
# never installs them, instead adding each of them to the PERL5LIB in turn
# so later ones can find them. We needed the path to be "correct" at that
# point so that dependent modules can at least find something to link and
# test against.
my $buildlibdir = File::Spec->catdir( $self->base_dir, "blib", "arch" );
my $instlibdir = $self->install_destination( "arch" );
my $pkgconfig_module = $self->pkgconfig_module;
my $pcfile = "$instlibdir/pkgconfig/$pkgconfig_module.pc";
if( -f $pcfile ) {
print "Relocating $pcfile";
open my $in, "<", $pcfile or die "Cannot open $pcfile for reading - $!";
open my $out, ">", "$pcfile.new" or die "Cannot open $pcfile.new for writing - $!";
print { $out } join "\n",
"# pkg-config paths rewritten by Alien::make::Module::Build",
"# buildlibdir=$buildlibdir",
"# instlibdir=$instlibdir",
"";
while( <$in> ) {
s{\Q$buildlibdir\E}{$instlibdir}g;
print { $out } $_;
}
# Cygwin/Windows doesn't like it when you delete open files
close $in;
close $out;
unlink $pcfile;
rename "$pcfile.new", $pcfile;
}
}
sub ACTION_clean
{
my $self = shift;
if( $self->notes( 'use_bundled' ) ) {
$self->apply_extra_pkgconfig_paths;
if( -d $self->_srcdir ) {
$self->make_in_srcdir( "clean" );
}
unlink( $self->_stampfile( "build" ) );
}
( run in 2.169 seconds using v1.01-cache-2.11-cpan-71847e10f99 )