| 1 | # Data::Hopen::G::Goal - A named build goal | ||||||||||
| 2 | package Data::Hopen::G::Goal; | ||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 9 | ▶ | use Data::Hopen::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 9 | our $VERSION = '0.000018'; | |||||||||
| 7 | |||||||||||
| 8 | 9 | ▶ | use parent 'Data::Hopen::G::Op'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | use Class::Tiny { | ||||||||||
| 10 | 9 | should_output => true, # if true, forward the goal's inputs as | |||||||||
| 11 | # its outputs. | ||||||||||
| 12 | 9 | ▶ | }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 9 | ▶ | use Data::Hopen; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 9 | ▶ | use Data::Hopen::Util::Data qw(forward_opts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | # Docs {{{1 | ||||||||||
| 18 | |||||||||||
| 19 | =head1 NAME | ||||||||||
| 20 | |||||||||||
| 21 | Data::Hopen::G::Goal - a named goal in a hopen build | ||||||||||
| 22 | |||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||
| 24 | |||||||||||
| 25 | A C<Goal> is a named build target, e.g., C<doc> or C<dist>. The name C<all> | ||||||||||
| 26 | is reserved for the root goal. Goals usually appear at the end of the build | ||||||||||
| 27 | graph, but this is not required --- Goal nodes can appear anywhere in the | ||||||||||
| 28 | graph. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 MEMBERS | ||||||||||
| 31 | |||||||||||
| 32 | =head2 should_output | ||||||||||
| 33 | |||||||||||
| 34 | Boolean, default true. If false, the goal's outputs are always C<{}> (empty). | ||||||||||
| 35 | If true, the goal's inputs are passed through as outputs. | ||||||||||
| 36 | |||||||||||
| 37 | =head1 FUNCTIONS | ||||||||||
| 38 | |||||||||||
| 39 | =head2 run | ||||||||||
| 40 | |||||||||||
| 41 | Passes through the inputs if L</should_output> is set. | ||||||||||
| 42 | |||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | # }}}1 | ||||||||||
| 46 | |||||||||||
| 47 | sub _run { | ||||||||||
| 48 | 27 | ▶ | my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_); | ||||||||
|
Subroutine
_run: called CC=2 SCAR=6.9
| |||||||||||
| 49 | 20 | ▶ | hlog { Goal => $self->name, ($self->should_output ? 'with' : 'without'), | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 50 | 27 | 'outputs' }; | |||||||||
| 51 | |||||||||||
| 52 | 27 | ▶ | return {} unless $self->should_output; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 25 | return $self->passthrough(-nocontext=>1, -levels => 'local', | |||||||||
| 55 | forward_opts(\%args, {'-'=>1}, qw[phase visitor])); | ||||||||||
| 56 | } #_run() | ||||||||||
| 57 | |||||||||||
| 58 | =head2 BUILD | ||||||||||
| 59 | |||||||||||
| 60 | Enforce the requirement for a user-specified name. | ||||||||||
| 61 | |||||||||||
| 62 | =cut | ||||||||||
| 63 | |||||||||||
| 64 | sub BUILD { | ||||||||||
| 65 | 17 | ▶ | my ($self, $args) = @_; | ||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 66 | 17 | ▶ | croak 'Goals must have names' unless $args->{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | } #BUILD() | ||||||||||
| 68 | |||||||||||
| 69 | 9 | 1; | |||||||||
| 70 | __END__ | ||||||||||