Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Build/CommandSequence.pm view on Meta::CPAN
package Alien::Build::CommandSequence;
use strict;
use warnings;
use 5.008004;
use Text::ParseWords qw( shellwords );
use Capture::Tiny qw( capture );
# ABSTRACT: Alien::Build command sequence
our $VERSION = '2.84'; # VERSION
sub new
{
my($class, @commands) = @_;
my $self = bless {
commands => \@commands,
}, $class;
$self;
}
sub apply_requirements
{
my($self, $meta, $phase) = @_;
my $intr = $meta->interpolator;
foreach my $command (@{ $self->{commands} })
{
next if ref $command eq 'CODE';
if(ref $command eq 'ARRAY')
{
foreach my $arg (@$command)
{
next if ref $arg eq 'CODE';
$meta->add_requires($phase, $intr->requires($arg))
}
}
else
{
$meta->add_requires($phase, $intr->requires($command));
}
}
$self;
}
my %built_in = (
cd => sub {
my(undef, $dir) = @_;
if(!defined $dir)
{
die "undef passed to cd";
}
elsif(-d $dir)
{
chdir($dir) || die "unable to cd $dir $!";
}
else
{
die "unable to cd $dir, does not exist";
}
},
);
sub _run_list
{
my($build, @cmd) = @_;
$build->log("+ @cmd");
return $built_in{$cmd[0]}->(@cmd) if $built_in{$cmd[0]};
system @cmd;
die "external command failed" if $?;
}
sub _run_string
{
( run in 0.365 second using v1.01-cache-2.11-cpan-9bca49b1385 )