@@ -353,6 +353,7 @@ sub new {
353
353
$self -> {' escape_spaces' } = $self -> escape_spaces();
354
354
$self -> {' current_template' } = undef ;
355
355
$self -> {' make_coexistence' } = $makeco ;
356
+ $self -> {' forcount' } = 0;
356
357
357
358
$self -> add_default_matching_assignments();
358
359
$self -> reset_generating_types();
@@ -4673,14 +4674,24 @@ sub get_custom_value {
4673
4674
}
4674
4675
elsif ($cmd eq ' commands' ) { # only used with 'combined_custom'
4675
4676
$value = [];
4677
+
4678
+ # # Clear out the previous custom_multi_details hash map so that we don't
4679
+ # # have extraneous data associated with commands from previous iterations.
4680
+ $self -> {' custom_multi_details' } = {};
4681
+
4676
4682
my %details = (' flags' => ' commandflags' ,
4677
4683
' outopt' => ' output_option' ,
4678
4684
' gdir' => ' gendir' );
4679
4685
for my $tag (@{$self -> {' custom_multi_cmd' }-> {$based }}) {
4680
4686
my $command = $self -> get_custom_assign_or_override(' command' , $tag ,
4681
4687
$based , @params );
4682
- push (@$value , $command );
4683
- my $det = $self -> {' custom_multi_details' }-> {$command } = {};
4688
+
4689
+ # # Use $tag as the key for custom_multi_details and store the command as
4690
+ # # a data member that we can access later. $command shouldn't be used
4691
+ # # as the key because it is not guaranteed to be unique.
4692
+ my $det = $self -> {' custom_multi_details' }-> {$tag } = {' _cmd' => $command ,
4693
+ ' type' => $tag ,
4694
+ ' outfile' => ' ' };
4684
4695
for my $k (keys %details ) {
4685
4696
$det -> {$k } = $self -> get_custom_assign_or_override($details {$k }, $tag ,
4686
4697
$based , @params );
@@ -4702,11 +4713,16 @@ sub get_custom_value {
4702
4713
}
4703
4714
}
4704
4715
}
4705
- }
4706
- elsif ($cmd eq ' flags' || $cmd eq ' outopt' || $cmd eq ' outfile' ||
4707
- $cmd eq ' gdir' ) {
4708
- # only used with 'combined_custom'
4709
- $value = $self -> {' custom_multi_details' }-> {$based }-> {$cmd } || ' ' ;
4716
+
4717
+ # # Sort the list of types so that generated projects are reproducable.
4718
+ # # Additionally, we need them to be ordered (and numbered) so that we can
4719
+ # # match the command with the right tag when iterating in the template.
4720
+ my $det = $self -> {' custom_multi_details' };
4721
+ my $i = 0;
4722
+ foreach my $key (sort { $a cmp $b } keys %$det ) {
4723
+ $det -> {$key }-> {' _order' } = $i ++;
4724
+ push (@$value , $det -> {$key }-> {' _cmd' });
4725
+ }
4710
4726
}
4711
4727
elsif (defined $customDefined {$cmd }) {
4712
4728
$value = $self -> get_assignment($cmd ,
@@ -4715,6 +4731,30 @@ sub get_custom_value {
4715
4731
$value = $self -> convert_command_parameters($based , $value , @params );
4716
4732
}
4717
4733
}
4734
+ else {
4735
+ # # This is only used with 'combined_custom'.
4736
+ # #
4737
+ # # $based - The command for the original define custom.
4738
+ # # $cmd - The member after the arrow operator.
4739
+ # #
4740
+ # # We cannot use a direct lookup because the command is no longer the
4741
+ # # key for custom_multi_details. It is possible to have two or more custom
4742
+ # # types that use the same command. Therefore, we have to use the custom
4743
+ # # type name ($tag) as the key. Since this code can only be called within
4744
+ # # a foreach, we have to rely on the fact that the values created above
4745
+ # # (during the processing of 'commands') are sorted to correlate the
4746
+ # # command, stored in $base, with the correct tag in order to get the
4747
+ # # correct command flags and other associated values.
4748
+ foreach my $tag (keys %{$self -> {' custom_multi_details' }}) {
4749
+ my $det = $self -> {' custom_multi_details' }-> {$tag };
4750
+ if ($det -> {' _cmd' } eq $based && $det -> {' _order' } == $self -> {' forcount' }) {
4751
+ if (exists $det -> {$cmd }) {
4752
+ $value = $det -> {$cmd };
4753
+ }
4754
+ last ;
4755
+ }
4756
+ }
4757
+ }
4718
4758
4719
4759
return $value ;
4720
4760
}
@@ -5819,7 +5859,7 @@ sub combine_custom_types {
5819
5859
# synthetic type.
5820
5860
foreach my $in (keys %input ) {
5821
5861
next if scalar @{$input {$in }} < 2;
5822
- my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } @{$input {$in }})
5862
+ my $combo_tag = join (' _and_' , map {/ (.+)_files$ / ; $1 } sort ( @{$input {$in }}) )
5823
5863
. ' _files' ;
5824
5864
if (!$self -> {' combined_custom' }-> {$combo_tag }) {
5825
5865
$self -> {' combined_custom' }-> {$combo_tag } = $input {$in };
@@ -5883,6 +5923,10 @@ sub combine_custom_types {
5883
5923
return 1;
5884
5924
}
5885
5925
5926
+ sub set_forcount {
5927
+ my ($self , $count ) = @_ ;
5928
+ $self -> {' forcount' } = $count ;
5929
+ }
5886
5930
5887
5931
# ************************************************************
5888
5932
# Accessors used by support scripts
0 commit comments