Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
}
$self->do_system( ref($command) ? @$command : $command );
}
# alias for backwards compatibility
*_env_do_system = \&alien_do_system;
sub alien_check_built_version {
return;
}
sub alien_do_commands {
my $self = shift;
my $phase = shift;
my $attr = "alien_${phase}_commands";
my $commands = $self->$attr();
print "\n+ cd $CWD\n";
foreach my $command (@$commands) {
my %result = $self->alien_do_system( $command );
unless ($result{success}) {
carp "External command ($result{command}) failed! Error: $?\n";
return 0;
}
}
return 1;
}
# wrapper for M::B::do_system which interpolates alien_ vars first
# futher it either captures or tees depending on the value of $Verbose
sub do_system {
my $self = shift;
my $opts = ref $_[-1] ? pop : { verbose => 1 };
my $verbose = $Verbose || $opts->{verbose};
# prevent build process from cwd-ing from underneath us
local $CWD;
my $initial_cwd = $CWD;
my @args = map { $self->alien_interpolate($_) } @_;
print "+ @args\n";
my $old_super_verbose = $self->verbose;
$self->verbose(0);
my ($out, $err, $success) =
$verbose
? tee { $self->SUPER::do_system(@args) }
: capture { $self->SUPER::do_system(@args) }
;
$self->verbose($old_super_verbose);
my %return = (
stdout => $out,
stderr => $err,
success => $success,
command => join(' ', @args),
);
# 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;
}
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
[version 0.006]
my $version = $amb->alien_check_built_version;
This function determines the version of the library after it has been
built from source. This function only gets called if the operating
system version can not be found and the package is successfully built.
The version is returned on success. If the version can't be detected
then it should return empty list. Note that failing to detect a version
is considered a failure and the corresponding C<./Build> action will
fail!
Any string is valid as a version as far as L<Alien::Base> is concerned.
The most useful value would be a number or dotted decimal that most
software developers recognize and that software tools can differentiate.
In some cases packages will not have a clear version number, in which
case the string C<unknown> would be a reasonable choice.
The default implementation relies on C<pkg-config>, and other heuristics,
but you will probably want to override this with your own implementation
if the package you are building does not use C<pkg-config>.
When this method is called, the current working directory will be the
build root.
If you see an error message like this:
Library looks like it installed, but no version was determined
After the package is built from source code then you probably need to
provide an implementation for this method.
=head2 alien_extract_archive
[version 0.024]
my $dir = $amb->alien_extract_archive($filename);
This function unpacks the given archive and returns the directory
containing the unpacked files.
The default implementation relies on L<Archive::Extract> that is able
to handle most common formats. In order to handle other formats or
archives requiring some special treatment you may want to override
this method.
=head2 alien_do_system
[version 0.024]
my %result = $amb->alien_do_system($cmd)
Similar to
L<Module::Build's do_system|Module::Build::API/"do_system($cmd, @args)">,
also sets the path and several environment variables in accordance
to the object configuration (i.e. C<alien_bin_requires>) and
performs the interpolation of the patterns described in
L<Alien::Base::ModuleBuild::API/"COMMAND INTERPOLATION">.
Returns a set of key value pairs including C<stdout>, C<stderr>,
C<success> and C<command>.
=head2 alien_do_commands
$amb->alien_do_commands($phase);
Executes the commands for the given phase.
=head2 alien_interpolate
my $string = $amb->alien_interpolate($string);
Takes the input string and interpolates the results.
=head2 alien_install_network
[version 1.16]
my $bool = $amb->alien_install_network;
Returns true if downloading source from the internet is allowed. This
is true unless C<ALIEN_INSTALL_NETWORK> is defined and false.
=head2 alien_download_rule
[version 1.16]
my $rule = $amb->alien_download_rule;
This will return one of C<warn>, C<digest>, C<encrypt>, C<digest_or_encrypt>
or C<digest_and_encrypt>. This is based on the C<ALIEN_DOWNLOAD_RULE>
environment variable.
=head1 GUIDE TO DOCUMENTATION
The documentation for C<Module::Build> is broken up into sections:
=over
=item General Usage (L<Module::Build>)
This is the landing document for L<Alien::Base::ModuleBuild>'s parent class.
It describes basic usage and background information.
Its main purpose is to assist the user who wants to learn how to invoke
and control C<Module::Build> scripts at the command line.
It also lists the extra documentation for its use. Users and authors of Alien::
modules should familiarize themselves with these documents. L<Module::Build::API>
is of particular importance to authors.
=item Alien-Specific Usage (L<Alien::Base::ModuleBuild>)
This is the document you are currently reading.
=item Authoring Reference (L<Alien::Base::Authoring>)
This document describes the structure and organization of
C<Alien::Base> based projects, beyond that contained in
C<Module::Build::Authoring>, and the relevant concepts needed by authors who are
writing F<Build.PL> scripts for a distribution or controlling
( run in 0.586 second using v1.01-cache-2.11-cpan-fa01517f264 )