line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# App::hopen::Gen::Ninja::AssetGraphNode - AssetOp for Gen::Ninja |
2
|
|
|
|
|
|
|
package App::hopen::Gen::Ninja::AssetGraphNode; |
3
|
1
|
|
|
1
|
|
8
|
use Data::Hopen qw(getparameters $VERBOSE); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
88
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
6
|
use Data::Hopen::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000011'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1460
|
use parent 'App::hopen::G::AssetOp'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
use Class::Tiny { |
11
|
0
|
|
|
|
|
0
|
_rules => sub { +{} }, |
12
|
1
|
|
|
1
|
|
92
|
}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
275
|
use App::hopen::BuildSystemGlobals; # for $DestDir |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
106
|
|
15
|
1
|
|
|
1
|
|
7
|
use Quote::Code; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
16
|
1
|
|
|
1
|
|
56
|
use String::Print; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Docs {{{1 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
App::hopen::Gen::Ninja::AssetGraphNode - AssetOp for Gen::Ninja |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
TODO |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 _rules |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
TODO? Store mapping from command lines to rules? Don't want to generate |
33
|
|
|
|
|
|
|
a separate rule for every command if we can help it. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 FUNCTIONS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# }}}1 |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
193
|
use vars::i '&OUTPUT' => sub { '__R_Ninjafile' }; |
|
1
|
|
|
5
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
36
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 _run |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Generate a piece of a Ninja file and write it to the filehandle in |
46
|
|
|
|
|
|
|
C<__R_Ninjafile>. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _run { |
51
|
3
|
|
|
3
|
|
994
|
state $ruleidx=0; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
16
|
my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_); |
54
|
3
|
|
|
|
|
283
|
my $fh = $self->scope->find(OUTPUT); |
55
|
|
|
|
|
|
|
# TODO deal with multiple inputs being merged in DAG::_run() |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
3121
|
my @inputs = $self->input_assets; |
58
|
3
|
|
|
|
|
20
|
my $output = $self->asset->target->path_wrt($DestDir); |
59
|
|
|
|
|
|
|
# TODO refactor this processing into a utility module/function |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Debugging output |
62
|
3
|
50
|
|
|
|
1075
|
if($VERBOSE) { |
63
|
0
|
|
|
|
|
0
|
print $fh qc'\n# From node {$self->name}:\n'; |
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
0
|
|
|
0
|
print $fh qc' # {$self->how//"<nothing to be done>"}\n'; |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
|
|
0
|
print $fh qc' # Depends on {$_->target}\n' foreach @inputs; |
|
0
|
|
|
|
|
0
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
3
|
100
|
|
|
|
76
|
if(defined $self->how) { |
69
|
2
|
|
|
|
|
16
|
my @paths = map { $_->target->path_wrt($DestDir) } @inputs; |
|
2
|
|
|
|
|
16
|
|
70
|
2
|
|
|
|
|
715
|
my $recipe = $self->how; |
71
|
|
|
|
|
|
|
# TODO refactor this processing into a utility module/function |
72
|
2
|
100
|
|
|
|
91
|
warn "I don't yet support #first very well (in ``$recipe'')" if $recipe =~ /#first/; |
73
|
2
|
|
|
|
|
14
|
$recipe =~ s<#first\b><\$in>g; # first input # TODO FIXME |
74
|
2
|
|
|
|
|
8
|
$recipe =~ s<#all\b><\$in>g; # all inputs |
75
|
2
|
|
|
|
|
9
|
$recipe =~ s<#out\b><\$out>g; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# TODO FIXME ugly hack: for now, each command gets its own rule. |
78
|
2
|
|
|
|
|
8
|
my $rulename = 'rule_' . ++$ruleidx; |
79
|
2
|
|
|
|
|
6
|
print $fh qc_to <<"EOT" |
80
|
2
|
|
|
|
|
6
|
rule #{$rulename} |
81
|
|
|
|
|
|
|
command = #{$recipe} |
82
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
8
|
|
83
|
|
|
|
|
|
|
build #{$output}: #{$rulename} #{join(" ", @paths)} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
EOT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
3
|
|
|
|
|
64
|
$self->make($self->asset); |
90
|
3
|
|
|
|
|
17
|
return {}; |
91
|
|
|
|
|
|
|
} #_run() |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
__END__ |
95
|
|
|
|
|
|
|
# vi: set fdm=marker: # |