Verby::Action::Make - Action to run make(1).


Verby documentation Contained in the Verby distribution.

Index


Code Index:

NAME

Top

Verby::Action::Make - Action to run make(1).

SYNOPSIS

Top

	use Verby::Action::Make;

DESCRIPTION

Top

METHODS

Top

do

Run the make command with the specified parameters and fields.

log_extra

Used by the Run role to provide better log messages.

finished

Called by the Run role when the job has finished,

PARAMETERS

Top

target
targets

The make targets to run, like e.g. test.

Optional.

workdir

The directory in which the makefile should be found. This is passed as the -C option to make.

makefile

If defined, passed as the -f option to make.

FIELDS

Top

make_path

The name of the command to run. Defaults to make, but can be overridden to use e.g. gmake, or something not in $PATH.

num_jobs

The -j flag to make. Defaults to 1.

silent

Whether or not to pass the -s option to make. Defaults to true.

BUGS

Top

None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.

CODE COVERAGE

Top

We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.

SEE ALSO

Top

AUTHOR

Top

Yuval Kogman, <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


Verby documentation Contained in the Verby distribution.

#!/usr/bin/perl

package Verby::Action::Make;
use Moose;

with qw(Verby::Action::Run::Unconditional);

our $VERSION = "0.05";

has make_path => (
	isa => "Str",
	is  => "rw",
	default => "make",
);

has num_jobs => (
	isa => "Int",
	is  => "rw",
	default => 1,
);

has silent => (
	isa => "Bool",
	is  => "rw",
	default => 1,
);

sub do {
	my ( $self, $c ) = @_;

	my $wd       = $c->workdir;
	my $makefile = $c->makefile;
	my @targets  = (($c->target || ()), @{ $c->targets || [] });

	my $num_jobs = $self->num_jobs;
	my $silent   = $self->silent;

	$c->is_make_test(1) if "@targets" eq "test";

	my @cli = (
		$self->make_path,
		"-j$num_jobs",
		( $silent ? "-s" : () ),
		( defined($makefile) ? ( "-f" => $makefile ) : () ),
		"-C" => $wd,
		@targets,
	);

	$self->create_poe_session(
		c   => $c,
		cli => \@cli,
	);
}

sub finished {
	my ( $self, $c ) = @_;

	my $out = $c->stdout;
	chomp($out);
	$c->logger->info("test output:\n$out") if $c->is_make_test;

	$self->confirm($c);
}

around exit_code_is_ok => sub {
	my $next = shift;
	my ( $self, $c ) = @_;
	
	if ( $c->is_make_test and $c->allow_test_failurei ) {
		# GNU make exits with '2' on any error in a subtool
		# this is not perfect, but it's something
		$c->program_exit == 2 || $self->$next($c);
	} else {
		$self->$next($c);
	}
};

sub log_extra {
	my ( $self, $c ) = @_;
	" in " . $c->workdir;
}

__PACKAGE__

__END__