Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Base.pm view on Meta::CPAN
{
foreach my $key (keys %{ $runtime_prop->{alt}->{$name} })
{
$runtime_prop->{$key} = $runtime_prop->{alt}->{$name}->{$key};
}
}
else
{
Carp::croak("no such alt: $name");
}
$new->{_alt} = {
runtime_prop => $runtime_prop,
orig => $orig,
};
$new;
}
sub alt_names
{
my($class) = @_;
my $alts = $class->runtime_prop->{alt};
defined $alts
? sort keys %$alts
: ();
}
sub alt_exists
{
my($class, $alt_name) = @_;
my $alts = $class->runtime_prop->{alt};
defined $alts
? exists $alts->{$alt_name} && defined $alts->{$alt_name}
: 0;
}
1;
=pod
=encoding UTF-8
=head1 NAME
Alien::Base - Base classes for Alien:: modules
=head1 VERSION
version 2.84
=head1 SYNOPSIS
package Alien::MyLibrary;
use strict;
use warnings;
use parent 'Alien::Base';
1;
(for details on the C<Makefile.PL> or C<Build.PL> and L<alienfile>
that should be bundled with your L<Alien::Base> subclass, please see
L<Alien::Build::Manual::AlienAuthor>).
Then a C<MyLibrary::XS> can use C<Alien::MyLibrary> in its C<Makefile.PL>:
use Alien::MyLibrary
use ExtUtils::MakeMaker;
use Alien::Base::Wrapper qw( Alien::MyLibrary !export );
use Config;
WriteMakefile(
...
Alien::Base::Wrapper->mm_args,
...
);
Or if you prefer L<Module::Build>, in its C<Build.PL>:
use Alien::MyLibrary;
use Module::Build 0.28; # need at least 0.28
use Alien::Base::Wrapper qw( Alien::MyLibrary !export );
my $builder = Module::Build->new(
...
Alien::Base::Wrapper->mb_args,
...
);
$builder->create_build_script;
Or if you are using L<ExtUtils::Depends>:
use ExtUtils::MakeMaker;
use ExtUtils::Depends;
my $eud = ExtUtils::Depends->new(qw( MyLibrary::XS Alien::MyLibrary ));
WriteMakefile(
...
$eud->get_makefile_vars
);
If you are using L<Alien::Base::ModuleBuild> instead of the recommended L<Alien::Build>
and L<alienfile>, then in your C<MyLibrary::XS> module, you may need something like
this in your main C<.pm> file IF your library uses dynamic libraries:
package MyLibrary::XS;
use Alien::MyLibrary; # may only be needed if you are using Alien::Base::ModuleBuild
...
Or you can use it from an FFI module:
package MyLibrary::FFI;
use Alien::MyLibrary;
use FFI::Platypus;
lib/Alien/Base.pm view on Meta::CPAN
);
share {
...
plugin 'Extract' => 'tar.gz';
plugin 'Build::MSYS';
build [
'sh configure --prefix=%{alien.install.prefix}',
'%{gmake}',
'%{gmake} install',
];
};
...
=head2 inline_auto_include
my(@headers) = Alien::MyLibrary->inline_auto_include;
List of header files to automatically include in inline C and C++
code when using L<Inline::C> or L<Inline::CPP>. This is provided
as a public interface primarily so that it can be overridden at run
time. This can also be specified in your C<Build.PL> with
L<Alien::Base::ModuleBuild> using the C<alien_inline_auto_include>
property.
=head2 runtime_prop
my $hashref = Alien::MyLibrary->runtime_prop;
Returns a hash reference of the runtime properties computed by L<Alien::Build> during its
install process. If the L<Alien::Base> based L<Alien> was not built using L<Alien::Build>,
then this will return undef.
=head2 alt
my $new_alien = Alien::MyLibrary->alt($alt_name);
my $new_alien = $old_alien->alt($alt_name);
Returns an L<Alien::Base> instance with the alternate configuration.
Some packages come with multiple libraries, and multiple C<.pc> files to
use with them. This method can be used with C<pkg-config> plugins to
access different configurations. (It could also be used with non-pkg-config
based packages too, though there are not as of this writing any build
time plugins that take advantage of this feature).
From your L<alienfile>
use alienfile;
plugin 'PkgConfig' => (
pkg_name => [ 'libfoo', 'libbar', ],
);
Then in your base class works like normal:
package Alien::MyLibrary;
use parent qw( Alien::Base );
1;
Then you can use it:
use Alien::MyLibrary;
my $cflags = Alien::MyLibrary->alt('foo1')->cflags;
my $libs = Alien::MyLibrary->alt('foo1')->libs;
=head2 alt_names
my @alt_names = Alien::MyLibrary->alt_names
Returns the list of all available alternative configuration names.
=head2 alt_exists
my $bool = Alien::MyLibrary->alt_exists($alt_name)
Returns true if the given alternative configuration exists.
=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
( run in 1.372 second using v1.01-cache-2.11-cpan-524268b4103 )