Changeset 2154 in ProjectBuilder
- Timestamp:
- Dec 23, 2016, 4:25:49 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2152 r2154 29 29 30 30 our @ISA = qw(Exporter); 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_ print pb_conf_get_all pb_conf_get_hash pb_conf_cache);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); 32 32 ($VERSION,$REVISION) = pb_version_init(); 33 33 … … 156 156 return($lh) if (defined $pbconffiles{$cf}); 157 157 158 # Add the new one at the end158 # The new conf file overload values already managed 159 159 my $num = keys %pbconffiles; 160 160 pb_log(2,"DEBUG: pb_conf_cache of $cf at position $num\n"); … … 317 317 sub pb_conf_get_if { 318 318 319 return(pb_conf_get_in_hash_if($h,@_)); 319 my @param = @_; 320 my @return = pb_conf_get_in_hash_if($h,@_); 321 my $proj = undef; 322 323 if (not defined $ENV{'PBPROJ'}) { 324 $proj = "unknown"; 325 } else { 326 $proj = $ENV{'PBPROJ'}; 327 } 328 329 foreach my $i (0..$#param) { 330 if (not defined $return[$i]->{$proj}) { 331 $return[$i]->{$proj} = $return[$i]->{'default'} if (defined $return[$i]->{'default'}); 332 } 333 } 334 return(@return); 320 335 } 321 336 … … 342 357 # Everything is returned via @h 343 358 # @h contains the values overloading what @ptr may contain. 344 my @h = pb_conf_get_i f(@params);359 my @h = pb_conf_get_in_hash_if($h,@params); 345 360 my @ptr = pb_conf_get_in_hash_if($ptr,@params); 346 361 … … 349 364 350 365 pb_log(2,"DEBUG: pb_conf_add_last_in_hash params: ".Dumper(@params)."\n"); 351 pb_log(2,"DEBUG: pb_conf_add_last_in_hash hash: ".Dumper(@h)."\n");352 pb_log(2,"DEBUG: pb_conf_add_last_in_hash input: ".Dumper(@ptr)."\n");366 pb_log(2,"DEBUG: pb_conf_add_last_in_hash current hash: ".Dumper(@h)."\n"); 367 pb_log(2,"DEBUG: pb_conf_add_last_in_hash new inputs: ".Dumper(@ptr)."\n"); 353 368 354 369 foreach my $i (0..$#params) { 355 370 $p1 = $h[$i]; 356 371 $p2 = $ptr[$i]; 357 # Always try to take the param from h 372 # Always try to take the param from h in priority 358 373 # in order to mask what could be defined already in ptr 359 374 if (not defined $p2) { 360 375 # exit if no p1 either 361 376 next if (not defined $p1); 362 # No ref in p2 so use p1363 $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if ((not defined $p1->{$ENV{'PBPROJ'}}) && (defined $p1->{'default'}));364 377 } else { 365 378 # Ref found in p2 366 379 if (not defined $p1) { 367 380 # No ref in p1 so use p2's value 368 $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if ((not defined $p2->{$ENV{'PBPROJ'}}) && (defined $p2->{'default'}));369 381 $p1 = $p2; 370 382 } else { 371 383 # Both are defined - handling the overloading 372 if (not defined $p1->{'default'}) { 373 if (defined $p2->{'default'}) { 374 $p1->{'default'} = $p2->{'default'}; 375 } 376 } 377 384 # Now copy back into p1 all p2 content 385 # as p1 content always has priority over p2 378 386 if (not defined $p1->{$ENV{'PBPROJ'}}) { 379 387 if (defined $p2->{$ENV{'PBPROJ'}}) { 380 388 $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}}; 381 } else {382 $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (defined $p1->{'default'});383 389 } 384 390 } 385 391 # Now copy back into p1 all p2 content which doesn't exist in p1 386 # p1 content always has priority over p2392 # # p1 content always has priority over p2 387 393 foreach my $k (keys %$p2) { 388 394 $p1->{$k} = $p2->{$k} if (not defined $p1->{$k});
Note:
See TracChangeset
for help on using the changeset viewer.