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