Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
# restore wd
$CWD = $initial_cwd;
return wantarray ? %return : $return{success}; ## no critic (Policy::Community::Wantarray)
}
sub _alien_execute_helper {
my($self, $helper) = @_;
my $code = $self->alien_helper->{$helper};
die "no such helper: $helper" unless defined $code;
if(ref($code) ne 'CODE') {
my $perl = $code;
$code = sub {
my $value = eval $perl; ## no critic (Policy::BuiltinFunctions::ProhibitStringyEval)
die $@ if $@;
$value;
};
}
$code->();
}
sub alien_interpolate {
my $self = shift;
my ($string) = @_;
my $prefix = $self->alien_exec_prefix;
my $configure = $self->alien_configure;
my $share = $self->alien_library_destination;
my $name = $self->alien_name || '';
# substitute:
# install location share_dir (placeholder: %s)
$string =~ s/(?<!\%)\%s/$share/g;
# local exec prefix (ph: %p)
$string =~ s/(?<!\%)\%p/$prefix/g;
# correct incantation for configure on platform
$string =~ s/(?<!\%)\%c/$configure/g;
# library name (ph: %n)
$string =~ s/(?<!\%)\%n/$name/g;
# current interpreter ($^X) (ph: %x)
my $perl = $self->perl;
$string =~ s/(?<!\%)\%x/$perl/g;
$perl =~ s{\\}{/}g if $^O eq 'MSWin32';
$string =~ s/(?<!\%)\%X/$perl/g;
# Version, but only if needed. Complain if needed and not yet
# stored.
if ($string =~ /(?<!\%)\%v/) {
my $version = $self->config_data( 'alien_version' );
if ( ! defined( $version ) ) {
carp "Version substution requested but unable to identify";
} else {
$string =~ s/(?<!\%)\%v/$version/g;
}
}
$string =~ s/(?<!\%)\%\{([a-zA-Z_][a-zA-Z_0-9]+)\}/$self->_alien_execute_helper($1)/eg;
#remove escapes (%%)
$string =~ s/\%(?=\%)//g;
return $string;
}
sub alien_exec_prefix {
my $self = shift;
if ( $self->is_windowsish ) {
return '';
} else {
return './';
}
}
sub alien_configure {
my $self = shift;
my $configure;
if ($self->config_data( 'msys' )) {
$configure = 'sh configure';
} else {
$configure = './configure';
}
if ($self->alien_autoconf_with_pic) {
$configure .= ' --with-pic';
}
$configure;
}
########################
# Post-Build Methods #
########################
sub alien_load_pkgconfig {
my $self = shift;
my $dir = _catdir($self->config_data( 'working_directory' ));
my $pc_files = $self->rscan_dir( $dir, qr/\.pc$/ );
my %pc_objects = map {
my $pc = Alien::Base::PkgConfig->new($_);
$pc->make_abstract( pcfiledir => $dir );
($pc->{package}, $pc)
} @$pc_files;
$pc_objects{_manual} = $self->alien_generate_manual_pkgconfig($dir)
or croak "Could not autogenerate pkgconfig information";
$self->config_data( pkgconfig => \%pc_objects );
return \%pc_objects;
}
sub alien_refresh_manual_pkgconfig {
my $self = shift;
my ($dir) = @_;
my $pc_objects = $self->config_data( 'pkgconfig' );
$pc_objects->{_manual} = $self->alien_generate_manual_pkgconfig($dir)
or croak "Could not autogenerate pkgconfig information";
$self->config_data( pkgconfig => $pc_objects );
( run in 1.179 second using v1.01-cache-2.11-cpan-97f6503c9c8 )