@@ -194,7 +194,7 @@ my $cppresource = 'resource_files';
194
194
my %cppvc = (' source_files' => [ " \\ .cpp" , " \\ .cxx" , " \\ .cc" , " \\ .c" , " \\ .C" , ],
195
195
' template_files' => [ " _T\\ .cpp" , " _T\\ .cxx" , " _T\\ .cc" , " _T\\ .c" , " _T\\ .C" , " _t\\ .cpp" , " _t\\ .cxx" , " _t\\ .cc" , " _t\\ .c" , " _t\\ .C" , " \\ .tpp" ],
196
196
' header_files' => [ " \\ .h" , " \\ .hpp" , " \\ .hxx" , " \\ .hh" , ],
197
- ' inline_files' => [ " \\ .i" , " \\ .ipp" , " \\ .inl" , ],
197
+ ' inline_files' => [ " \\ .i" , " \\ .ipp" , " \\ .ixx " , " \\ . inl" , ],
198
198
' documentation_files' => [ " README" , " readme" , " \\ .doc" , " \\ .txt" , " \\ .html" ],
199
199
$cppresource => [ " \\ .rc" , ],
200
200
);
@@ -1386,7 +1386,6 @@ sub process_component_line {
1386
1386
$key =~ s /\\ / \/ / g if ($self -> {' convert_slashes' });
1387
1387
my $cmdflags = $$flags {' commandflags' };
1388
1388
my ($add_out , $deps ) = $cmdHelper -> get_output($key , $cmdflags );
1389
-
1390
1389
push (@{$self -> {' custom_special_output' }-> {$tag }-> {$key }}, @$add_out );
1391
1390
foreach my $depTag (keys %$deps ) {
1392
1391
foreach my $depFile (keys %{$deps -> {$depTag }}) {
@@ -3183,10 +3182,9 @@ sub correct_generated_files {
3183
3182
sub generate_default_components {
3184
3183
my ($self , $files , $passed ) = @_ ;
3185
3184
my $genext = $self -> {' generated_exts' };
3186
- my @gc = reverse sort { $self -> sort_generated_types($a , $b )
3187
- } keys %$genext ;
3188
3185
my @tags = (defined $passed ? $passed :
3189
- (@gc , keys %{$language {$self -> get_language()}-> [0]}));
3186
+ ($self -> get_generated_components(),
3187
+ keys %{$language {$self -> get_language()}-> [0]}));
3190
3188
my $pchh = $self -> get_assignment(' pch_header' );
3191
3189
my $pchc = $self -> get_assignment(' pch_source' );
3192
3190
my $recurse = $self -> get_assignment(' recurse' );
@@ -3195,11 +3193,9 @@ sub generate_default_components {
3195
3193
my $cmdflags = ' commandflags' ;
3196
3194
3197
3195
# # The order of @tags does make a difference in the way that generated
3198
- # # files get added. Hence the sort call on the generate_exts keys to
3199
- # # ensure that user defined types come first. They are reverse sorted
3200
- # # using the custom sort function to ensure that user defined types
3201
- # # that rely on other user defined types for input files are processed
3202
- # # first.
3196
+ # # files get added. The function that returns the generated components
3197
+ # # sorts the tags such that user defined types that rely on other user
3198
+ # # defined types for input files are processed first.
3203
3199
foreach my $tag (@tags ) {
3204
3200
if (!defined $genext -> {$tag } ||
3205
3201
$genext -> {$tag }-> {' automatic_in' }) {
@@ -3688,27 +3684,80 @@ sub remove_excluded {
3688
3684
}
3689
3685
3690
3686
3691
- sub sort_generated_types {
3692
- # # We need to sort the custom component types such that a custom type
3693
- # # that generates input for another custom type comes first in the
3694
- # # list.
3695
- my ( $self , $left , $right , $norecurse ) = @_ ;
3696
- foreach my $key (keys %{$self -> {' generated_exts' }-> {$left }}) {
3687
+ sub get_outputexts {
3688
+ my ( $self , $type ) = @_ ;
3689
+ my @outputexts ;
3690
+
3691
+ # # Get all generated output extensions for this generated type.
3692
+ foreach my $key (keys %{$self -> {' generated_exts' }-> {$type }}) {
3697
3693
if ($key =~ / _files$ / ) {
3698
- foreach my $regex (@{$self -> {' generated_exts' }-> {$left }-> {$key }}) {
3699
- my $ext = $regex ;
3700
- $ext =~ s /\\ // g ;
3701
- foreach my $vreg (@{$self -> {' valid_components' }-> {$right }}) {
3702
- return -1 if ($ext =~ / $vreg $ / );
3694
+ push (@outputexts , @{$self -> {' generated_exts' }-> {$type }-> {$key }});
3695
+ }
3696
+ }
3697
+
3698
+ # # If the generated type has a helper, get it and add the output exstensions
3699
+ # # to the list.
3700
+ my $cmdHelper = $self -> find_command_helper($type );
3701
+ push (@outputexts , @{$cmdHelper -> get_outputexts()}) if (defined $cmdHelper );
3702
+
3703
+ return \@outputexts ;
3704
+ }
3705
+
3706
+ sub get_generated_components {
3707
+ my $self = shift ;
3708
+ my @list = keys %{$self -> {' generated_exts' }};
3709
+ my $len = scalar (@list );
3710
+ my %geninfo ;
3711
+ my %movedfor ;
3712
+ for (my $i = 1; $i < $len ; $i ++) {
3713
+ my $right = $list [$i ];
3714
+
3715
+ # # Cache the outputexts into a hash map so that we do not have to call a
3716
+ # # function more than once per type. Since items in the list will be
3717
+ # # swapped and $i modified, we are very likely to hit this cache multiple
3718
+ # # times.
3719
+ my $outputexts ;
3720
+ if (exists $geninfo {$right }) {
3721
+ $outputexts = $geninfo {$right };
3722
+ }
3723
+ else {
3724
+ $geninfo {$right } = $outputexts = $self -> get_outputexts($right );
3725
+ }
3726
+
3727
+ # # Go backwards in the list to see if $right will generate inputs for
3728
+ # # anything to the left.
3729
+ for (my $j = $i - 1; $j >= 0; $j --) {
3730
+ my $left = $list [$j ];
3731
+ # # See if $right generates input for $left
3732
+ my $generates ;
3733
+ foreach my $inputext (@{$self -> {' valid_components' }-> {$left }}) {
3734
+ if (grep { $_ eq $inputext } @$outputexts ) {
3735
+ $generates = 1;
3736
+ last ;
3703
3737
}
3704
3738
}
3739
+
3740
+ if ($generates ) {
3741
+ # # If it does and we haven't already moved $right because of $left,
3742
+ # # then we will move $right in front of $left, push everything to the
3743
+ # # right up to $i, and reset $i to $j (after the increment of the outer
3744
+ # # for loop).
3745
+ if (exists $movedfor {$right } && $movedfor {$right } eq $left ) {
3746
+ $self -> warning(" Circular generation dependency for $right and $left " );
3747
+ }
3748
+ else {
3749
+ $movedfor {$right } = $left ;
3750
+ for (my $k = $i ; $k > $j ; $k --) {
3751
+ $list [$k ] = $list [$k - 1];
3752
+ }
3753
+ $list [$j ] = $right ;
3754
+ $i = $j - 1;
3755
+ }
3756
+ last ;
3757
+ }
3705
3758
}
3706
3759
}
3707
- if (!$norecurse && $self -> sort_generated_types($right , $left , 1) == -1) {
3708
- return 1;
3709
- }
3710
-
3711
- return 0;
3760
+ return @list ;
3712
3761
}
3713
3762
3714
3763
sub generate_defaults {
@@ -3747,8 +3796,7 @@ sub generate_defaults {
3747
3796
my @vc = sort { return -1 if $a eq ' source_files' ;
3748
3797
return 1 if $b eq ' source_files' ;
3749
3798
return $b cmp $a ; } keys %{$self -> {' valid_components' }};
3750
- my @gvc = sort { $self -> sort_generated_types($a , $b )
3751
- } keys %{$self -> {' generated_exts' }};
3799
+ my @gvc = $self -> get_generated_components();
3752
3800
foreach my $gentype (@gvc ) {
3753
3801
$self -> list_default_generated($gentype , \@vc );
3754
3802
}
0 commit comments