line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Build::Simple; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Build::Simple::VERSION = '0.002'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
57409
|
use Moo; |
|
1
|
|
|
|
|
20851
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
2358
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
68
|
|
9
|
1
|
|
|
1
|
|
5
|
use File::Path; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
524
|
use Build::Simple::Node; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
954
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has _nodes => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
default => sub { {} }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _get_node { |
19
|
59
|
|
|
59
|
|
80
|
my ($self, $key) = @_; |
20
|
59
|
|
|
|
|
233
|
return $self->_nodes->{$key}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub has_node { |
24
|
0
|
|
|
0
|
1
|
0
|
my ($self, $key) = @_; |
25
|
0
|
|
|
|
|
0
|
return exists $self->_nodes->{$key}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub add_file { |
29
|
2
|
|
|
2
|
1
|
32
|
my ($self, $name, %args) = @_; |
30
|
2
|
50
|
33
|
|
|
14
|
Carp::croak("File '$name' already exists in database") if !$args{override} && $self->_get_node($name); |
31
|
2
|
|
|
|
|
36
|
my $node = Build::Simple::Node->new(%args, phony => 0); |
32
|
2
|
|
|
|
|
16
|
$self->_nodes->{$name} = $node; |
33
|
2
|
|
|
|
|
3
|
push @{ $self->_get_node($_)->dependencies }, $name for @{ $args{dependents} }; |
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
34
|
2
|
|
|
|
|
8
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub add_phony { |
38
|
5
|
|
|
5
|
1
|
30
|
my ($self, $name, %args) = @_; |
39
|
5
|
50
|
33
|
|
|
25
|
Carp::croak("Phony '$name' already exists in database") if !$args{override} && $self->_get_node($name); |
40
|
5
|
|
|
|
|
120
|
my $node = Build::Simple::Node->new(%args, phony => 1); |
41
|
5
|
|
|
|
|
31
|
$self->_nodes->{$name} = $node; |
42
|
5
|
|
|
|
|
7
|
push @{ $self->_get_node($_)->dependencies }, $name for @{ $args{dependents} }; |
|
5
|
|
|
|
|
14
|
|
|
0
|
|
|
|
|
0
|
|
43
|
5
|
|
|
|
|
16
|
return; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _node_sorter { |
47
|
59
|
|
|
59
|
|
95
|
my ($self, $current, $callback, $seen, $loop) = @_; |
48
|
59
|
100
|
|
|
|
329
|
Carp::croak("$current has a circular dependency, aborting!\n") if exists $loop->{$current}; |
49
|
58
|
100
|
|
|
|
203
|
return if $seen->{$current}++; |
50
|
45
|
50
|
|
|
|
75
|
my $node = $self->_get_node($current) or Carp::croak("Node $current doesn't exist"); |
51
|
45
|
|
|
|
|
117
|
local $loop->{$current} = 1; |
52
|
45
|
|
|
|
|
52
|
$self->_node_sorter($_, $callback, $seen, $loop) for @{ $node->dependencies }; |
|
45
|
|
|
|
|
160
|
|
53
|
43
|
|
|
|
|
89
|
$callback->($current, $node); |
54
|
43
|
|
|
|
|
164
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _sort_nodes { |
58
|
1
|
|
|
1
|
|
6
|
my ($self, $startpoint) = @_; |
59
|
1
|
|
|
|
|
2
|
my @ret; |
60
|
1
|
|
|
3
|
|
9
|
$self->_node_sorter($startpoint, sub { push @ret, $_[0] }, {}, {}); |
|
3
|
|
|
|
|
5
|
|
61
|
1
|
|
|
|
|
7
|
return @ret; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _is_phony { |
65
|
7
|
|
|
7
|
|
12
|
my ($self, $key) = @_; |
66
|
7
|
|
|
|
|
15
|
my $node = $self->_get_node($key); |
67
|
7
|
50
|
|
|
|
47
|
return $node ? $node->phony : 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub run { |
71
|
13
|
|
|
13
|
1
|
1011311
|
my ($self, $startpoint, %options) = @_; |
72
|
13
|
|
|
40
|
|
70
|
$self->_node_sorter($startpoint, sub { $_[1]->run($_[0], $self, \%options) }, {}, {}); |
|
40
|
|
|
|
|
141
|
|
73
|
12
|
|
|
|
|
63
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#ABSTRACT: A minimalistic dependency system |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |