Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Base.pm view on Meta::CPAN
my $self = shift;
my $type = $self->config('install_type');
return @_ ? $type eq $_[0] : $type;
}
sub is_system_install
{
my($self) = @_;
$self->install_type('system');
}
sub is_share_install
{
my($self) = @_;
$self->install_type('share');
}
sub _pkgconfig_keyword {
my $self = shift;
my $keyword = shift;
my $static = shift;
# use pkg-config if installed system-wide
if ($self->install_type('system')) {
my $name = $self->config('name');
require Alien::Base::PkgConfig;
my $command = Alien::Base::PkgConfig->pkg_config_command . " @{[ $static ? '--static' : '' ]} --\L$keyword\E $name";
$! = 0;
chomp ( my $pcdata = capture_stdout { system( $command ) } );
# if pkg-config fails for whatever reason, then we try to
# fallback on alien_provides_*
$pcdata = '' if $! || $?;
$pcdata =~ s/\s*$//;
if($self->config('system_provides')) {
if(my $system_provides = $self->config('system_provides')->{$keyword}) {
$pcdata = length $pcdata ? "$pcdata $system_provides" : $system_provides;
}
}
return $pcdata;
}
# use parsed info from build .pc file
my $dist_dir = $self->dist_dir;
my @pc = $self->_pkgconfig(@_);
my @strings =
grep defined,
map { $_->keyword($keyword,
#{ pcfiledir => $dist_dir }
) }
@pc;
if(defined $self->config('original_prefix') && $self->config('original_prefix') ne $self->dist_dir)
{
my $dist_dir = $self->dist_dir;
$dist_dir =~ s{\\}{/}g if $^O eq 'MSWin32';
my $old = quotemeta $self->config('original_prefix');
@strings = map {
my $flag = $_;
$flag =~ s{^(-I|-L|-LIBPATH:)?($old)}{$1.$dist_dir}e;
$flag =~ s/(\s)/\\$1/g;
$flag;
} map { $self->split_flags($_) } @strings;
}
return join( ' ', @strings );
}
sub _pkgconfig {
my $self = shift;
my %all = %{ $self->config('pkgconfig') };
# merge in found pc files
require File::Find;
my $wanted = sub {
return if ( -d or not /\.pc$/ );
require Alien::Base::PkgConfig;
my $pkg = Alien::Base::PkgConfig->new($_);
$all{$pkg->{package}} = $pkg;
};
File::Find::find( $wanted, $self->dist_dir );
croak "No Alien::Base::PkgConfig objects are stored!"
unless keys %all;
# Run through all pkgconfig objects and ensure that their modules are loaded:
for my $pkg_obj (values %all) {
my $perl_module_name = blessed $pkg_obj;
my $pm = "$perl_module_name.pm";
$pm =~ s/::/\//g;
eval { require $pm };
}
return @all{@_} if @_;
my $manual = delete $all{_manual};
if (keys %all) {
return values %all;
} else {
return $manual;
}
}
# helper method to call Alien::MyLib::ConfigData->config(@_)
sub config {
my $class = shift;
$class = blessed $class || $class;
if(my $ab_config = $class->runtime_prop)
{
my $key = shift;
return $ab_config->{legacy}->{$key};
}
my $config = $class . '::ConfigData';
lib/Alien/Base.pm view on Meta::CPAN
=head1 SUPPORT AND CONTRIBUTING
First check the L<Alien::Build::Manual::FAQ> for questions that have already been answered.
IRC: #native on irc.perl.org
L<(click for instant chatroom login)|http://chat.mibbit.com/#native@irc.perl.org>
If you find a bug, please report it on the projects issue tracker on GitHub:
=over 4
=item L<https://github.com/PerlAlien/Alien-Build/issues>
=back
Development is discussed on the projects google groups. This is also
a reasonable place to post a question if you don't want to open an issue
in GitHub.
=over 4
=item L<https://groups.google.com/forum/#!forum/perl5-alien>
=back
If you have implemented a new feature or fixed a bug, please open a pull
request.
=over 4
=item L<https://github.com/PerlAlien/Alien-Build/pulls>
=back
=head1 SEE ALSO
=over
=item *
L<Alien::Build>
=item *
L<alienfile>
=item *
L<Alien>
=item *
L<Alien::Build::Manual::FAQ>
=back
=head1 THANKS
C<Alien::Base> was originally written by Joel Berger, and that
code is still Copyright (C) 2012-2017 Joel Berger. It has the
same license as the rest of the L<Alien::Build>.
Special thanks for the early development of C<Alien::Base> go to:
=over
=item Christian Walde (Mithaldu)
For productive conversations about component interoperability.
=item kmx
For writing Alien::Tidyp from which I drew many of my initial ideas.
=item David Mertens (run4flat)
For productive conversations about implementation.
=item Mark Nunberg (mordy, mnunberg)
For graciously teaching me about rpath and dynamic loading,
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (å康æ°, gugod)
( run in 0.541 second using v1.01-cache-2.11-cpan-5b529ec07f3 )