Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
}
}
@lib_files = uniq @lib_files;
@lib_files = sort @lib_files;
@lib_paths = uniq @lib_paths;
@inc_paths = uniq @inc_paths;
return { lib => \@lib_paths, inc => \@inc_paths, lib_files => \@lib_files };
}
sub alien_refresh_packlist {
my $self = shift;
my $dir = shift || croak "Must specify a directory to include in packlist";
return unless $self->create_packlist;
my %installed_args;
$installed_args{extra_libs} = [map { File::Spec->catdir($self->destdir, $_) } @INC]
if defined $self->destdir;
my $inst = ExtUtils::Installed->new( %installed_args );
my $packlist = $inst->packlist( $self->module_name );
print "Using " . $packlist->packlist_file . "\n";
my $changed = 0;
my $files = $self->_rscan_destdir($dir);
# This is kind of strange, but MB puts the destdir paths in the
# packfile, when arguably it should not. Usually you will want
# to turn off packlists when you you are building an rpm anyway,
# but for the sake of maximum compat with MB we add the destdir
# back in after _rscan_destdir has stripped it out.
$files = [ map { File::Spec->catdir($self->destdir, $_) } @$files ]
if defined $self->destdir;
for my $file (@$files) {
next if $packlist->{$file};
print "Adding $file to packlist\n";
$changed++;
$packlist->{$file}++;
};
$packlist->write if $changed;
}
sub alien_relocation_fixup {
my($self) = @_;
# so far relocation fixup is only needed on OS X
return unless $^O eq 'darwin';
my $dist_name = $self->dist_name;
my $share = _catdir( $self->install_destination($self->alien_arch ? 'arch' : 'lib'), qw/auto share dist/, $dist_name );
require File::Find;
File::Find::find(sub {
if(/\.dylib$/)
{
# save the original mode and make it writable
my $mode = (stat $File::Find::name)[2];
chmod 0755, $File::Find::name unless -w $File::Find::name;
my @cmd = (
'install_name_tool',
'-id' => $File::Find::name,
$File::Find::name,
);
print "+ @cmd\n";
system @cmd;
# restore the original permission mode
chmod $mode, $File::Find::name;
}
}, $share);
}
sub _rscan_destdir {
my($self, $dir, $pattern) = @_;
my $destdir = $self->destdir;
$dir = _catdir($destdir, $dir) if defined $destdir;
my $files = $self->rscan_dir($dir, $pattern);
$files = [ map { my $dir = $_; $dir =~ s/^$destdir//; $dir } @$files ] if defined $destdir;
$files;
}
# File::Spec uses \ as the file separator on MSWin32, which makes sense
# since it is the default "native" file separator, but in practice / is
# supported everywhere that matters and is significantly less problematic
# in a number of common use cases (e.g. shell quoting). This is a short
# cut _catdir for this rather common pattern where you want catdir with
# / as the file separator on Windows.
sub _catdir {
my $dir = File::Spec->catdir(@_);
$dir =~ s{\\}{/}g if $^O eq 'MSWin32';
$dir;
}
sub alien_install_network {
defined $ENV{ALIEN_INSTALL_NETWORK} ? !!$ENV{ALIEN_INSTALL_NETWORK} : 1;
}
sub alien_download_rule {
if(defined $ENV{ALIEN_DOWNLOAD_RULE}) {
return 'warn' if $ENV{ALIEN_DOWNLOAD_RULE} eq 'default';
return $ENV{ALIEN_DOWNLOAD_RULE} if $ENV{ALIEN_DOWNLOAD_RULE} =~ /^(warn|digest|encrypt|digest_or_encrypt|digest_and_encrypt)$/;
warn "unknown ALIEN_DOWNLOAD_RULE \"ALIEN_DOWNLOAD_RULE\", using \"warn\" instead";
}
return 'warn';
}
1;
=pod
=encoding UTF-8
=head1 NAME
Alien::Base::ModuleBuild - A Module::Build subclass for building Alien:: modules and their libraries
=head1 VERSION
version 1.17
=head1 SYNOPSIS
In your Build.PL:
use Alien::Base::ModuleBuild;
( run in 1.426 second using v1.01-cache-2.11-cpan-98e64b0badf )