| 1 | package SPVM::Builder::Config::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | use File::Basename 'fileparse'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | use Carp 'confess'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ▶ | sub load_config { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 315 | ▶ | my ($config_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 315 | ▶ | unless (-f $config_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 315 | confess("Config file '$config_file' must exist."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 315 | my $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 315 | ▶ | open my $fh, '<', $config_file | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | or confess("Config file '$config_file' can't found: $!."); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 205 | my $config_content = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 205 | $config = &_eval_config_content($config_content, $config_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 205 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 205 | confess("Config file '$config_file' can't be parsed: $@."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 205 | ▶ | unless (defined $config && $config->isa('SPVM::Builder::Config::Linker')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $config and $config->isa("SPVM::Builder::Config::Linker")
defined $config and $config->isa("SPVM::Builder::Config::Linker")
MC/DC0%0/2
defined $config and $config->isa("SPVM::Builder::Config::Linker")
defined $config
$config->isa("SPVM::Builder::Config::Linker")
MC/DC0%0/2
defined $config and $config->isa("SPVM::Builder::Config::Linker")
defined $config
$config->isa("SPVM::Builder::Config::Linker")
Truth table33%1/3
A and B
A= defined $configB= $config->isa("SPVM::Builder::Config::Linker")
Truth table33%1/3
A and B
A= defined $configB= $config->isa("SPVM::Builder::Config::Linker")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 205 | confess("Config file must be an SPVM::Builder::Config::Linker object."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 205 | push @{$config->loaded_config_files}, $config_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 205 | $config->file($config_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 205 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ▶ | sub load_mode_config { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 205 | ▶ | my ($config_file, $mode, $options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_mode_config: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 205 | ▶ | $options //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$options //= {}
$options //= {}
MC/DC0%0/1
$options //= {}
$options
MC/DC0%0/1
$options //= {}
$options
Truth table0%0/2
A
A= $options
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 205 | my $mode_config_file = &remove_ext_from_config_file($config_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 205 | ▶ | if (defined $mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 205 | $mode_config_file .= ".$mode"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 205 | my $config_ext = &get_config_ext(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 205 | $mode_config_file .= ".$config_ext"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 205 | my $config = &load_config($mode_config_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 205 | ▶ | if (defined $mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 203 | $config->mode($mode); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 203 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ▶ | sub load_base_config { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 203 | ▶ | my ($config_file, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_base_config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 203 | my $config = &load_mode_config($config_file, undef, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 203 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | sub _eval_config_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 203 | ▶ | my ($config_content, $config_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_config_content: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 203 | $config_content = <<"EOS"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | use SPVM::Builder::Config::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | use SPVM::Builder::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | use SPVM::Builder::Config::Exe; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | use SPVM::Builder::Config::DLL; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # line 1 "$config_file" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $config_content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 203 | ▶ | return eval $config_content; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ▶ | sub remove_ext_from_config_file { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 203 | ▶ | my ($config_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_ext_from_config_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 203 | my ($config_base_name, $config_dir) = fileparse $config_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 203 | my $config_ext = &get_config_ext(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 203 | $config_base_name =~ s/(\.[^\.]+)?\.$config_ext$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 203 | my $config_file_without_ext = "$config_dir$config_base_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 203 | return $config_file_without_ext; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ▶ | sub load_config_global { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 203 | ▶ | my ($config_global_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config_global: called CC=6 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 203 | ▶ | unless (-f $config_global_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 203 | confess("Config file '$config_global_file' must exist"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 203 | my $config_global; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 203 | ▶ | open my $fh, '<', $config_global_file | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | or confess("Config file '$config_global_file' can't be opened: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 203 | my $config_content = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Prepare and eval config content for global | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 56 | $config_global = &_eval_config_global_content($config_content, $config_global_file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 56 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 56 | confess("Config file '$config_global_file' can't be parsed: $@"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Verify object type | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 56 | ▶ | unless (defined $config_global && $config_global->isa('SPVM::Builder::Config::Global')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined $config_global and $config_global->isa("SPVM::Builder::Config::Global")
defined $config_global and $config_global->isa("SPVM::Builder::Config::Global")
MC/DC0%0/2
defined $config_global and $config_global->isa("SPVM::Builder::Config::Global")
defined $config_global
$config_global->isa("SPVM::Builder::Config::Global")
MC/DC0%0/2
defined $config_global and $config_global->isa("SPVM::Builder::Config::Global")
defined $config_global
$config_global->isa("SPVM::Builder::Config::Global")
Truth table0%0/3
A and B
A= defined $config_globalB= $config_global->isa("SPVM::Builder::Config::Global")
Truth table0%0/3
A and B
A= defined $config_globalB= $config_global->isa("SPVM::Builder::Config::Global")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 56 | confess("Config file must be an SPVM::Builder::Config::Global object."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 56 | return $config_global; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | sub _eval_config_global_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 56 | ▶ | my ($config_global_content, $config_global_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval_config_global_content: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 56 | $config_global_content = <<"EOS"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | use SPVM::Builder::Config::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | use SPVM::Builder::Config::Global; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # line 1 "$config_global_file" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $config_global_content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | EOS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 341 | ▶ | return eval $config_global_content; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ▶ | sub create_config_file_path_from_class_file_path { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 56 | ▶ | my ($class_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_config_file_path_from_class_file_path: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 56 | ▶ | unless ($class_file =~ /\.spvm$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 56 | Carp::confess("The class file path '$class_file' must end with '.spvm'."); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 56 | my $config_ext = &get_config_ext(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 56 | my $config_file = $class_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 56 | $config_file =~ s/\.spvm$/.$config_ext/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 56 | return $config_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ▶ | sub get_config_ext { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 56 | ▶ | my $config_ext = 'build'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_config_ext: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 56 | return $config_ext; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ▶ | sub exists_config_file { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 56 | ▶ | my ($config_file) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists_config_file: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 55 | my $config_ext = &get_config_ext(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 55 | my $exists_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 51 | ▶ | if (-f $config_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 55 | $exists_file = $config_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 55 | return $exists_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | =head1 Name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | SPVM::Builder::Config::Util - Config Utilities | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | =head1 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | SPVM::Builder::Config::Util module has utilities for L<SPVM::Builder::Config> class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | =head1 Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | =head2 load_config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | my $config = SPVM::Builder::Config::Util::load_config($config_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | Loads the config file $config_file and returns an L<SPVM::Builder::Config::Base> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my $config = SPVM::Builder::Config::Util::load_config($config_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | L<file|SPVM::Builder::Config::Base/"file"> field of the returned config object is set to $config_file. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | =head2 load_mode_config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | my $config = SPVM::Builder::Config::Util::load_mode_config($config_file, $mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | Loads the mode config from the config file $config_file and the mode $mode and returns an L<SPVM::Builder::Config::Base> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $config_file is a config file path, such as C<path/MyClass.build> and C<path/MyClass.debug.build>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | A mode config file is a config file with a mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # Mode config file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | MyClass.debug.build | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | The mode config file path such as C<path/MyClass.$mode.build> is created from $config_file and $mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | L<mode|SPVM::Builder::Config::Base/"mode"> field of the returned config object is set to $mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | This function calls L</"load_config"> function internally. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | See also L<SPVM::Builder::Config::Base/"Config Mode">. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | Examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | my $config = SPVM::Builder::Config::Util::load_mode_config(__FILE__, "debug"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | =head2 load_base_config | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | my $config = SPVM::Builder::Config::Util::load_base_config($config_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | Loads the base config from the config file $config_file and returns an L<SPVM::Builder::Config::Base> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | A base config file is the config file that removes its mode. If $config_file is C<path/MyClass.debug.build>, the base config file is C<path/MyClass.build>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | This function calls L</"load_mode_config"> function internally. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | Examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | my $config = SPVM::Builder::Config::Util::load_base_config(__FILE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | =head2 remove_ext_from_config_file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | my $config_file_without_ext = SPVM::Builder::Config::Util::remove_ext_from_config_file($config_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | Removes the all extension from the config file path $config_file and returns it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | =head2 load_config_global | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | my $config_global = SPVM::Builder::Config::Util::load_config_global($config_global_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | Loads the global config from the config file $config_global_file and returns an L<SPVM::Builder::Config::Global> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | Examples: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | my $config_global = SPVM::Builder::Config::Util::load_config_global($config_global_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||