line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Enbld::Config; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
819
|
use strict; |
|
3
|
|
|
|
|
29
|
|
|
3
|
|
|
|
|
71
|
|
4
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
60
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
9
|
use Carp; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
148
|
|
7
|
3
|
|
|
3
|
|
11
|
use Scalar::Util qw/blessed/; |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
1673
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Enbld::Exception; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
48
|
|
|
48
|
0
|
9891
|
my $class = shift; |
13
|
|
|
|
|
|
|
|
14
|
48
|
|
|
|
|
188
|
my $self = { |
15
|
|
|
|
|
|
|
name => undef, |
16
|
|
|
|
|
|
|
enabled => undef, |
17
|
|
|
|
|
|
|
installed => {}, |
18
|
|
|
|
|
|
|
@_, |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
48
|
|
|
|
|
71
|
bless $self, $class; |
22
|
|
|
|
|
|
|
|
23
|
48
|
|
|
|
|
112
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub name { |
27
|
23
|
|
|
23
|
0
|
131
|
return $_[0]->{name}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub installed { |
31
|
4
|
|
|
4
|
0
|
21
|
return $_[0]->{installed}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub condition { |
35
|
36
|
|
|
36
|
0
|
61
|
my ( $self, $version ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
36
|
|
|
|
|
116
|
require Enbld::Condition; |
38
|
|
|
|
|
|
|
|
39
|
36
|
100
|
|
|
|
71
|
if ( ! $version ) { |
40
|
|
|
|
|
|
|
return Enbld::Condition->new( |
41
|
32
|
|
|
|
|
31
|
%{ $self->{installed}{$self->enabled} } |
|
32
|
|
|
|
|
47
|
|
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
4
|
100
|
|
|
|
20
|
if ( exists $self->{installed}{$version} ) { |
46
|
|
|
|
|
|
|
return Enbld::Condition->new( |
47
|
3
|
|
|
|
|
6
|
%{ $self->{installed}{$version} } |
|
3
|
|
|
|
|
23
|
|
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
3
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub is_installed_version { |
55
|
7
|
|
|
7
|
0
|
22
|
my ( $self, $version ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
7
|
100
|
|
|
|
20
|
return unless $version; |
58
|
6
|
100
|
|
|
|
9
|
return unless keys %{ $self->{installed} }; |
|
6
|
|
|
|
|
27
|
|
59
|
|
|
|
|
|
|
|
60
|
5
|
100
|
|
|
|
28
|
return $version if ( exists $self->{installed}{$version} ); |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
8
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub enabled { |
66
|
106
|
|
|
106
|
0
|
815
|
return $_[0]->{enabled}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub drop_enabled { |
70
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
10
|
return ( $self->{enabled} = undef ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub set_enabled { |
76
|
49
|
|
|
49
|
0
|
126
|
my ( $self, $version, $condition ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
49
|
|
|
|
|
114
|
$self->{enabled} = $version; |
79
|
49
|
|
|
|
|
210
|
$self->{installed}{$version} = $condition->serialize; |
80
|
|
|
|
|
|
|
|
81
|
49
|
|
|
|
|
374
|
return $self->{enabled}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub serialize { |
85
|
1
|
|
|
1
|
0
|
1
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
2
|
my $serialized; |
88
|
1
|
|
|
|
|
1
|
foreach my $key ( sort keys %{ $self } ) { |
|
1
|
|
|
|
|
3
|
|
89
|
3
|
|
|
|
|
4
|
$serialized->{$key} = $self->{$key}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
3
|
return $serialized; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub DSL { |
96
|
4
|
|
|
4
|
0
|
11
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
|
|
5
|
my @config; |
99
|
|
|
|
|
|
|
|
100
|
4
|
|
|
|
|
436
|
require Enbld::Feature; |
101
|
4
|
100
|
|
|
|
11
|
my $version = Enbld::Feature->is_current_mode ? |
102
|
|
|
|
|
|
|
$self->enabled : $self->condition->version; |
103
|
|
|
|
|
|
|
|
104
|
4
|
|
|
|
|
9
|
push @config, "target '" . $self->name . "' => define {\n"; |
105
|
4
|
|
|
|
|
7
|
push @config, " version '". $version . "';\n"; |
106
|
4
|
100
|
|
|
|
7
|
if ( $self->condition->make_test ) { |
107
|
1
|
|
|
|
|
2
|
push @config, " make_test '" . $self->condition->make_test . "';\n"; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
4
|
50
|
|
|
|
10
|
if ( $self->condition->arguments ) { |
111
|
0
|
|
|
|
|
0
|
push @config, " arguments '" . $self->condition->arguments . "';\n"; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
4
|
50
|
|
|
|
9
|
if ( $self->condition->annotation ) { |
115
|
0
|
|
|
|
|
0
|
push @config, " annotation '" . $self->condition->annotation ."';\n"; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
4
|
100
|
|
|
|
6
|
if ( $self->condition->modules ) { |
119
|
1
|
|
|
|
|
3
|
push @config, " modules {\n"; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
2
|
foreach my $module ( sort keys %{ $self->condition->modules } ) { |
|
1
|
|
|
|
|
1
|
|
122
|
|
|
|
|
|
|
push @config, ' ' x 8 . "'" . $module . "' => " . |
123
|
2
|
|
|
|
|
4
|
$self->condition->modules->{$module} . ",\n"; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
1
|
|
|
|
|
2
|
push @config, " };\n"; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
4
|
|
|
|
|
5
|
push @config, "};\n"; |
130
|
|
|
|
|
|
|
|
131
|
4
|
|
|
|
|
8
|
return \@config; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |