| 1 | package Enbld; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.7032_1'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use FindBin qw/$Script/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Try::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 15 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 16 | 1 | our @EXPORT = qw/ | |||||||||||||||||||||||||||
| 17 | enbld | ||||||||||||||||||||||||||||
| 18 | build | ||||||||||||||||||||||||||||
| 19 | target | ||||||||||||||||||||||||||||
| 20 | define | ||||||||||||||||||||||||||||
| 21 | version | ||||||||||||||||||||||||||||
| 22 | make_test | ||||||||||||||||||||||||||||
| 23 | modules | ||||||||||||||||||||||||||||
| 24 | arguments | ||||||||||||||||||||||||||||
| 25 | annotation | ||||||||||||||||||||||||||||
| 26 | conf | ||||||||||||||||||||||||||||
| 27 | load | ||||||||||||||||||||||||||||
| 28 | copy | ||||||||||||||||||||||||||||
| 29 | set | ||||||||||||||||||||||||||||
| 30 | from | ||||||||||||||||||||||||||||
| 31 | to | ||||||||||||||||||||||||||||
| 32 | content | ||||||||||||||||||||||||||||
| 33 | /; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | require Enbld::App::Configuration; | |||||||||||||||||||||||||||
| 36 | 1 | require Enbld::Logger; | |||||||||||||||||||||||||||
| 37 | 1 | require Enbld::Target; | |||||||||||||||||||||||||||
| 38 | 1 | require Enbld::Condition; | |||||||||||||||||||||||||||
| 39 | 1 | require Enbld::Error; | |||||||||||||||||||||||||||
| 40 | 1 | require Enbld::Exception; | |||||||||||||||||||||||||||
| 41 | 1 | require Enbld::RcFile; | |||||||||||||||||||||||||||
| 42 | 1 | require Enbld::Deployed; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | our $initialized; | |||||||||||||||||||||||||||
| 45 | 1 | our %target_result; | |||||||||||||||||||||||||||
| 46 | 1 | our %rcfile_result; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | our %rcfile_collection; | |||||||||||||||||||||||||||
| 49 | 1 | our %target_collection; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | sub enbld($$) { | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my ( $envname, $coderef ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
enbld: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ( ref( $envname ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | _err( | |||||||||||||||||||||||||||
| 56 | "Function 'enbld' first requires " . | ||||||||||||||||||||||||||||
| 57 | "string type parameter 'env name'." | ||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( $envname =~ /[^0-9a-zA-Z_]/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | _err( | |||||||||||||||||||||||||||
| 63 | "Env name '$envname' contains invalid character.", | ||||||||||||||||||||||||||||
| 64 | $envname | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( ref( $coderef ) ne 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | _err( "Function 'enbld' second requires code reference parameter." ); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | require Enbld::Message; | |||||||||||||||||||||||||||
| 73 | 0 | Enbld::Message->set_verbose; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | parse_option(); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | require Enbld::Home; | |||||||||||||||||||||||||||
| 78 | 0 | Enbld::Home->initialize; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | Enbld::App::Configuration->read_file; | |||||||||||||||||||||||||||
| 81 | 0 | Enbld::App::Configuration->set_envname( $_[0] ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | $initialized++; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | $_[1]->(); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | Enbld->_setup_directory; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | foreach my $name ( sort keys %target_collection ) { | |||||||||||||||||||||||||||
| 90 | 0 | build_target( $name ); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | foreach my $filepath ( sort keys %rcfile_collection ) { | |||||||||||||||||||||||||||
| 94 | 0 | do_rcfile( $rcfile_collection{$filepath} ); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | undef $initialized; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | show_result_message(); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | check_targets_in_DSL(); | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( ! Enbld::App::Configuration->is_dirty ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | Enbld::Message->notify( | |||||||||||||||||||||||||||
| 105 | "INFO:No builded targets & loaded configuration file." | ||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | return 1; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | sub build_target { | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $name = shift; | ||||||||||||||||||||||||||
|
Subroutine
build_target: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $config = Enbld::Feature->is_deploy_mode ? undef : | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | Enbld::App::Configuration->search_config( $name ); | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my $target = Enbld::Target->new( $name, $config ); | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | my $installed = try { | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return Enbld::Feature->is_deploy_mode ? | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | $target->deploy_declared( \%target_collection ) : | ||||||||||||||||||||||||||||
| 123 | $target->install_declared( \%target_collection ); | ||||||||||||||||||||||||||||
| 124 | } ( 'Enbld::Error' => sub { | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | Enbld::Message->alert( $@ ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $^O ne 'darwin' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | say "If you run Enbld at Linux or BSD, there is a possibility " . | |||||||||||||||||||||||||||
| 129 | "that the Software which depends is not installed."; | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | say "\n" . "Please check build logile:" . Enbld::Logger->logfile; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | $target_result{$name} = $name . ' is failure to build.'; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | return; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | 0 | ); | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | # Target is installed. | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( $installed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $target_result{$name} = $name . ' ' . $installed->enabled . | |||||||||||||||||||||||||||
| 143 | " is installed."; | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | Enbld::App::Configuration->set_config( $installed ); | |||||||||||||||||||||||||||
| 146 | 0 | Enbld::App::Configuration->write_file; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ( Enbld::Feature->is_deploy_mode ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | Enbld::Deployed->add( $installed ); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | return $name; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | # Target is up-to-date. | ||||||||||||||||||||||||||||
| 156 | 0 | $target_result{$name} = $name . ' is up-to-date.'; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | return $name; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | sub check_targets_in_DSL { | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | return if Enbld::Feature->is_deploy_mode; | ||||||||||||||||||||||||||
|
Subroutine
check_targets_in_DSL: not called CC=6 SCAR=37.4
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | my %not_in_dsl; | |||||||||||||||||||||||||||
| 166 | 0 | foreach my $name ( keys %{ Enbld::App::Configuration->config } ) { | |||||||||||||||||||||||||||
| 167 | 0 | my $config = Enbld::App::Configuration->search_config( $name ); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $not_in_dsl{$name}++ unless defined $target_result{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( keys %not_in_dsl ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | Enbld::Message->notify( | |||||||||||||||||||||||||||
| 174 | "WARN:The following targets are not defined in DSL $Script.\n" . | ||||||||||||||||||||||||||||
| 175 | "Please check $Script." | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | foreach my $target ( sort keys %not_in_dsl ) { | |||||||||||||||||||||||||||
| 179 | 0 | Enbld::Message->notify( " " . $target ); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | sub show_result_message { | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | foreach my $target ( sort keys %target_result ) { | ||||||||||||||||||||||||||
|
Subroutine
show_result_message: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 187 | 0 | Enbld::Message->notify( $target_result{$target} ); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | foreach my $file ( sort keys %rcfile_result ) { | |||||||||||||||||||||||||||
| 191 | 0 | Enbld::Message->notify( $rcfile_result{$file} ); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | sub build(&) { | ||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
build: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 1 | our $condition_ref; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | sub target($$) { | ||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my ( $targetname, $coderef ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
target: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ( ! $initialized ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | _err( | |||||||||||||||||||||||||||
| 206 | "Environment is not initialized.". | ||||||||||||||||||||||||||||
| 207 | "Isn't the syntax of DSL possibly mistaken?" | ||||||||||||||||||||||||||||
| 208 | ); | ||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( ref( $targetname ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 0 | _err( | |||||||||||||||||||||||||||
| 213 | "Function 'target' first requsres " . | ||||||||||||||||||||||||||||
| 214 | "string type parameter 'target name'." | ||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if( $targetname =~ /[^0-9a-z]/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | _err( "Target name '$targetname' contains invalid character." ); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( ref( $coderef ) ne 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | _err( "Function 'target' seconde requires code reference parameter." ); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | $condition_ref = { | ||||||||||||||||||||||||||||
| 227 | 0 | name => $targetname, | |||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | $coderef->(); | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | my $condition = Enbld::Condition->new( %{ $condition_ref } ); | |||||||||||||||||||||||||||
| 233 | 0 | $target_collection{$targetname} = $condition; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | undef $condition_ref; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | sub define(&) { | ||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my $coderef = shift; | ||||||||||||||||||||||||||
|
Subroutine
define: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | return $coderef; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | sub version($) { | ||||||||||||||||||||||||||||
| 245 | 0 | ▶ | my $version = shift; | ||||||||||||||||||||||||||
|
Subroutine
version: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( ref( $version ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 0 | _err( "Function 'version' requires string type parameter." ); | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | $condition_ref->{version} = $version; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | sub make_test(;$) { | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $make_test = shift; | ||||||||||||||||||||||||||
|
Subroutine
make_test: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ( $make_test && ref( $make_test ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$make_test and ref $make_test
MC/DC0%0/2
$make_test and ref $make_test
$make_test
ref $make_test
Truth table0%0/3
A and B
A= $make_testB= ref $make_test
| |||||||||||||||||||||||||||||
| 258 | 0 | _err( "Function 'make_test' requires string type parameter." ); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $condition_ref->{make_test} = $make_test if $make_test; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | sub arguments($) { | ||||||||||||||||||||||||||||
| 265 | 0 | ▶ | my $arguments = shift; | ||||||||||||||||||||||||||
|
Subroutine
arguments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ( ref( $arguments ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 0 | _err( "Function 'arguments' requires string type parameter." ); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 0 | $condition_ref->{arguments} = $arguments; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | sub annotation($) { | ||||||||||||||||||||||||||||
| 275 | 0 | ▶ | my $annotation = shift; | ||||||||||||||||||||||||||
|
Subroutine
annotation: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( ref( $annotation ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 0 | _err( "Function 'annotation' requires string type parameter." ); | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 0 | $condition_ref->{annotation} = $annotation; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | sub modules($) { | ||||||||||||||||||||||||||||
| 285 | 0 | ▶ | my $modules = shift; | ||||||||||||||||||||||||||
|
Subroutine
modules: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ( ref( $modules ) ne 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 0 | _err( "Function 'modules' requires HASH reference type parameter." ); | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | $condition_ref->{modules} = $modules; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 1 | our $rcfile_condition; | |||||||||||||||||||||||||||
| 295 | sub conf($$) { | ||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my ( $filepath, $coderef ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
conf: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ( ! $initialized ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 0 | _err( | |||||||||||||||||||||||||||
| 300 | "Environment is not initialized.". | ||||||||||||||||||||||||||||
| 301 | "Isn't the syntax of DSL possibly mistaken?" | ||||||||||||||||||||||||||||
| 302 | ); | ||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( ref( $filepath ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | _err( "Function 'conf' first requires string type parameter." ); | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ( $filepath =~ /\s/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 0 | _err( | |||||||||||||||||||||||||||
| 311 | "Configuration file path parameter must " . | ||||||||||||||||||||||||||||
| 312 | "not contain space character." | ||||||||||||||||||||||||||||
| 313 | ); | ||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if ( ref( $coderef ) ne 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | 0 | _err( "Function 'conf' requires code reference type parameter." ); | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | $coderef->(); | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | $rcfile_condition->{filepath} = $filepath; | |||||||||||||||||||||||||||
| 323 | 0 | $rcfile_collection{$filepath} = Enbld::RcFile->new( %{ $rcfile_condition } ); | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 0 | undef $rcfile_condition; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | sub do_rcfile { | ||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my $rcfile = shift; | ||||||||||||||||||||||||||
|
Subroutine
do_rcfile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | my $result = try { | ||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return $rcfile->do; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 333 | } ( 'Enbld::Error' => sub { | ||||||||||||||||||||||||||||
| 334 | 0 | ▶ | Enbld::Message->alert( $@ ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | say "\n" . "Please check build logile:" . Enbld::Logger->logfile; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | $rcfile_result{$rcfile->filepath} = | |||||||||||||||||||||||||||
| 339 | $rcfile->filepath . ' is failure to create.'; | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 0 | return; | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | 0 | ); | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | # Configuration file is loaded or set. | ||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( $result ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 0 | Enbld::App::Configuration->set_rcfile( $rcfile ); | |||||||||||||||||||||||||||
| 349 | 0 | Enbld::App::Configuration->write_file; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | $rcfile_result{$rcfile->filepath} = | |||||||||||||||||||||||||||
| 352 | $rcfile->filepath . ' is created.'; | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | return $result; | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | # Configuration file is not loaded or set. | ||||||||||||||||||||||||||||
| 358 | 0 | $rcfile_result{$rcfile->filepath} = | |||||||||||||||||||||||||||
| 359 | $rcfile->filepath . ' is not created.'; | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | return; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | sub load(&) { | ||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $rcfile_condition->{command} = 'load'; | ||||||||||||||||||||||||||
|
Subroutine
load: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | return $_[0]; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | sub set(&) { | ||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $rcfile_condition->{command} = 'set'; | ||||||||||||||||||||||||||
|
Subroutine
set: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 0 | return $_[0]; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | sub copy(&) { | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $rcfile_condition->{command} = 'copy'; | ||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | return $_[0]; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | sub from($) { | ||||||||||||||||||||||||||||
| 383 | 0 | ▶ | my $from = shift; | ||||||||||||||||||||||||||
|
Subroutine
from: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if ( ref( $from ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 0 | _err( "Function 'from' requsres string type parameter." ); | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | $rcfile_condition->{from} = $from; | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | sub to($) { | ||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my $to = shift; | ||||||||||||||||||||||||||
|
Subroutine
to: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ( ref( $to ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | _err( "Function 'to' requsres string type parameter." ); | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $to =~ /\s/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | 0 | _err( "Function 'to' must not contain space character." ); | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | $rcfile_condition->{directory} = $to; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | sub content($) { | ||||||||||||||||||||||||||||
| 407 | 0 | ▶ | my $content = shift; | ||||||||||||||||||||||||||
|
Subroutine
content: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ( ref( $content ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 0 | _err( "Function 'content' reuqires string type parameter." ); | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | chomp( $content ); | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 0 | $rcfile_condition->{contents} .= $content . "\n"; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 1 | our $setuped; | |||||||||||||||||||||||||||
| 419 | sub _setup_directory { | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | unless ( $setuped ) { | ||||||||||||||||||||||||||
|
Subroutine
_setup_directory: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 0 | Enbld::Home->create_build_directory; | |||||||||||||||||||||||||||
| 423 | 0 | Enbld::Logger->rotate( Enbld::Home->log ); | |||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 0 | $setuped++; | |||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | sub parse_option { | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my $make_test; | ||||||||||||||||||||||||||
|
Subroutine
parse_option: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 432 | my $force; | ||||||||||||||||||||||||||||
| 433 | 0 | my $deploy_path; | |||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 0 | Getopt::Long::Configure( "bundling" ); | |||||||||||||||||||||||||||
| 436 | Getopt::Long::GetOptions( | ||||||||||||||||||||||||||||
| 437 | 0 | ▶ | 't|test' => sub { $make_test++ }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 438 | 0 | ▶ | 'f|force' => sub { $force++ }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 439 | 0 | 'd|deploy=s' => \$deploy_path, | |||||||||||||||||||||||||||
| 440 | ); | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 0 | require Enbld::Feature; | |||||||||||||||||||||||||||
| 443 | 0 | Enbld::Feature->initialize( | |||||||||||||||||||||||||||
| 444 | make_test => $make_test, | ||||||||||||||||||||||||||||
| 445 | force => $force, | ||||||||||||||||||||||||||||
| 446 | deploy => $deploy_path, | ||||||||||||||||||||||||||||
| 447 | ); | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if ( Enbld::Feature->is_deploy_mode ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 450 | 0 | Enbld::Message->notify( | |||||||||||||||||||||||||||
| 451 | "INFO:Enbld is set 'deploy mode'.\n" . | ||||||||||||||||||||||||||||
| 452 | "All targets will be deployed in $deploy_path." | ||||||||||||||||||||||||||||
| 453 | ); | ||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ( Enbld::Feature->is_make_test_all ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | 0 | Enbld::Message->notify( | |||||||||||||||||||||||||||
| 458 | "INFO:Enbld is set 'make test mode'.\n" . | ||||||||||||||||||||||||||||
| 459 | "All targets will be tested." | ||||||||||||||||||||||||||||
| 460 | ); | ||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | ▶ | if ( Enbld::Feature->is_force_install ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 464 | 0 | Enbld::Message->notify( | |||||||||||||||||||||||||||
| 465 | "INFO:Enbld is set 'force install mode'.\n" . | ||||||||||||||||||||||||||||
| 466 | "All targets will be builded by force." | ||||||||||||||||||||||||||||
| 467 | ); | ||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | sub _err { | ||||||||||||||||||||||||||||
| 473 | 0 | ▶ | my ( $msg, $param ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_err: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | die( Enbld::Error->new( $msg, $param ) ); | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 1 | 1; | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | __END__ | ||||||||||||||||||||||||||||