Changeset 2500 in ProjectBuilder
- Timestamp:
- Apr 1, 2020, 2:25:15 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2494 r2500 22 22 # Inherit from the "Exporter" module which handles exporting functions. 23 23 24 use vars qw( $VERSION $REVISION $PBCONFVER@ISA @EXPORT);24 use vars qw(@ISA @EXPORT); 25 25 use Exporter; 26 26 … … 30 30 our @ISA = qw(Exporter); 31 31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_get_all pb_conf_get_hash pb_conf_cache pb_conf_update_v0 pb_conf_get_in_hash_if); 32 ($VERSION,$REVISION,$PBCONFVER) = pb_version_init();33 32 34 33 # Global hash of conf files … … 43 42 # We consider that values can not change during the life of pb 44 43 my $h = (); 44 45 my $dpfunc; 46 my $ldfunc; 47 our ($VERSION,$REVISION,$PBCONFVER) = pb_version_init(); 45 48 46 49 =pod … … 146 149 my $proj=shift; 147 150 148 pb_log( 1,"Entering pb_conf_init\n");151 pb_log(2,"Entering pb_conf_init\n"); 149 152 # 150 153 # Check project name … … 165 168 } 166 169 pb_log(1,"PBPROJ = $ENV{'PBPROJ'}\n"); 170 171 # Manage YAML modules to use 172 173 if ($PBCONFVER >= 1) { 174 eval { 175 require YAML::XS; 176 YAML::XS->import(); 177 }; 178 if ($@) { 179 eval { 180 require YAML; 181 YAML->import(); 182 }; 183 if ($@) { 184 eval { 185 # No YAML found using a more std but less complete one. Old perl only 186 require Module::Build::YAML; 187 Module::Build::YAML->import(); 188 }; 189 if ($@) { 190 eval { 191 # No YAML found using a more std but less complete one. Old perl only 192 require YAML::Tiny; 193 YAML::Tiny->import(); 194 }; 195 if ($@) { 196 # Here we should be in the setup phase, with an embedded YAML code 197 $dpfunc = \&pb_Dump; 198 $ldfunc = \&pb_LoadFile; 199 #die "Unable to handle YAML configuration files without a YAML.pm module\n"; 200 } else { 201 $dpfunc = \&YAML::Tiny::Dump; 202 $ldfunc = \&YAML::Tiny::LoadFile; 203 } 204 } else { 205 $dpfunc = \&Module::Build::YAML::Dump; 206 $ldfunc = \&Module::Build::YAML::LoadFile; 207 } 208 } else { 209 $dpfunc = \&YAML::Dump; 210 $ldfunc = \&YAML::LoadFile; 211 } 212 } else { 213 $dpfunc = \&YAML::XS::Dump; 214 $ldfunc = \&YAML::XS::LoadFile; 215 } 216 } 167 217 } 168 218 … … 180 230 my $cf = shift; 181 231 my $lh = shift; 182 183 my $ldfunc;184 232 185 233 # Read the content of the config file and cache it in the %h hash then available for queries … … 208 256 } 209 257 close(CONF); 258 210 259 } else { 211 eval {212 require YAML::XS;213 YAML::XS->import();214 };215 if ($@) {216 eval {217 require YAML;218 YAML->import();219 };220 if ($@) {221 eval {222 # No YAML found using a more std but less complete one. Old perl only223 require Module::Build::YAML;224 Module::Build::YAML->import();225 };226 if ($@) {227 eval {228 # No YAML found using a more std but less complete one. Old perl only229 require YAML::Tiny;230 YAML::Tiny->import();231 };232 if ($@) {233 eval {234 # No YAML found using an embedded pne235 require ProjectBuilder::YAML;236 ProjectBuilder::YAML->import();237 };238 if ($@) {239 # Here we should be in the setup phase, with an embedded YAML code240 $ldfunc = \&LoadFile;241 #die "Unable to handle YAML configuration files without a YAML.pm module\n";242 } else {243 $ldfunc = \&ProjectBuilder::YAML::LoadFile;244 }245 } else {246 $ldfunc = \&YAML::Tiny::LoadFile;247 }248 } else {249 $ldfunc = \&Module::Build::YAML::LoadFile;250 }251 } else {252 $ldfunc = \&YAML::LoadFile;253 }254 } else {255 $ldfunc = \&YAML::XS::LoadFile;256 }257 258 260 # Have we already handled that conf file ? 259 261 next if ((defined $lh) && (defined $lh->{'__cf'}) && (defined $lh->{'__cf'}->{$cf}) && ($lh->{'__cf'}->{$cf} eq 1)); … … 366 368 my $conffile = shift; 367 369 my $h = shift; 368 my $dpfunc;369 370 370 371 confess "No configuration file defined to write into !" if (not defined $conffile); … … 381 382 } 382 383 } else { 383 # This is the new YAML format384 eval {385 require YAML::XS;386 YAML::XS->import();387 };388 if ($@) {389 eval {390 require YAML;391 YAML->import();392 };393 if ($@) {394 eval {395 # No YAML found using a more std but less complete one. Old perl only396 require Module::Build::YAML;397 Module::Build::YAML->import();398 };399 if ($@) {400 eval {401 # No YAML found using a more std but less complete one. Old perl only402 require YAML::Tiny;403 YAML::Tiny->import();404 };405 if ($@) {406 eval {407 # No YAML found using an embedded pne408 require ProjectBuilder::YAML;409 ProjectBuilder::YAML->import();410 };411 if ($@) {412 # Here we should be in the setup phase, with an embedded YAML code413 $dpfunc = \&LoadFile;414 #die "Unable to handle YAML configuration files without a YAML.pm module\n";415 } else {416 $dpfunc = \&ProjectBuilder::YAML::Dump;417 }418 } else {419 $dpfunc = \&YAML::Tiny::Dump;420 }421 } else {422 $dpfunc = \&Module::Build::YAML::Dump;423 }424 } else {425 $dpfunc = \&YAML::Dump;426 }427 } else {428 $dpfunc = \&YAML::XS::Dump;429 }430 431 384 pb_log(1,"Writing YAML conf file $conffile\n"); 432 385 delete $h->{'__cf'};
Note:
See TracChangeset
for help on using the changeset viewer.