Alien-Build
view release on metacpan or search on metacpan
lib/alienfile.pm view on Meta::CPAN
fetch => { share => 'fetch' },
decode => { share => 'fetch' },
prefer => { share => 'prefer' },
extract => { share => 'extract' },
patch => { share => 'patch$' },
build => { share => 'build$' },
test => { share => 'test$' },
# Note: below special case gather_ffi for the ffi block :P
gather => { share => 'gather_share', system => 'gather_system', any => 'gather_share,gather_system' },
);
sub _add_modifier
{
my($type, $stage, $sub) = @_;
my $method = "${type}_hook";
Carp::croak "No such stage $stage" unless defined $modifiers{$stage};
Carp::croak "$type $stage argument must be a code reference" unless defined $sub && ref($sub) eq 'CODE';
my $caller = caller;
my $meta = $caller->meta;
Carp::croak "$type $stage is not allowed in sys block" unless defined $modifiers{$stage}->{$meta->{phase}};
$meta->add_requires('configure' => 'Alien::Build' => '1.40');
my $suffix = $meta->{build_suffix};
if($suffix eq '_ffi' && $stage eq 'gather')
{
$meta->$method('gather_ffi' => $sub);
}
foreach my $hook (
map { split /,/, $_ } # split on , for when multiple hooks must be attached (gather in any)
map { my $x = $_ ; $x =~ s/\$/$suffix/; $x } # substitute $ at the end for a suffix (_ffi) if any
$modifiers{$stage}->{$meta->{phase}}) # get the list of modifiers
{
$meta->$method($hook => $sub);
}
return;
}
sub before
{
my($stage, $sub) = @_;
@_ = ('before', @_);
goto &alienfile::_add_modifier;
}
sub after
{
my($stage, $sub) = @_;
@_ = ('after', @_);
goto &alienfile::_add_modifier;
}
sub import
{
strict->import;
warnings->import;
goto &Exporter::import;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
alienfile - Specification for defining an external dependency for CPAN
=head1 VERSION
version 2.84
=head1 SYNOPSIS
Do-it-yourself approach:
use alienfile;
probe [ 'pkg-config --exists libarchive' ];
share {
start_url 'http://libarchive.org/downloads/libarchive-3.2.2.tar.gz';
# the first one which succeeds will be used
download [ 'wget %{.meta.start_url}' ];
download [ 'curl -o %{.meta.start_url}' ];
extract [ 'tar xf %{.install.download}' ];
build [
# Note: will not work on Windows, better to use Build::Autoconf plugin
# if you need windows support
'./configure --prefix=%{.install.prefix} --disable-shared',
'%{make}',
'%{make} install',
];
}
gather [
[ 'pkg-config', '--modversion', 'libarchive', \'%{.runtime.version}' ],
[ 'pkg-config', '--cflags', 'libarchive', \'%{.runtime.cflags}' ],
[ 'pkg-config', '--libs', 'libarchive', \'%{.runtime.libs}' ],
];
With plugins (better):
use alienfile;
plugin 'PkgConfig' => 'libarchive';
share {
( run in 0.298 second using v1.01-cache-2.11-cpan-e93a5daba3e )