File Coverage

blib/lib/App/hopen/Gen/Make/AssetGraphNode.pm
Criterion Covered Total %
statement 52 58 89.6
branch 3 4 75.0
condition 2 6 33.3
subroutine 12 12 100.0
pod n/a
total 69 80 86.2


line stmt bran cond sub pod time code
1             # App::hopen::Gen::Make::AssetGraphNode - AssetOp for Gen::Make
2             package App::hopen::Gen::Make::AssetGraphNode;
3 1     1   8 use Data::Hopen qw(getparameters $VERBOSE);
  1         2  
  1         97  
4 1     1   7 use strict; use warnings;
  1     1   3  
  1         20  
  1         4  
  1         3  
  1         42  
5 1     1   7 use Data::Hopen::Base;
  1         2  
  1         7  
6              
7             our $VERSION = '0.000012'; # TRIAL
8              
9 1     1   1333 use parent 'App::hopen::G::AssetOp';
  1         3  
  1         5  
10 1     1   48 use Class::Tiny;
  1         3  
  1         4  
11              
12 1     1   34 use App::hopen::BuildSystemGlobals; # for $DestDir
  1         1  
  1         105  
13 1     1   6 use Quote::Code;
  1         2  
  1         5  
14 1     1   565 use String::Print;
  1         52019  
  1         7  
15              
16             # Docs {{{1
17              
18             =head1 NAME
19              
20             App::hopen::Gen::Make::AssetGraphNode - AssetOp for Gen::Make
21              
22             =head1 SYNOPSIS
23              
24             TODO
25              
26             =head1 FUNCTIONS
27              
28             =cut
29              
30             # }}}1
31              
32 1     1   185 use vars::i '&OUTPUT' => sub { '__R_Makefile' };
  1     5   4  
  1         11  
  5         34  
33              
34             =head2 _run
35              
36             Generate a piece of a Makefile and write it to the filehandle in
37             C<__R_Makefile>.
38              
39             =cut
40              
41             sub _run {
42 3     3   1033 my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
43 3         283 my $fh = $self->scope->find(OUTPUT);
44             # TODO deal with multiple inputs being merged in DAG::_run()
45              
46 3         2982 my @inputs = $self->input_assets;
47 3         21 my $output = $self->asset->target->path_wrt($DestDir);
48             # TODO refactor this processing into a utility module/function
49              
50             # Debugging output
51 3 50       1084 if($VERBOSE) {
52 0         0 print $fh qc'\n# Makefile piece from node {$self->name}\n';
  0         0  
53 0   0     0 print $fh qc' # {$self->how//"<nothing to be done>"}\n';
  0         0  
54 0         0 print $fh qc' # Depends on {$_->target}\n' foreach @inputs;
  0         0  
55             }
56              
57 3 100       75 if(defined $self->how) {
58 2         17 my @paths = map { $_->target->path_wrt($DestDir) } @inputs;
  2         9  
59 2         743 my $recipe = $self->how;
60             # TODO refactor this processing into a utility module/function
61 2   50     21 $recipe =~ s<#first\b><$paths[0] // ''>ge; # first input
  1         7  
62 2         47 $recipe =~ s<#all\b><join(' ', @paths)>ge; # all inputs
  1         6  
63 2   50     15 $recipe =~ s<#out\b><$output // ''>ge;
  2         7  
64 2         7 print $fh qc_to <<"EOT"
  2         14  
65 2         21 #{$output}: #{join(" ", @paths)}
  2         42  
66             \t#{$recipe}
67             EOT
68              
69             }
70              
71 3         18 $self->make($self->asset);
72 3         17 return {};
73             } #_run()
74              
75             1;
76             __END__
77             # vi: set fdm=marker: #