Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Build/Plugin/Build/SearchDep.pm view on Meta::CPAN
}
else
{
@aliens = ref $self->aliens ? @{ $self->aliens } : ($self->aliens);
$meta->add_requires('share' => $_ => 0) for @aliens;
}
$meta->around_hook(
build => sub {
my($orig, $build) = @_;
local $ENV{CFLAGS} = $ENV{CFLAGS};
local $ENV{CXXFLAGS} = $ENV{CXXFLAGS};
local $ENV{LDFLAGS} = $ENV{LDFLAGS};
tie my @CFLAGS, 'Env::ShellWords', 'CFLAGS';
tie my @CXXFLAGS, 'Env::ShellWords', 'CXXFLAGS';
tie my @LDFLAGS, 'Env::ShellWords', 'LDFLAGS';
my $cflags = $build->install_prop->{plugin_build_searchdep_cflags} = [];
my $ldflags = $build->install_prop->{plugin_build_searchdep_ldflags} = [];
my $libs = $build->install_prop->{plugin_build_searchdep_libs} = [];
foreach my $other (@aliens)
{
my $other_cflags;
my $other_libs;
if($other->install_type('share'))
{
$other_cflags = $other->cflags_static;
$other_libs = $other->libs_static;
}
else
{
$other_cflags = $other->cflags;
$other_libs = $other->libs;
}
unshift @$cflags, grep /^-I/, shellwords($other_cflags);
unshift @$ldflags, grep /^-L/, shellwords($other_libs);
unshift @$libs, grep /^-l/, shellwords($other_libs);
}
unshift @CFLAGS, @$cflags;
unshift @CXXFLAGS, @$cflags;
unshift @LDFLAGS, @$ldflags;
$orig->($build);
},
);
$meta->after_hook(
gather_share => sub {
my($build) = @_;
$build->runtime_prop->{libs} = '' unless defined $build->runtime_prop->{libs};
$build->runtime_prop->{libs_static} = '' unless defined $build->runtime_prop->{libs_static};
if($self->public_l)
{
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_libs} })) . ' ' . $build->runtime_prop->{$_}
for qw( libs libs_static );
}
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_ldflags} })) . ' ' . $build->runtime_prop->{$_}
for qw( libs libs_static );
if($self->public_I)
{
$build->runtime_prop->{cflags} = '' unless defined $build->runtime_prop->{cflags};
$build->runtime_prop->{cflags_static} = '' unless defined $build->runtime_prop->{cflags_static};
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_cflags} })) . ' ' . $build->runtime_prop->{$_}
for qw( cflags cflags_static );
}
},
);
}
sub _space_escape
{
map {
my $str = $_;
$str =~ s{(\s)}{\\$1}g;
$str;
} @_;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::SearchDep - Add dependencies to library and header search path
=head1 VERSION
version 2.84
=head1 SYNOPSIS
use alienfile;
plugin 'Build::SearchDep' => (
aliens => [qw( Alien::Foo Alien::Bar )],
);
=head1 DESCRIPTION
This plugin adds the other aliens as prerequisites, and adds their header and library
search path to C<CFLAGS> and C<LDFLAGS> environment variable, so that tools that use
them (like autoconf) can pick them up.
=head1 PROPERTIES
=head2 aliens
Either a list reference or hash reference of the other aliens. If a hash reference
then the keys are the class names and the values are the versions of those classes.
=head2 public_I
Include the C<-I> flags when setting the runtime cflags property.
=head2 public_l
Include the C<-l> flags when setting the runtime libs property.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
( run in 0.742 second using v1.01-cache-2.11-cpan-e1769b4cff6 )