File Coverage

blib/lib/App/hopen/Gen/MSBuild/AssetGraphNode.pm
Criterion Covered Total %
statement 53 60 88.3
branch 6 6 100.0
condition 5 9 55.5
subroutine 11 14 78.5
pod n/a
total 75 89 84.2


line stmt bran cond sub pod time code
1             # App::hopen::Gen::MSBuild::AssetGraphNode - AssetOp for Gen::MSBuild
2             package App::hopen::Gen::MSBuild::AssetGraphNode;
3 1     1   8 use Data::Hopen qw(hlog getparameters *VERBOSE);
  1         3  
  1         94  
4 1     1   6 use strict; use warnings;
  1     1   5  
  1         18  
  1         6  
  1         7  
  1         25  
5 1     1   5 use Data::Hopen::Base;
  1         3  
  1         8  
6              
7             our $VERSION = '0.000013'; # TRIAL
8              
9 1     1   1508 use parent 'App::hopen::G::AssetOp';
  1         2  
  1         7  
10 1     1   75 use Class::Tiny;
  1         2  
  1         10  
11              
12 1     1   52 use App::hopen::BuildSystemGlobals; # for $DestDir
  1         3  
  1         113  
13 1     1   9 use Quote::Code;
  1         8  
  1         6  
14 1     1   53 use String::Print;
  1         2  
  1         10  
15              
16             # Docs {{{1
17              
18             =head1 NAME
19              
20             App::hopen::Gen::MSBuild::AssetGraphNode - AssetOp for Gen::MSBuild
21              
22             =head1 SYNOPSIS
23              
24             TODO
25              
26             =head1 FUNCTIONS
27              
28             =cut
29              
30             # }}}1
31              
32 1     1   178 use vars::i '*OUTPUT' => eval "\\'__R_MSBuildXML'";
  1         4  
  1         96  
33              
34             =head2 _run
35              
36             Add to the XML hashref being built up in C<__R_MSBuildXML>.
37              
38             If the `how` of a node is defined but falsy, it's a goal.
39             If `how` is defined and truthy, it's a file.
40              
41             =cut
42              
43             sub _run {
44 4     4   1126 my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
45 4         260 my $lrXML = $self->scope->find($OUTPUT);
46             # TODO deal with multiple inputs being merged in DAG::_run()
47              
48 4         3154 my @inputs = $self->input_assets;
49 4         20 my $output = $self->asset->target;
50 4 100       7 $output = $output->path_wrt($DestDir) if eval { $output->DOES('App::hopen::Util::BasedPath') };
  4         36  
51             # TODO refactor this processing into a utility module/function
52              
53             # Debugging output
54             hlog {;
55 0         0 qc'Project piece from node {$self->name}',
56 0   0     0 qc'{$self->how//"<nothing to be done>"}',
57 0     0   0 map { qc'Depends on {$_->target}' } @inputs,
  0         0  
  0         0  
58 4         1064 };
59              
60 4 100 100     114 if(defined $self->how && !$self->how) { # goal = MSBuild <Target>
    100          
61 1     0   33 hlog { Goal => $output };
  0         0  
62 1         10 $lrXML = [ Target => { Name => $output },
63             $lrXML ];
64              
65             } elsif(defined $self->how) { # file = MSBuild task
66 2     0   95 hlog { File => $output };
  0         0  
67 2         15 my @paths = map { $_->target->path_wrt($DestDir) } @inputs;
  2         8  
68 2         672 my $recipe = $self->how;
69              
70             # TODO refactor this processing into a utility module/function
71 2   50     18 $recipe =~ s<#first\b><$paths[0] // ''>ge; # first input
  1         16  
72 2         63 $recipe =~ s<#all\b><join(' ', @paths)>ge; # all inputs
  1         5  
73 2   50     18 $recipe =~ s<#out\b><$output // ''>ge;
  2         8  
74              
75 2         29 $lrXML = [ TODO => { Name => $output },
76             $lrXML ];
77             }
78              
79 4         46 $self->make($self->asset);
80 4         17 return {$OUTPUT=>$lrXML};
81             } #_run()
82              
83             1;
84             __END__
85             # vi: set fdm=marker: #