Subversion Repositories gelsvn

Rev

Rev 198 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 198 Rev 217
Line 12... Line 12...
12
 
12
 
13
use strict;
13
use strict;
14
use FileHandle;
14
use FileHandle;
15
use File::Path;
15
use File::Path;
16
use File::Compare;
16
use File::Compare;
17
use File::Basename;
-
 
18
 
17
 
19
use Creator;
18
use Creator;
20
use TemplateInputReader;
19
use TemplateInputReader;
21
use TemplateParser;
20
use TemplateParser;
22
use FeatureParser;
21
use FeatureParser;
Line 35... Line 34...
35
 
34
 
36
## Valid names for assignments within a project
35
## Valid names for assignments within a project
37
## Bit Meaning
36
## Bit Meaning
38
## 0   Preserve the order for additions (1) or invert it (0)
37
## 0   Preserve the order for additions (1) or invert it (0)
39
## 1   Add this value to template input value (if there is one)
38
## 1   Add this value to template input value (if there is one)
-
 
39
## 2   Preserve <% %> settings for evaluation within the template
40
my(%validNames) = ('exename'         => 1,
40
my(%validNames) = ('exename'         => 1,
41
                   'sharedname'      => 1,
41
                   'sharedname'      => 1,
42
                   'staticname'      => 1,
42
                   'staticname'      => 1,
43
                   'libpaths'        => 3,
43
                   'libpaths'        => 3,
44
                   'install'         => 1,
44
                   'install'         => 1,
Line 48... Line 48...
48
                   'libs'            => 2,
48
                   'libs'            => 2,
49
                   'lit_libs'        => 2,
49
                   'lit_libs'        => 2,
50
                   'pure_libs'       => 2,
50
                   'pure_libs'       => 2,
51
                   'pch_header'      => 1,
51
                   'pch_header'      => 1,
52
                   'pch_source'      => 1,
52
                   'pch_source'      => 1,
-
 
53
                   'prebuild'        => 5,
53
                   'postbuild'       => 1,
54
                   'postbuild'       => 5,
54
                   'dllout'          => 1,
55
                   'dllout'          => 1,
55
                   'libout'          => 1,
56
                   'libout'          => 1,
56
                   'dynamicflags'    => 3,
57
                   'dynamicflags'    => 3,
57
                   'staticflags'     => 3,
58
                   'staticflags'     => 3,
58
                   'version'         => 1,
59
                   'version'         => 1,
Line 120... Line 121...
120
 
121
 
121
## All matching assignment arrays will get these keywords
122
## All matching assignment arrays will get these keywords
122
my(@default_matching_assignments) = ('recurse',
123
my(@default_matching_assignments) = ('recurse',
123
                                    );
124
                                    );
124
 
125
 
-
 
126
## These matching assingment arrays will get added, but only to the
-
 
127
## specific project component types.
-
 
128
my(%default_matching_assignments) = ('source_files' => ['buildflags'],
-
 
129
                                    );
-
 
130
 
125
## Deal with these components in a special way
131
## Deal with these components in a special way
126
my(%specialComponents) = ('header_files'   => 1,
132
my(%specialComponents) = ('header_files'   => 1,
127
                          'inline_files'   => 1,
133
                          'inline_files'   => 1,
128
                          'template_files' => 1,
134
                          'template_files' => 1,
129
                         );
135
                         );
Line 143... Line 149...
143
 
149
 
144
## Valid component names within a project along with the valid file extensions
150
## Valid component names within a project along with the valid file extensions
145
my(%cppvc) = ('source_files'        => [ "\\.cpp", "\\.cxx", "\\.cc", "\\.c", "\\.C", ],
151
my(%cppvc) = ('source_files'        => [ "\\.cpp", "\\.cxx", "\\.cc", "\\.c", "\\.C", ],
146
              'template_files'      => [ "_T\\.cpp", "_T\\.cxx", "_T\\.cc", "_T\\.c", "_T\\.C", ],
152
              'template_files'      => [ "_T\\.cpp", "_T\\.cxx", "_T\\.cc", "_T\\.c", "_T\\.C", ],
147
              'header_files'        => [ "\\.h", "\\.hpp", "\\.hxx", "\\.hh", ],
153
              'header_files'        => [ "\\.h", "\\.hpp", "\\.hxx", "\\.hh", ],
148
              'inline_files'        => [ "\\.i", "\\.inl", ],
154
              'inline_files'        => [ "\\.i", "\\.ipp", "\\.inl", ],
149
              'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
155
              'documentation_files' => [ "README", "readme", "\\.doc", "\\.txt", "\\.html" ],
150
              'resource_files'      => [ "\\.rc", ],
156
              'resource_files'      => [ "\\.rc", ],
151
             );
157
             );
152
 
158
 
153
## Exclude these extensions when auto generating the component values
159
## Exclude these extensions when auto generating the component values
Line 204... Line 210...
204
# 2     Assignments available in standard file types
210
# 2     Assignments available in standard file types
205
# 3     The entry point for executables
211
# 3     The entry point for executables
206
# 4     The language uses a C preprocessor
212
# 4     The language uses a C preprocessor
207
my(%language) = ('cplusplus' => [ \%cppvc, \%cppec, {}    , 'main', 1 ],
213
my(%language) = ('cplusplus' => [ \%cppvc, \%cppec, {}    , 'main', 1 ],
208
                 'csharp'    => [ \%csvc,  {},      \%csma, 'Main', 0 ],
214
                 'csharp'    => [ \%csvc,  {},      \%csma, 'Main', 0 ],
209
                 'java'      => [ \%jvc,   {},      {}    , 'Main', 0 ],
215
                 'java'      => [ \%jvc,   {},      {}    , 'main', 0 ],
210
                 'vb'        => [ \%vbvc,  {},      \%vbma, 'Main', 0 ],
216
                 'vb'        => [ \%vbvc,  {},      \%vbma, 'Main', 0 ],
211
                );
217
                );
212
 
218
 
213
# ************************************************************
219
# ************************************************************
214
# Subroutine Section
220
# Subroutine Section
Line 279... Line 285...
279
  $typefeaturef = undef if (! -r $typefeaturef);
285
  $typefeaturef = undef if (! -r $typefeaturef);
280
  $self->{'feature_parser'}        = new FeatureParser($features,
286
  $self->{'feature_parser'}        = new FeatureParser($features,
281
                                                       $gfeature,
287
                                                       $gfeature,
282
                                                       $typefeaturef,
288
                                                       $typefeaturef,
283
                                                       $feature);
289
                                                       $feature);
284
  $self->{'convert_slashes'}       = $self->convert_slashes();
-
 
285
  $self->{'sort_files'}            = $self->sort_files();
290
  $self->{'sort_files'}            = $self->sort_files();
286
  $self->{'source_callback'}       = undef;
291
  $self->{'source_callback'}       = undef;
287
  $self->{'dollar_special'}        = $self->dollar_special();
292
  $self->{'dollar_special'}        = $self->dollar_special();
288
  $self->{'generate_ins'}          = $genins;
293
  $self->{'generate_ins'}          = $genins;
289
  $self->{'addtemp_state'}         = undef;
294
  $self->{'addtemp_state'}         = undef;
290
  $self->{'command_subs'}          = $self->get_command_subs();
295
  $self->{'command_subs'}          = $self->get_command_subs();
291
  $self->{'escape_spaces'}         = $self->escape_spaces();
296
  $self->{'escape_spaces'}         = $self->escape_spaces();
-
 
297
  $self->{'case_insensitive'}      = $self->case_insensitive();
292
 
298
 
293
  $self->add_default_matching_assignments();
299
  $self->add_default_matching_assignments();
294
  $self->reset_generating_types();
300
  $self->reset_generating_types();
295
 
301
 
296
  return $self;
302
  return $self;
297
}
303
}
298
 
304
 
299
 
305
 
-
 
306
sub is_keyword {
-
 
307
  my($self) = shift;
-
 
308
  my($name) = shift;
-
 
309
  return $self->{'valid_names'}->{$name};
-
 
310
}
-
 
311
 
-
 
312
 
300
sub read_global_configuration {
313
sub read_global_configuration {
301
  my($self)   = shift;
314
  my($self)   = shift;
302
  my($input)  = $self->get_global_cfg();
315
  my($input)  = $self->get_global_cfg();
303
  my($status) = 1;
316
  my($status) = 1;
304
 
317
 
Line 328... Line 341...
328
  my($assign) = shift;
341
  my($assign) = shift;
329
 
342
 
330
  ## Support the '*' mechanism as in the project name, to allow
343
  ## Support the '*' mechanism as in the project name, to allow
331
  ## the user to correctly depend on another project within the same
344
  ## the user to correctly depend on another project within the same
332
  ## directory.
345
  ## directory.
-
 
346
  if (defined $value) {
333
  if ($name eq 'after' && $value =~ /\*/) {
347
    if ($name eq 'after' && index($value, '*') >= 0) {
334
    $value = $self->fill_type_name($value,
348
      $value = $self->fill_type_name($value,
335
                                   $self->get_default_project_name());
349
                                     $self->get_default_project_name());
336
  }
350
    }
337
  if (defined $value && !$self->{'dollar_special'} && $value =~ /\$\$/) {
351
    if (!$self->{'dollar_special'} && index($value, '$$') >= 0) {
338
    $value =~ s/\$\$/\$/g;
352
      $value =~ s/\$\$/\$/g;
-
 
353
    }
-
 
354
    if (defined $self->{'valid_names'}->{$name} &&
-
 
355
        ($self->{'valid_names'}->{$name} & 0x04) == 0 &&
-
 
356
        index($value, '<%') >= 0) {
-
 
357
      $value = $self->replace_parameters($value, $self->{'command_subs'});
-
 
358
    }
339
  }
359
  }
340
  $self->SUPER::process_assignment($name, $value, $assign);
360
  $self->SUPER::process_assignment($name, $value, $assign);
341
 
361
 
342
  ## Support keyword mapping here only at the project level scope. The
362
  ## Support keyword mapping here only at the project level scope. The
343
  ## scoped keyword mapping is done through the parse_scoped_assignment()
363
  ## scoped keyword mapping is done through the parse_scoped_assignment()
344
  ## method.
364
  ## method.
345
  if (!defined $assign || $assign == $self->get_assignment_hash()) {
365
  if (!defined $assign || $assign == $self->get_assignment_hash()) {
346
    my($mapped) = $self->{'valid_names'}->{$name};
366
    my($mapped) = $self->{'valid_names'}->{$name};
347
    if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
367
    if (defined $mapped && UNIVERSAL::isa($mapped, 'ARRAY')) {
348
      $self->parse_scoped_assignment($$mapped[0], 'assignment',
368
      $self->parse_scoped_assignment($$mapped[0], '=',
349
                                     $$mapped[1], $value,
369
                                     $$mapped[1], $value,
350
                                     $self->{'generated_exts'}->{$$mapped[0]});
370
                                     $self->{'generated_exts'}->{$$mapped[0]});
351
    }
371
    }
352
  }
372
  }
353
}
373
}
Line 470... Line 490...
470
            ## The base project has already been read.  So, if
490
            ## The base project has already been read.  So, if
471
            ## we are reading the original project (not a parent base
491
            ## we are reading the original project (not a parent base
472
            ## project), then the current base project is redundant.
492
            ## project), then the current base project is redundant.
473
            if (!defined $self->{'reading_parent'}->[0]) {
493
            if (!defined $self->{'reading_parent'}->[0]) {
474
              $file =~ s/\.[^\.]+$//;
494
              $file =~ s/\.[^\.]+$//;
475
              $self->information('Inheriting from \'' . basename($file) .
495
              $self->information('Inheriting from \'' .
-
 
496
                                 $self->mpc_basename($file) .
476
                                 '\' in ' . $self->{'current_input'} .
497
                                 '\' in ' . $self->{'current_input'} .
477
                                 ' is redundant at line ' .
498
                                 ' is redundant at line ' .
478
                                 $self->get_line_number() . '.');
499
                                 $self->get_line_number() . '.');
479
            }
500
            }
480
          }
501
          }
Line 574... Line 595...
574
              $status = 0;
595
              $status = 0;
575
            }
596
            }
576
          }
597
          }
577
 
598
 
578
          if ($status) {
599
          if ($status) {
-
 
600
            ## Generate default target names after all source files are added
-
 
601
            ## and after we've added in all of the options from the
-
 
602
            ## command line.  If the user set exename on the command line
-
 
603
            ## and no "main" is found, sharedname will be set too and
-
 
604
            ## most templates do not handle that well.
-
 
605
            $self->generate_default_target_names();
-
 
606
 
579
            ## End of project; Write out the file.
607
            ## End of project; Write out the file.
580
            ($status, $errorString) = $self->write_project();
608
            ($status, $errorString) = $self->write_project();
581
 
609
 
582
            ## write_project() can return 0 for error, 1 for project
610
            ## write_project() can return 0 for error, 1 for project
583
            ## was written and 2 for project was skipped
611
            ## was written and 2 for project was skipped
Line 657... Line 685...
657
                $name =~ s/^\(\s*//;
685
                $name =~ s/^\(\s*//;
658
                $name =~ s/\s*\)$//;
686
                $name =~ s/\s*\)$//;
659
                $name = $self->transform_file_name($name);
687
                $name = $self->transform_file_name($name);
660
 
688
 
661
                ## Replace any *'s with the default name
689
                ## Replace any *'s with the default name
662
                if ($name =~ /\*/) {
690
                if (index($name, '*') >= 0) {
663
                  $name = $self->fill_type_name(
691
                  $name = $self->fill_type_name(
664
                                    $name,
692
                                    $name,
665
                                    $self->get_default_project_name());
693
                                    $self->get_default_project_name());
666
                }
694
                }
667
 
695
 
Line 678... Line 706...
678
          ## Signify that we have a valid project
706
          ## Signify that we have a valid project
679
          $self->{$typecheck} = 1;
707
          $self->{$typecheck} = 1;
680
        }
708
        }
681
      }
709
      }
682
    }
710
    }
683
    elsif ($values[0] eq 'assignment') {
711
    elsif ($values[0] eq '=') {
684
      my($name)  = $values[1];
712
      my($name)  = $values[1];
685
      my($value) = $values[2];
713
      my($value) = $values[2];
686
      if (defined $self->{'valid_names'}->{$name}) {
714
      if (defined $self->{'valid_names'}->{$name}) {
687
        $self->process_assignment($name, $value);
715
        $self->process_assignment($name, $value);
688
      }
716
      }
689
      else {
717
      else {
690
        $errorString = "Invalid assignment name: $name";
718
        $errorString = "Invalid assignment name: $name";
691
        $status = 0;
719
        $status = 0;
692
      }
720
      }
693
    }
721
    }
694
    elsif ($values[0] eq 'assign_add') {
722
    elsif ($values[0] eq '+=') {
695
      my($name)  = $values[1];
723
      my($name)  = $values[1];
696
      my($value) = $values[2];
724
      my($value) = $values[2];
697
      if (defined $self->{'valid_names'}->{$name}) {
725
      if (defined $self->{'valid_names'}->{$name}) {
698
        $self->process_assignment_add($name, $value);
726
        $self->process_assignment_add($name, $value);
699
      }
727
      }
700
      else {
728
      else {
701
        $errorString = "Invalid addition name: $name";
729
        $errorString = "Invalid addition name: $name";
702
        $status = 0;
730
        $status = 0;
703
      }
731
      }
704
    }
732
    }
705
    elsif ($values[0] eq 'assign_sub') {
733
    elsif ($values[0] eq '-=') {
706
      my($name)  = $values[1];
734
      my($name)  = $values[1];
707
      my($value) = $values[2];
735
      my($value) = $values[2];
708
      if (defined $self->{'valid_names'}->{$name}) {
736
      if (defined $self->{'valid_names'}->{$name}) {
709
        $self->process_assignment_sub($name, $value);
737
        $self->process_assignment_sub($name, $value);
710
      }
738
      }
Line 818... Line 846...
818
    }
846
    }
819
    else {
847
    else {
820
      $self->{'flag_overrides'}->{$tag} = $over;
848
      $self->{'flag_overrides'}->{$tag} = $over;
821
    }
849
    }
822
 
850
 
823
    if ($type eq 'assignment') {
851
    if ($type eq '=') {
824
      $self->process_assignment($name, $value, $flags);
852
      $self->process_assignment($name, $value, $flags);
825
    }
853
    }
826
    elsif ($type eq 'assign_add') {
854
    elsif ($type eq '+=') {
827
      ## If there is no value in $$flags, then we need to get
855
      ## If there is no value in $$flags, then we need to get
828
      ## the outer scope value and put it in there.
856
      ## the outer scope value and put it in there.
829
      if (!defined $self->get_assignment($name, $flags)) {
857
      if (!defined $self->get_assignment($name, $flags)) {
830
        my($outer) = $self->get_assignment($name);
858
        my($outer) = $self->get_assignment($name);
831
        $self->process_assignment($name, $outer, $flags);
859
        $self->process_assignment($name, $outer, $flags);
832
      }
860
      }
833
      $self->process_assignment_add($name, $value, $flags);
861
      $self->process_assignment_add($name, $value, $flags);
834
    }
862
    }
835
    elsif ($type eq 'assign_sub') {
863
    elsif ($type eq '-=') {
836
      ## If there is no value in $$flags, then we need to get
864
      ## If there is no value in $$flags, then we need to get
837
      ## the outer scope value and put it in there.
865
      ## the outer scope value and put it in there.
838
      if (!defined $self->get_assignment($name, $flags)) {
866
      if (!defined $self->get_assignment($name, $flags)) {
839
        my($outer) = $self->get_assignment($name);
867
        my($outer) = $self->get_assignment($name);
840
        $self->process_assignment($name, $outer, $flags);
868
        $self->process_assignment($name, $outer, $flags);
Line 863... Line 891...
863
      $self->{'addtemp_state'} = \%state;
891
      $self->{'addtemp_state'} = \%state;
864
    }
892
    }
865
 
893
 
866
    ## Now modify the addtemp values
894
    ## Now modify the addtemp values
867
    $self->information("'$values[1]' was used as a template modifier.");
895
    $self->information("'$values[1]' was used as a template modifier.");
868
    if ($values[0] eq 'assign_add') {
896
    if ($values[0] eq '+=') {
869
      $values[0] = 1;
897
      $values[0] = 1;
870
    }
898
    }
871
    elsif ($values[0] eq 'assign_sub') {
899
    elsif ($values[0] eq '-=') {
872
      $values[0] = -1;
900
      $values[0] = -1;
873
    }
901
    }
874
    else {
902
    else {
875
      $values[0] = 0;
903
      $values[0] = 0;
876
    }
904
    }
Line 936... Line 964...
936
  my($comps)   = shift;
964
  my($comps)   = shift;
937
  my($count)   = shift;
965
  my($count)   = shift;
938
  my($status)  = 1;
966
  my($status)  = 1;
939
  my($error)   = undef;
967
  my($error)   = undef;
940
  my(%exclude) = ();
968
  my(%exclude) = ();
-
 
969
  my(@values)  = ();
941
 
970
 
942
  my(@values) = ();
-
 
943
  ## If this returns true, then we've found an assignment
971
  ## If this returns true, then we've found an assignment
944
  if ($self->parse_assignment($line, \@values)) {
972
  if ($self->parse_assignment($line, \@values)) {
945
    $status = $self->parse_scoped_assignment($tag, @values, $flags);
973
    $status = $self->parse_scoped_assignment($tag, @values, $flags);
946
    if (!$status) {
974
    if (!$status) {
947
      $error = 'Unknown keyword: ' . $values[1];
975
      $error = 'Unknown keyword: ' . $values[1];
Line 958... Line 986...
958
    ## not work nor will we get the correct wild carded file list.
986
    ## not work nor will we get the correct wild carded file list.
959
    ## We also need to make sure that any back slashes are converted to
987
    ## We also need to make sure that any back slashes are converted to
960
    ## slashes to ensure that later flag_overrides checks will happen
988
    ## slashes to ensure that later flag_overrides checks will happen
961
    ## correctly.
989
    ## correctly.
962
    $line = $self->relative($line);
990
    $line = $self->relative($line);
963
    if ($self->{'convert_slashes'}) {
991
    $line =~ s/\\/\//g if ($self->{'convert_slashes'});
964
      $line =~ s/\\/\//g;
-
 
965
    }
-
 
966
 
992
 
967
    ## Now look for specially listed files
993
    ## Now look for specially listed files
-
 
994
    if ((index($line, '>>') >= 0 || index($line, '<<') >= 0) &&
968
    if ($line =~ /(.*)\s+(>>|<<)\s+(.*)/) {
995
        $line =~ /(.*)\s+(>>|<<)\s+(.*)/) {
969
      $line    = $1;
996
      $line    = $1;
970
      my($oop) = $2;
997
      my($oop) = $2;
-
 
998
      my($iop) = ($oop eq '>>' ? '<<' : '>>');
971
      my($out) = ($oop eq '>>' ? $3 : undef);
999
      my($out) = ($oop eq '>>' ? $3 : undef);
972
      my($dep) = ($oop eq '<<' ? $3 : undef);
1000
      my($dep) = ($oop eq '<<' ? $3 : undef);
973
 
1001
 
974
      $line =~ s/\s+$//;
1002
      $line =~ s/\s+$//;
975
      if ($line =~ /(.*)\s+(>>|<<)\s+(.*)/) {
1003
      if (index($line, $iop) >= 0 && $line =~ /(.*)\s+$iop\s+(.*)/) {
976
        $line = $1;
1004
        $line = $1;
977
        $out  = ($2 eq '>>' ? $3 : $out);
1005
        $out  = ($iop eq '>>' ? $2 : $out);
978
        $dep  = ($2 eq '<<' ? $3 : $dep);
1006
        $dep  = ($iop eq '<<' ? $2 : $dep);
979
 
-
 
980
        $line =~ s/\s+$//;
1007
        $line =~ s/\s+$//;
981
        if ($2 eq $oop) {
-
 
982
          $status = 0;
-
 
983
          $error  = "Duplicate $oop used";
-
 
984
        }
-
 
985
      }
1008
      }
986
 
1009
 
987
      ## Since these (custom_special_*) are used by the TemplateParser,
1010
      ## Check for both possible error conditions
988
      ## the keys need to have slashes in the target format.  So, we will
1011
      if (index($line, $oop) >= 0) {
-
 
1012
        $status = 0;
989
      ## convert slashes back to target.
1013
        $error  = "Duplicate $oop used";
990
      my($key) = $line;
1014
      }
991
      if ($self->{'convert_slashes'}) {
1015
      elsif (index($line, $iop) >= 0) {
-
 
1016
        $status = 0;
992
        $key = $self->slash_to_backslash($key);
1017
        $error  = "Duplicate $iop used";
993
      }
1018
      }
-
 
1019
 
-
 
1020
      ## Keys used internally to MPC need to be in forward slash format.
-
 
1021
      my($key) = $line;
-
 
1022
      $key =~ s/\\/\//g if ($self->{'convert_slashes'});
994
      if (defined $out) {
1023
      if (defined $out) {
995
        if (!defined $self->{'custom_special_output'}->{$tag}) {
1024
        if (!defined $self->{'custom_special_output'}->{$tag}) {
996
          $self->{'custom_special_output'}->{$tag} = {};
1025
          $self->{'custom_special_output'}->{$tag} = {};
997
        }
1026
        }
998
        $self->{'custom_special_output'}->{$tag}->{$key} = $self->create_array($out);
1027
        $self->{'custom_special_output'}->{$tag}->{$key} = $self->create_array($out);
Line 1155... Line 1184...
1155
    my($line) = $self->preprocess_line($fh, $_);
1184
    my($line) = $self->preprocess_line($fh, $_);
1156
 
1185
 
1157
    if ($line eq '') {
1186
    if ($line eq '') {
1158
    }
1187
    }
1159
    elsif ($line =~ /^(\w+)\s*{$/) {
1188
    elsif ($line =~ /^(\w+)\s*{$/) {
1160
      if (!defined $current || !$set) {
1189
      if (!$set) {
1161
        $current = $1;
1190
        $current = $1;
1162
        $set = 1;
1191
        $set = 1;
1163
        if (!defined $$comps{$current}) {
1192
        if (!defined $$comps{$current}) {
1164
          $$comps{$current} = [];
1193
          $$comps{$current} = [];
1165
        }
1194
        }
Line 1178... Line 1207...
1178
      if (!$status) {
1207
      if (!$status) {
1179
        last;
1208
        last;
1180
      }
1209
      }
1181
    }
1210
    }
1182
    elsif ($line =~ /^}$/) {
1211
    elsif ($line =~ /^}$/) {
1183
      if (defined $current) {
-
 
1184
        if (!defined $$comps{$current}->[0] && !defined $exclude[0]) {
1212
      if (!defined $$comps{$current}->[0] && !defined $exclude[0]) {
1185
          ## The default components name was never used
1213
        ## The default components name was never used
1186
          ## so we remove it from the components
1214
        ## so we remove it from the components
1187
          delete $$comps{$current};
1215
        delete $$comps{$current};
1188
        }
1216
      }
1189
        else {
1217
      else {
1190
          ## It was used, so we need to add that name to
1218
        ## It was used, so we need to add that name to
1191
          ## the set of group names unless it's already been added.
1219
        ## the set of group names unless it's already been added.
1192
          my($groups)   = $self->get_assignment($grtag);
-
 
1193
          my($addgroup) = 1;
-
 
1194
          if (defined $groups) {
-
 
1195
            foreach my $group (@{$self->create_array($groups)}) {
-
 
1196
              if ($current eq $group) {
-
 
1197
                $addgroup = 0;
-
 
1198
                last;
-
 
1199
              }
-
 
1200
            }
-
 
1201
          }
-
 
1202
          if ($addgroup) {
-
 
1203
            $self->process_assignment_add($grtag, $current);
1220
        $self->process_assignment_add($grtag, $current);
1204
          }
-
 
1205
        }
-
 
1206
      }
1221
      }
1207
      if (defined $current && $set) {
1222
      if ($set) {
1208
        $current = $defgroup;
1223
        $current = $defgroup;
1209
        $set = undef;
1224
        $set = undef;
1210
      }
1225
      }
1211
      else {
1226
      else {
1212
        ## We are at the end of a component.  If the only group
1227
        ## We are at the end of a component.  If the only group
1213
        ## we added was the default group, then we need to remove
1228
        ## we added was the default group, then we need to remove
1214
        ## the group setting altogether.
1229
        ## the group setting altogether.
1215
        my($groups) = $self->get_assignment($grtag);
1230
        my($groups) = $self->get_assignment($grtag);
1216
        if (defined $groups) {
1231
        if (defined $groups) {
1217
          my(@grarray) = @{$self->create_array($groups)};
1232
          my($grarray) = $self->create_array($groups);
1218
          if ($#grarray == 0 && $grarray[0] eq $defgroup) {
1233
          if (scalar(@$grarray) == 1 && $$grarray[0] eq $defgroup) {
1219
            $self->process_assignment($grtag, undef);
1234
            $self->process_assignment($grtag, undef);
1220
          }
1235
          }
1221
        }
1236
        }
1222
 
1237
 
1223
        ## This is not an error,
1238
        ## This is not an error,
1224
        ## this is the end of the components
1239
        ## this is the end of the components
1225
        last;
1240
        last;
1226
      }
1241
      }
1227
    }
1242
    }
1228
    elsif (defined $current) {
1243
    else {
1229
      ($status, $error) = $self->process_component_line($tag, $line, \%flags,
1244
      ($status, $error) = $self->process_component_line($tag, $line, \%flags,
1230
                                                        \$grname, $current,
1245
                                                        \$grname, $current,
1231
                                                        \@exclude, $comps,
1246
                                                        \@exclude, $comps,
1232
                                                        \$count);
1247
                                                        \$count);
1233
      if (!$status) {
1248
      if (!$status) {
1234
        last;
1249
        last;
1235
      }
1250
      }
1236
    }
1251
    }
1237
    else {
-
 
1238
      $status = 0;
-
 
1239
      $error  = 'Syntax error';
-
 
1240
      last;
-
 
1241
    }
-
 
1242
  }
1252
  }
1243
 
1253
 
1244
  ## If we didn't encounter an error, didn't have any files explicitly
1254
  ## If we didn't encounter an error, didn't have any files explicitly
1245
  ## listed and we attempted to exclude files, then we need to find the
1255
  ## listed and we attempted to exclude files, then we need to find the
1246
  ## set of files that don't match the excluded files and add them.
1256
  ## set of files that don't match the excluded files and add them.
1247
  if ($status && $#exclude != -1 && defined $grname) {
1257
  if ($status && defined $exclude[0] && defined $grname) {
1248
    my($alldir)  = $self->get_assignment('recurse') || $flags{'recurse'};
1258
    my($alldir)  = $self->get_assignment('recurse') || $flags{'recurse'};
1249
    my(%checked) = ();
1259
    my(%checked) = ();
1250
    my(@files)   = ();
1260
    my(@files)   = ();
1251
    foreach my $exc (@exclude) {
1261
    foreach my $exc (@exclude) {
1252
      my($dname) = $self->mpc_dirname($exc);
1262
      my($dname) = $self->mpc_dirname($exc);
1253
      if (!defined $checked{$dname}) {
1263
      if (!defined $checked{$dname}) {
1254
        $checked{$dname} = 1;
1264
        $checked{$dname} = 1;
1255
        push(@files, $self->generate_default_file_list($dname,
1265
        push(@files, $self->generate_default_file_list($dname,
-
 
1266
                                                       \@exclude,
1256
                                                       \@exclude, $alldir));
1267
                                                       undef, $alldir));
1257
      }
1268
      }
1258
    }
1269
    }
1259
 
1270
 
1260
    $self->sift_files(\@files,
1271
    $self->sift_files(\@files,
1261
                      $self->{'valid_components'}->{$tag},
1272
                      $self->{'valid_components'}->{$tag},
Line 1372... Line 1383...
1372
  my($self)  = shift;
1383
  my($self)  = shift;
1373
  my($aref)  = shift;
1384
  my($aref)  = shift;
1374
  my($type)  = shift;
1385
  my($type)  = shift;
1375
  my($array) = shift;
1386
  my($array) = shift;
1376
 
1387
 
1377
  if (!defined $$aref || $type eq 'assignment') {
1388
  if (!defined $$aref || $type eq '=') {
1378
    if ($type ne 'assign_sub') {
1389
    if ($type ne '-=') {
1379
      $$aref = $array;
1390
      $$aref = $array;
1380
    }
1391
    }
1381
  }
1392
  }
1382
  else {
1393
  else {
1383
    if ($type eq 'assign_add') {
1394
    if ($type eq '+=') {
1384
      push(@{$$aref}, @$array);
1395
      push(@{$$aref}, @$array);
1385
    }
1396
    }
1386
    elsif ($type eq 'assign_sub') {
1397
    elsif ($type eq '-=') {
1387
      my($count) = scalar(@{$$aref});
1398
      my($count) = scalar(@{$$aref});
1388
      for(my $i = 0; $i < $count; ++$i) {
1399
      for(my $i = 0; $i < $count; ++$i) {
1389
        foreach my $val (@$array) {
1400
        foreach my $val (@$array) {
1390
          if ($$aref->[$i] eq $val) {
1401
          if ($$aref->[$i] eq $val) {
1391
            splice(@{$$aref}, $i, 1);
1402
            splice(@{$$aref}, $i, 1);
Line 1542... Line 1553...
1542
              }
1553
              }
1543
              ## Try to convert the value into a relative path
1554
              ## Try to convert the value into a relative path
1544
              $value = $self->relative($value);
1555
              $value = $self->relative($value);
1545
 
1556
 
1546
              if (($customDefined{$name} & 0x04) != 0) {
1557
              if (($customDefined{$name} & 0x04) != 0) {
1547
                if ($type eq 'assignment') {
1558
                if ($type eq '=') {
1548
                  $self->process_assignment(
1559
                  $self->process_assignment(
1549
                                     $name, $value,
1560
                                     $name, $value,
1550
                                     $self->{'generated_exts'}->{$tag});
1561
                                     $self->{'generated_exts'}->{$tag});
1551
                }
1562
                }
1552
                elsif ($type eq 'assign_add') {
1563
                elsif ($type eq '+=') {
1553
                  $self->process_assignment_add(
1564
                  $self->process_assignment_add(
1554
                                     $name, $value,
1565
                                     $name, $value,
1555
                                     $self->{'generated_exts'}->{$tag});
1566
                                     $self->{'generated_exts'}->{$tag});
1556
                }
1567
                }
1557
                elsif ($type eq 'assign_sub') {
1568
                elsif ($type eq '-=') {
1558
                  $self->process_assignment_sub(
1569
                  $self->process_assignment_sub(
1559
                                     $name, $value,
1570
                                     $name, $value,
1560
                                     $self->{'generated_exts'}->{$tag});
1571
                                     $self->{'generated_exts'}->{$tag});
1561
                }
1572
                }
1562
              }
1573
              }
Line 1635... Line 1646...
1635
  return $status, $errorString;
1646
  return $status, $errorString;
1636
}
1647
}
1637
 
1648
 
1638
 
1649
 
1639
sub remove_duplicate_addition {
1650
sub remove_duplicate_addition {
1640
  my($self)    = shift;
1651
  my($self)  = shift;
1641
  my($name)    = shift;
1652
  my($name)  = shift;
1642
  my($value)   = shift;
1653
  my($value) = shift;
1643
  my($nval)    = shift;
1654
  my($nval)  = shift;
1644
 
1655
 
-
 
1656
  if (defined $nval) {
1645
  ## If we are modifying the libs, libpaths, macros or includes
1657
    ## If we are modifying the libs, libpaths, macros or includes
1646
  ## assignment with either addition or subtraction, we are going to
1658
    ## assignment with either addition or subtraction, we are going to
1647
  ## perform a little fix on the value to avoid multiple
1659
    ## perform a little fix on the value to avoid multiple
1648
  ## libraries and to try to insure the correct linking order
1660
    ## libraries and to try to insure the correct linking order
1649
  if ($name eq 'macros'   ||
1661
    if ($name eq 'macros' || $name eq 'libpaths' ||
1650
      $name eq 'libpaths' || $name eq 'includes' || $name =~ /libs$/) {
1662
        $name eq 'includes' || $name =~ /libs$/ ||
1651
    if (defined $nval) {
1663
        index($name, $grouped_key) == 0) {
1652
      my($allowed) = '';
1664
      my($allowed) = '';
1653
      my(%parts)   = ();
1665
      my(%parts)   = ();
1654
 
1666
 
1655
      ## Convert the array into keys for a hash table
1667
      ## Convert the array into keys for a hash table
1656
      @parts{@{$self->create_array($nval)}} = ();
1668
      @parts{@{$self->create_array($nval)}} = ();
Line 1748... Line 1760...
1748
        $errorString = 'Unable to locate template input file.';
1760
        $errorString = 'Unable to locate template input file.';
1749
      }
1761
      }
1750
    }
1762
    }
1751
  }
1763
  }
1752
 
1764
 
-
 
1765
  if ($status && defined $self->{$tag}) {
-
 
1766
    ## Put the features into the template input set
-
 
1767
    my($features) = $self->{'feature_parser'}->get_names();
-
 
1768
    $self->{$tag}->parse_line(undef, "features = @$features");
-
 
1769
  }
-
 
1770
 
1753
  return $status, $errorString;
1771
  return $status, $errorString;
1754
}
1772
}
1755
 
1773
 
1756
 
1774
 
1757
sub already_added {
1775
sub already_added {
1758
  my($self)  = shift;
1776
  my($self)  = shift;
1759
  my($array) = shift;
1777
  my($array) = shift;
1760
  my($name)  = shift;
1778
  my($name)  = shift;
1761
 
1779
 
1762
  ## This method expects that the file
1780
  ## This method expects that the file name will be unix style
1763
  ## name will be unix style
-
 
1764
  $name =~ s/\\/\//g;
1781
  $name =~ s/\\/\//g if ($self->{'convert_slashes'});
1765
 
1782
 
1766
  foreach my $file (@$array) {
1783
  ## Remove the leading ./
1767
    if ($file eq $name) {
1784
  $name =~ s/^\.\///;
1768
      return 1;
1785
  my($dsname) = "./$name";
1769
    }
-
 
1770
  }
-
 
1771
 
1786
 
1772
  ## If we haven't matched the name yet and the name
-
 
1773
  ## begins with ./, we will remove it and try again.
-
 
1774
  if ($name =~ s/^\.\///) {
1787
  foreach my $file (@$array) {
1775
    return $self->already_added($array, $name);
1788
    return 1 if ($file eq $name || $file eq $dsname);
1776
  }
1789
  }
1777
 
1790
 
1778
  return 0;
1791
  return 0;
1779
}
1792
}
1780
 
1793
 
Line 1817... Line 1830...
1817
  my($self)   = shift;
1830
  my($self)   = shift;
1818
  my($opt)    = shift;
1831
  my($opt)    = shift;
1819
  my($value)  = shift;
1832
  my($value)  = shift;
1820
  my($status) = undef;
1833
  my($status) = undef;
1821
  my(@parts)  = grep(!/^$/, split(/\s+/, $opt));
1834
  my(@parts)  = grep(!/^$/, split(/\s+/, $opt));
-
 
1835
  my($pcount) = scalar(@parts);
1822
 
1836
 
1823
  for(my $i = 0; $i <= $#parts; $i++) {
1837
  for(my $i = 0; $i < $pcount; $i++) {
1824
    if ($parts[$i] eq '&&' || $parts[$i] eq '||') {
1838
    if ($parts[$i] eq '&&' || $parts[$i] eq '||') {
1825
      if (defined $status) {
1839
      if (defined $status) {
1826
        if (defined $parts[$i + 1]) {
1840
        if (defined $parts[$i + 1]) {
1827
          if ($parts[$i] eq '&&') {
1841
          if ($parts[$i] eq '&&') {
1828
            $status &&= $self->evaluate_optional_option($parts[$i + 1],
1842
            $status &&= $self->evaluate_optional_option($parts[$i + 1],
Line 1908... Line 1922...
1908
                                         $file, \@additional);
1922
                                         $file, \@additional);
1909
  }
1923
  }
1910
 
1924
 
1911
  ## If the current array only has the default,
1925
  ## If the current array only has the default,
1912
  ## then we need to remove it
1926
  ## then we need to remove it
1913
  if ($#additional >= 0) {
1927
  if (defined $additional[0]) {
1914
    if ($#array == 0 && $array[0] eq '') {
1928
    if ($#array == 0 && $array[0] eq '') {
1915
      pop(@array);
1929
      pop(@array);
1916
    }
1930
    }
1917
    push(@array, @additional);
1931
    push(@array, @additional);
1918
  }
1932
  }
1919
 
1933
 
1920
  return @array;
1934
  return @array;
1921
}
1935
}
1922
 
1936
 
1923
 
1937
 
-
 
1938
sub add_explicit_output {
-
 
1939
  my($self)  = shift;
-
 
1940
  my($file)  = shift;
-
 
1941
  my($type)  = shift;
-
 
1942
  my($tag)   = shift;
-
 
1943
  my($array) = shift;
-
 
1944
 
-
 
1945
  if (defined $self->{'valid_components'}->{$tag} &&
-
 
1946
      defined $self->{'custom_special_output'}->{$type} &&
-
 
1947
      defined $self->{'custom_special_output'}->{$type}->{$file}) {
-
 
1948
    my(@files) = ();
-
 
1949
    foreach my $check (@{$self->{'custom_special_output'}->{$type}->{$file}}) {
-
 
1950
      foreach my $regext (@{$self->{'valid_components'}->{$tag}}) {
-
 
1951
        if ($check =~ /$regext$/) {
-
 
1952
          my($add) = 1;
-
 
1953
          if ($tag eq 'source_files') {
-
 
1954
            foreach my $tregext (@{$self->{'valid_components'}->{'template_files'}}) {
-
 
1955
              if ($check =~ /$tregext$/) {
-
 
1956
                $add = undef;
-
 
1957
                last;
-
 
1958
              }
-
 
1959
            }
-
 
1960
          }
-
 
1961
          if ($add) {
-
 
1962
            ## If gendir was specified, then we need to account for that
-
 
1963
            my($dir) = '';
-
 
1964
            if (defined $self->{'flag_overrides'}->{$type} &&
-
 
1965
                defined $self->{'flag_overrides'}->{$type}->{$file} &&
-
 
1966
                defined $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'}) {
-
 
1967
              if ($self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} eq '.') {
-
 
1968
                $dir = '';
-
 
1969
              }
-
 
1970
              else {
-
 
1971
                $dir = $self->{'flag_overrides'}->{$type}->{$file}->{'gendir'} . '/';
-
 
1972
              }
-
 
1973
            }
-
 
1974
 
-
 
1975
            push(@files, "$dir$check");
-
 
1976
            last;
-
 
1977
          }
-
 
1978
        }
-
 
1979
      }
-
 
1980
    }
-
 
1981
    if (defined $files[0]) {
-
 
1982
      push(@$array, \@files);
-
 
1983
    }
-
 
1984
  }
-
 
1985
}
-
 
1986
 
1924
sub generated_filename_arrays {
1987
sub generated_filename_arrays {
1925
  my($self)  = shift;
1988
  my($self)  = shift;
1926
  my($part)  = shift;
1989
  my($part)  = shift;
1927
  my($type)  = shift;
1990
  my($type)  = shift;
1928
  my($tag)   = shift;
1991
  my($tag)   = shift;
1929
  my($file)  = shift;
1992
  my($file)  = shift;
1930
  my($rmesc) = shift;
-
 
1931
  my($noext) = shift;
1993
  my($noext) = shift;
1932
  my(@array) = ();
1994
  my(@array) = ();
1933
  my(@pearr) = $self->get_pre_keyword_array('pre_extension',
1995
  my(@pearr) = $self->get_pre_keyword_array('pre_extension',
1934
                                            $type, $tag, $file);
1996
                                            $type, $tag, $file);
1935
  my(@pfarr) = $self->get_pre_keyword_array('pre_filename',
1997
  my(@pfarr) = $self->get_pre_keyword_array('pre_filename',
1936
                                            $type, $tag, $file);
1998
                                            $type, $tag, $file);
1937
  my(@exts)  = (defined $self->{'generated_exts'}->{$type}->{$tag} ?
1999
  my(@exts)  = (defined $self->{'generated_exts'}->{$type}->{$tag} ?
1938
                  @{$self->{'generated_exts'}->{$type}->{$tag}} : ());
2000
                  @{$self->{'generated_exts'}->{$type}->{$tag}} : ());
1939
 
2001
 
1940
  if ($#exts == -1) {
2002
  if (!defined $exts[0]) {
1941
    my($backtag) = $tag;
2003
    my($backtag) = $tag;
1942
    if ($backtag =~ s/files$/outputext/) {
2004
    if ($backtag =~ s/files$/outputext/) {
1943
      $self->add_optional_filename_portion($type, $backtag,
2005
      $self->add_optional_filename_portion($type, $backtag,
1944
                                           $file, \@exts);
2006
                                           $file, \@exts);
1945
    }
2007
    }
1946
  }
2008
  }
1947
 
2009
 
1948
  if ($#pearr == 0 && $#pfarr == 0 && $#exts == -1 &&
2010
  if (!defined $exts[0] && $#pearr == 0 && $#pfarr == 0 &&
1949
      $pearr[0] eq '' && $pfarr[0] eq '') {
2011
      $pearr[0] eq '' && $pfarr[0] eq '') {
1950
    ## If both arrays are defined to be the defaults, then there
2012
    ## If both arrays are defined to be the defaults, then there
1951
    ## is nothing for us to do.
2013
    ## is nothing for us to do.
1952
  }
2014
  }
1953
  else {
2015
  else {
Line 1976... Line 2038...
1976
    }
2038
    }
1977
 
2039
 
1978
    ## Loop through creating all of the possible file names
2040
    ## Loop through creating all of the possible file names
1979
    foreach my $pe (@pearr) {
2041
    foreach my $pe (@pearr) {
1980
      push(@array, []);
2042
      push(@array, []);
1981
      if ($rmesc) {
-
 
1982
        $pe =~ s/\\\././g;
2043
      $pe =~ s/\\\././g;
1983
      }
-
 
1984
      foreach my $pf (@pfarr) {
2044
      foreach my $pf (@pfarr) {
1985
        if ($rmesc) {
-
 
1986
          $pf =~ s/\\\././g;
2045
        $pf =~ s/\\\././g;
1987
        }
-
 
1988
        if ($noext) {
2046
        if ($noext) {
1989
          push(@{$array[$#array]}, "$dir$pf$base$pe");
2047
          push(@{$array[$#array]}, "$dir$pf$base$pe");
1990
        }
2048
        }
1991
        else {
2049
        else {
1992
          foreach my $ext (@exts) {
2050
          foreach my $ext (@exts) {
1993
            if ($rmesc) {
-
 
1994
              $ext =~ s/\\\././g;
2051
            $ext =~ s/\\\././g;
1995
            }
-
 
1996
            push(@{$array[$#array]}, "$dir$pf$base$pe$ext");
2052
            push(@{$array[$#array]}, "$dir$pf$base$pe$ext");
1997
          }
2053
          }
1998
        }
2054
        }
1999
      }
2055
      }
2000
    }
2056
    }
2001
  }
2057
  }
2002
 
2058
 
-
 
2059
  $self->add_explicit_output($file, $type, $tag, \@array);
2003
  return @array;
2060
  return @array;
2004
}
2061
}
2005
 
2062
 
2006
 
2063
 
2007
sub generated_filenames {
2064
sub generated_filenames {
2008
  my($self)  = shift;
2065
  my($self)  = shift;
2009
  my($part)  = shift;
-
 
2010
  my($type)  = shift;
-
 
2011
  my($tag)   = shift;
-
 
2012
  my($file)  = shift;
-
 
2013
  my($rmesc) = shift;
-
 
2014
  my($noext) = shift;
-
 
2015
  my(@files) = ();
2066
  my(@files) = ();
2016
  my(@array) = $self->generated_filename_arrays($part, $type, $tag,
-
 
2017
                                                $file, $rmesc, $noext);
-
 
2018
 
2067
 
2019
  foreach my $array (@array) {
2068
  foreach my $array ($self->generated_filename_arrays(@_)) {
2020
    push(@files, @$array);
2069
    push(@files, @$array);
2021
  }
2070
  }
2022
 
2071
 
2023
  return @files;
2072
  return @files;
2024
}
2073
}
Line 2048... Line 2097...
2048
 
2097
 
2049
  ## Get the generated filenames
2098
  ## Get the generated filenames
2050
  my(@added) = ();
2099
  my(@added) = ();
2051
  foreach my $file (@$arr) {
2100
  foreach my $file (@$arr) {
2052
    foreach my $gen ($self->generated_filenames($file, $gentype, $tag,
2101
    foreach my $gen ($self->generated_filenames($file, $gentype, $tag,
2053
                                                "$file$wanted", 1, 1)) {
2102
                                                "$file$wanted", 1)) {
2054
      $self->list_generated_file($gentype, $tag, \@added, $gen, $file);
2103
      $self->list_generated_file($gentype, $tag, \@added, $gen, $file);
2055
    }
2104
    }
2056
  }
2105
  }
2057
 
2106
 
2058
  if ($#added >= 0) {
2107
  if (defined $added[0]) {
2059
    my($names) = $self->{$tag};
2108
    my($names) = $self->{$tag};
2060
 
2109
 
2061
    ## Get all files in one list and save the directory
2110
    ## Get all files in one list and save the directory
2062
    ## and component group in a hashed array.
2111
    ## and component group in a hashed array.
2063
    my(@all) = ();
2112
    my(@all) = ();
Line 2081... Line 2130...
2081
      }
2130
      }
2082
    }
2131
    }
2083
 
2132
 
2084
    ## If we have files to add, make sure we add them to a group
2133
    ## If we have files to add, make sure we add them to a group
2085
    ## that has the same directory location as the files we're adding.
2134
    ## that has the same directory location as the files we're adding.
2086
    if ($#oktoadd >= 0) {
2135
    if (defined $oktoadd[0]) {
2087
      my($key) = (defined $group ? $group :
2136
      my($key) = (defined $group ? $group :
2088
                          $dircomp{$self->mpc_dirname($oktoadd[0])});
2137
                          $dircomp{$self->mpc_dirname($oktoadd[0])});
2089
      if (!defined $key) {
2138
      if (!defined $key) {
2090
        my($check) = $oktoadd[0];
2139
        my($check) = $oktoadd[0];
2091
        foreach my $regext (@{$self->{'valid_components'}->{$tag}}) {
2140
        foreach my $regext (@{$self->{'valid_components'}->{$tag}}) {
Line 2149... Line 2198...
2149
  if (open($fh, $file)) {
2198
  if (open($fh, $file)) {
2150
    my($poundifed) = 0;
2199
    my($poundifed) = 0;
2151
    my($commented) = 0;
2200
    my($commented) = 0;
2152
 
2201
 
2153
    while(<$fh>) {
2202
    while(<$fh>) {
2154
      if (!$preproc || !$commented) {
2203
      if (!$commented) {
2155
        ## Remove c++ style comments
2204
        ## Remove c++ style comments
2156
        $_ =~ s/\/\/.*//;
2205
        $_ =~ s/\/\/.*//;
2157
      }
2206
      }
2158
 
2207
 
2159
      ## If the current language supports a c preprocessor, we
-
 
2160
      ## will perform a minimal check for #if 0 and c style comments.
-
 
2161
      if ($preproc) {
-
 
2162
        ## Remove one line c style comments
2208
      ## Remove one line c style comments
2163
        $_ =~ s/\/\*.*\*\///g;
2209
      $_ =~ s/\/\*.*\*\///g;
2164
 
2210
 
2165
        if ($commented) {
2211
      if ($commented) {
2166
          if (/\*\//) {
2212
        if (/\*\//) {
2167
            ## Found the end of a multi-line c style comment
2213
          ## Found the end of a multi-line c style comment
2168
            --$commented;
2214
          --$commented;
2169
          }
-
 
2170
        }
2215
        }
-
 
2216
      }
2171
        else {
2217
      else {
2172
          if (/\/\*/) {
2218
        if (/\/\*/) {
2173
            ## Found the beginning of a multi-line c style comment
2219
          ## Found the beginning of a multi-line c style comment
2174
            ++$commented;
2220
          ++$commented;
2175
          }
2221
        }
-
 
2222
        elsif ($preproc) {
-
 
2223
          ## If the current language supports a c preprocessor, we
-
 
2224
          ## will perform a minimal check for #if 0
2176
          elsif (/#\s*if\s+0/) {
2225
          if (/#\s*if\s+0/) {
2177
            ## Found the beginning of a #if 0
2226
            ## Found the beginning of a #if 0
2178
            ++$poundifed;
2227
            ++$poundifed;
2179
          }
2228
          }
2180
          elsif ($poundifed) {
2229
          elsif ($poundifed) {
2181
            if (/#\s*if/) {
2230
            if (/#\s*if/) {
Line 2195... Line 2244...
2195
      ## Check for main; Make sure it's not #if 0'ed and not commented out
2244
      ## Check for main; Make sure it's not #if 0'ed and not commented out
2196
      if (!$poundifed && !$commented &&
2245
      if (!$poundifed && !$commented &&
2197
          (/\s+$main\s*\(/ || /^\s*$main\s*\(/)) {
2246
          (/\s+$main\s*\(/ || /^\s*$main\s*\(/)) {
2198
        ## If we've found a main, set the exename to the basename
2247
        ## If we've found a main, set the exename to the basename
2199
        ## of the cpp file with the extension removed
2248
        ## of the cpp file with the extension removed
2200
        $name = basename($file);
2249
        $name = $self->mpc_basename($file);
2201
        $name =~ s/\.[^\.]+$//;
2250
        $name =~ s/\.[^\.]+$//;
2202
        last;
2251
        last;
2203
      }
2252
      }
2204
    }
2253
    }
2205
    close($fh);
2254
    close($fh);
Line 2251... Line 2300...
2251
      }
2300
      }
2252
 
2301
 
2253
      ## If we still don't have a project type, then we will
2302
      ## If we still don't have a project type, then we will
2254
      ## default to a library if there are source or resource files
2303
      ## default to a library if there are source or resource files
2255
      if (!defined $exename) {
2304
      if (!defined $exename) {
2256
        if ($#sources < 0) {
2305
        if (!defined $sources[0]) {
2257
          @sources = $self->get_component_list('resource_files', 1);
2306
          @sources = $self->get_component_list('resource_files', 1);
2258
        }
2307
        }
2259
        if ($#sources >= 0) {
2308
        if (defined $sources[0]) {
2260
          if (!$shared_empty) {
2309
          if (!$shared_empty) {
2261
            $self->process_assignment('sharedname',
2310
            $self->process_assignment('sharedname',
2262
                                      $self->{'unmodified_project_name'});
2311
                                      $self->{'unmodified_project_name'});
2263
          }
2312
          }
2264
          $self->process_assignment('staticname',
2313
          $self->process_assignment('staticname',
Line 2279... Line 2328...
2279
  }
2328
  }
2280
 
2329
 
2281
  ## Check for the use of an asterisk in the name
2330
  ## Check for the use of an asterisk in the name
2282
  foreach my $key ('exename', 'sharedname', 'staticname') {
2331
  foreach my $key ('exename', 'sharedname', 'staticname') {
2283
    my($value) = $self->get_assignment($key);
2332
    my($value) = $self->get_assignment($key);
2284
    if (defined $value && $value =~ /\*/) {
2333
    if (defined $value && index($value, '*') >= 0) {
2285
      $value = $self->fill_type_name($value,
2334
      $value = $self->fill_type_name($value,
2286
                                     $self->{'unmodified_project_name'});
2335
                                     $self->{'unmodified_project_name'});
2287
      $self->process_assignment($key, $value);
2336
      $self->process_assignment($key, $value);
2288
    }
2337
    }
2289
  }
2338
  }
Line 2295... Line 2344...
2295
  my($files)   = shift;
2344
  my($files)   = shift;
2296
  my($pchhdef) = (defined $self->get_assignment('pch_header'));
2345
  my($pchhdef) = (defined $self->get_assignment('pch_header'));
2297
  my($pchcdef) = (defined $self->get_assignment('pch_source'));
2346
  my($pchcdef) = (defined $self->get_assignment('pch_source'));
2298
 
2347
 
2299
  if (!$pchhdef || !$pchcdef) {
2348
  if (!$pchhdef || !$pchcdef) {
2300
    my($pname)     = $self->escape_regex_special(
-
 
2301
                             $self->get_assignment('project_name'));
2349
    my($pname)     = $self->get_assignment('project_name');
2302
    my($hcount)    = 0;
2350
    my($hcount)    = 0;
2303
    my($ccount)    = 0;
2351
    my($ccount)    = 0;
2304
    my($hmatching) = undef;
2352
    my($hmatching) = undef;
2305
    my($cmatching) = undef;
2353
    my($cmatching) = undef;
2306
    foreach my $file (@$files) {
2354
    foreach my $file (@$files) {
2307
      ## If the file doesn't even contain _pch, then there's no point
2355
      ## If the file doesn't even contain _pch, then there's no point
2308
      ## in looping through all of the extensions
2356
      ## in looping through all of the extensions
2309
      if ($file =~ /_pch/) {
2357
      if (index($file, '_pch') >= 0) {
2310
        if (!$pchhdef) {
2358
        if (!$pchhdef) {
2311
          foreach my $ext (@{$self->{'valid_components'}->{'header_files'}}) {
2359
          foreach my $ext (@{$self->{'valid_components'}->{'header_files'}}) {
2312
            if ($file =~ /(.*_pch$ext)$/) {
2360
            if ($file =~ /(.*_pch$ext)$/) {
2313
              $self->process_assignment('pch_header', $1);
2361
              $self->process_assignment('pch_header', $1);
2314
              ++$hcount;
2362
              ++$hcount;
2315
              if ($file =~ /$pname/) {
2363
              if (index($file, $pname) >= 0) {
2316
                $hmatching = $file;
2364
                $hmatching = $file;
2317
              }
2365
              }
2318
              last;
2366
              last;
2319
            }
2367
            }
2320
          }
2368
          }
Line 2322... Line 2370...
2322
        if (!$pchcdef) {
2370
        if (!$pchcdef) {
2323
          foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
2371
          foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
2324
            if ($file =~ /(.*_pch$ext)$/) {
2372
            if ($file =~ /(.*_pch$ext)$/) {
2325
              $self->process_assignment('pch_source', $1);
2373
              $self->process_assignment('pch_source', $1);
2326
              ++$ccount;
2374
              ++$ccount;
2327
              if ($file =~ /$pname/) {
2375
              if (index($file, $pname) >= 0) {
2328
                $cmatching = $file;
2376
                $cmatching = $file;
2329
              }
2377
              }
2330
              last;
2378
              last;
2331
            }
2379
            }
2332
          }
2380
          }
Line 2357... Line 2405...
2357
sub remove_extra_pch_listings {
2405
sub remove_extra_pch_listings {
2358
  my($self) = shift;
2406
  my($self) = shift;
2359
  my(@pchs) = ('pch_header', 'pch_source');
2407
  my(@pchs) = ('pch_header', 'pch_source');
2360
  my(@tags) = ('header_files', 'source_files');
2408
  my(@tags) = ('header_files', 'source_files');
2361
 
2409
 
2362
  for(my $j = 0; $j <= $#pchs; ++$j) {
2410
  for(my $j = 0; $j < 2; ++$j) {
2363
    my($pch) = $self->get_assignment($pchs[$j]);
2411
    my($pch) = $self->get_assignment($pchs[$j]);
2364
 
2412
 
2365
    if (defined $pch) {
2413
    if (defined $pch) {
2366
      ## If we are converting slashes, then we need to
2414
      ## If we are converting slashes, then we need to
2367
      ## convert the pch file back to forward slashes
2415
      ## convert the pch file back to forward slashes
2368
      if ($self->{'convert_slashes'}) {
2416
      $pch =~ s/\\/\//g if ($self->{'convert_slashes'});
2369
        $pch =~ s/\\/\//g;
-
 
2370
      }
-
 
2371
 
2417
 
2372
      ## Find out which files are duplicated
2418
      ## Find out which files are duplicated
2373
      my($names) = $self->{$tags[$j]};
2419
      my($names) = $self->{$tags[$j]};
2374
      foreach my $name (keys %$names) {
2420
      foreach my $name (keys %$names) {
2375
        my($comps) = $$names{$name};
2421
        my($comps) = $$names{$name};
Line 2398... Line 2444...
2398
  my($tag)    = shift;
2444
  my($tag)    = shift;
2399
  my($array)  = shift;
2445
  my($array)  = shift;
2400
  my($alldir) = shift;
2446
  my($alldir) = shift;
2401
  my(@saved)  = ();
2447
  my(@saved)  = ();
2402
  my($ec)     = $self->{'exclude_components'};
2448
  my($ec)     = $self->{'exclude_components'};
-
 
2449
  my($havec)  = (defined $$ec{$tag});
2403
 
2450
 
2404
  foreach my $file (@$files) {
2451
  foreach my $file (@$files) {
2405
    foreach my $ext (@$exts) {
2452
    foreach my $ext (@$exts) {
2406
      ## Always exclude the precompiled header and cpp
2453
      ## Always exclude the precompiled header and cpp
2407
      if ($file =~ /$ext$/ && (!defined $pchh || $file ne $pchh) &&
2454
      if ($file =~ /$ext$/ && (!defined $pchh || $file ne $pchh) &&
2408
                              (!defined $pchc || $file ne $pchc)) {
2455
                              (!defined $pchc || $file ne $pchc)) {
2409
        my($exclude) = 0;
2456
        if ($havec) {
2410
        if (defined $$ec{$tag}) {
2457
          my($exclude) = 0;
2411
          foreach my $exc (@{$$ec{$tag}}) {
2458
          foreach my $exc (@{$$ec{$tag}}) {
2412
            if ($file =~ /$exc$/) {
2459
            if ($file =~ /$exc$/) {
2413
              $exclude = 1;
2460
              $exclude = 1;
2414
              last;
2461
              last;
2415
            }
2462
            }
2416
          }
2463
          }
-
 
2464
          last if ($exclude);
2417
        }
2465
        }
2418
        elsif (!$alldir && $tag eq 'resource_files') {
2466
        elsif (!$alldir && $tag eq 'resource_files') {
2419
          ## Save these files for later.  There may
2467
          ## Save these files for later.  There may
2420
          ## be more than one and we want to try and
2468
          ## be more than one and we want to try and
2421
          ## find the one that corresponds to this project
2469
          ## find the one that corresponds to this project
2422
          $exclude = 1;
-
 
2423
          push(@saved, $file);
2470
          push(@saved, $file);
-
 
2471
          last;
2424
        }
2472
        }
2425
 
2473
 
2426
        if (!$exclude && !$self->already_added($array, $file)) {
2474
        if (!$self->already_added($array, $file)) {
2427
          push(@$array, $file);
2475
          push(@$array, $file);
2428
        }
2476
        }
2429
        last;
2477
        last;
2430
      }
2478
      }
2431
    }
2479
    }
2432
  }
2480
  }
2433
 
2481
 
2434
  ## Now deal with the saved files
2482
  ## Now deal with the saved files
2435
  if (defined $saved[0]) {
2483
  if (defined $saved[0]) {
2436
    if ($#saved == 0) {
2484
    if (!defined $saved[1]) {
2437
      ## Theres only one rc file, take it
2485
      ## Theres only one rc file, take it
2438
      push(@$array, $saved[0]);
2486
      push(@$array, $saved[0]);
2439
    }
2487
    }
2440
    else {
2488
    else {
2441
      my($pjname) = $self->escape_regex_special(
2489
      my($pjname) = $self->escape_regex_special(
Line 2464... Line 2512...
2464
  my($recurse) = shift;
2512
  my($recurse) = shift;
2465
  my($pchh)    = shift;
2513
  my($pchh)    = shift;
2466
  my($pchc)    = shift;
2514
  my($pchc)    = shift;
2467
  my($alldir)  = $recurse ||
2515
  my($alldir)  = $recurse ||
2468
                 $self->{'flag_overrides'}->{$tag}->{$file}->{'recurse'};
2516
                 $self->{'flag_overrides'}->{$tag}->{$file}->{'recurse'};
2469
  my(@gen)     = $self->generate_default_file_list($file, [], $alldir);
2517
  my(@gen)     = $self->generate_default_file_list($file, [], undef, $alldir);
2470
 
2518
 
2471
  $self->sift_files(\@gen, $exts, $pchh, $pchc, $tag, $built, $alldir);
2519
  $self->sift_files(\@gen, $exts, $pchh, $pchc, $tag, $built, $alldir);
2472
 
-
 
2473
}
2520
}
2474
 
2521
 
2475
 
2522
 
2476
sub generate_default_components {
2523
sub generate_default_components {
2477
  my($self)    = shift;
2524
  my($self)    = shift;
Line 2552... Line 2599...
2552
                      $newgroup = $key;
2599
                      $newgroup = $key;
2553
                    }
2600
                    }
2554
                  }
2601
                  }
2555
                }
2602
                }
2556
 
2603
 
2557
                if ($#input != -1) {
2604
                if (defined $input[0]) {
2558
                  my(@front) = ();
2605
                  my(@front) = ();
2559
                  my(@copy)  = @$array;
2606
                  my(@copy)  = @$array;
2560
 
2607
 
2561
                  @$array = ();
2608
                  @$array = ();
2562
                  foreach my $input (@input) {
2609
                  foreach my $input (@input) {
2563
                    my($part) = $self->remove_wanted_extension(
2610
                    my($part) = $self->remove_wanted_extension(
2564
                                   $input,
2611
                                   $input,
2565
                                   $self->{'valid_components'}->{$gentype});
2612
                                   $self->{'valid_components'}->{$gentype});
2566
 
2613
 
2567
                    $part = $self->escape_regex_special($part);
-
 
2568
                    my(@files) = $self->generated_filenames($part, $gentype,
2614
                    my(@files) = $self->generated_filenames($part, $gentype,
2569
                                                            $tag, $input, 1);
2615
                                                            $tag, $input);
2570
                    if ($#copy != -1) {
2616
                    if (defined $copy[0]) {
2571
                      my($found) = 0;
2617
                      my($found) = 0;
2572
                      foreach my $file (@files) {
2618
                      foreach my $file (@files) {
2573
                        for(my $i = 0; $i <= $#copy; $i++) {
2619
                        for(my $i = 0; $i < scalar(@copy); $i++) {
2574
                          my($re) = $self->escape_regex_special($copy[$i]);
2620
                          my($re) = $self->escape_regex_special($copy[$i]);
2575
                          if ($file eq $copy[$i] || $file =~ /[\/\\]$re$/) {
2621
                          if ($file eq $copy[$i] || $file =~ /[\/\\]$re$/) {
2576
                            ## No need to check for previously added files
2622
                            ## No need to check for previously added files
2577
                            ## here since there are none.
2623
                            ## here since there are none.
2578
                            $found = 1;
2624
                            $found = 1;
Line 2601... Line 2647...
2601
                          push(@front, $file);
2647
                          push(@front, $file);
2602
                        }
2648
                        }
2603
                      }
2649
                      }
2604
                    }
2650
                    }
2605
                  }
2651
                  }
2606
                  if ($#copy != -1) {
2652
                  if (defined $copy[0]) {
2607
                    ## No need to check for previously added files
2653
                    ## No need to check for previously added files
2608
                    ## here since there are none.
2654
                    ## here since there are none.
2609
                    push(@$array, @copy);
2655
                    push(@$array, @copy);
2610
                    if (defined $self->get_assignment($grtag)) {
2656
                    if (defined $self->get_assignment($grtag)) {
2611
                      $self->process_assignment_add($grtag, $defgroup);
2657
                      $self->process_assignment_add($grtag, $defgroup);
2612
                    }
2658
                    }
2613
                  }
2659
                  }
2614
                  if (defined $front[0]) {
2660
                  if (defined $front[0]) {
2615
                    if (defined $newgroup) {
2661
                    if (defined $newgroup) {
2616
                      if ($#copy != -1) {
2662
                      if (defined $copy[0]) {
2617
                        $self->process_assignment_add($grtag, $defgroup);
2663
                        $self->process_assignment_add($grtag, $defgroup);
2618
                      }
2664
                      }
-
 
2665
                      if (!defined $self->{$tag}->{$defcomp}->{$newgroup}) {
2619
                      $self->{$tag}->{$defcomp}->{$newgroup} = \@front;
2666
                        $self->{$tag}->{$defcomp}->{$newgroup} = \@front;
-
 
2667
                      }
-
 
2668
                      else {
-
 
2669
                        push(@{$self->{$tag}->{$defcomp}->{$newgroup}}, @front);
-
 
2670
                      }
2620
                      $self->process_assignment_add($grtag, $newgroup);
2671
                      $self->process_assignment_add($grtag, $newgroup);
2621
                    }
2672
                    }
2622
                    else {
2673
                    else {
2623
                      unshift(@$array, @front);
2674
                      unshift(@$array, @front);
2624
                    }
2675
                    }
Line 2676... Line 2727...
2676
  foreach my $name (keys %$names) {
2727
  foreach my $name (keys %$names) {
2677
    my($comps) = $$names{$name};
2728
    my($comps) = $$names{$name};
2678
    foreach my $key (keys %$comps) {
2729
    foreach my $key (keys %$comps) {
2679
      foreach my $val (@{$$comps{$key}}) {
2730
      foreach my $val (@{$$comps{$key}}) {
2680
        foreach my $i (@$arr) {
2731
        foreach my $i (@$arr) {
2681
          my($ifile) = $self->escape_regex_special($i);
-
 
2682
          foreach my $wanted (@$sext) {
2732
          foreach my $wanted (@$sext) {
2683
            ## Remove any escape characters from the extension
2733
            ## Remove any escape characters from the extension
2684
            my($oext) = $wanted;
2734
            my($oext) = $wanted;
2685
            $oext =~ s/\\//g;
2735
            $oext =~ s/\\//g;
2686
            foreach my $re ($self->generated_filenames($ifile, $gent,
2736
            foreach my $re ($self->generated_filenames($i, $gent,
2687
                                                       $tag, "$i$oext", 0)) {
2737
                                                       $tag, "$i$oext")) {
-
 
2738
              $re = $self->escape_regex_special($re);
2688
              if ($val =~ /$re$/) {
2739
              if ($val =~ /$re$/) {
2689
                return 1;
2740
                return 1;
2690
              }
2741
              }
2691
            }
2742
            }
2692
          }
2743
          }
Line 2771... Line 2822...
2771
  }
2822
  }
2772
 
2823
 
2773
  if (defined $key) {
2824
  if (defined $key) {
2774
    foreach my $ma (@{$self->{'matching_assignments'}->{$gentype}}) {
2825
    foreach my $ma (@{$self->{'matching_assignments'}->{$gentype}}) {
2775
      if ($ma eq 'gendir') {
2826
      if ($ma eq 'gendir') {
2776
        if (defined $self->{'flag_overrides'}->{$gentype}->{$key}->{$ma}) {
2827
        my($dir) = $self->{'flag_overrides'}->{$gentype}->{$key}->{$ma};
-
 
2828
        if (defined $dir) {
2777
          ## Convert the file to unix style for basename
2829
          ## Convert the file to unix style for basename
2778
          $created =~ s/\\/\//g;
2830
          $created =~ s/\\/\//g;
2779
          return "$self->{'flag_overrides'}->{$gentype}->{$key}->{$ma}/" .
-
 
2780
                 basename($created);
2831
          return "$dir/" . $self->mpc_basename($created);
2781
        }
2832
        }
2782
      }
2833
      }
2783
    }
2834
    }
2784
  }
2835
  }
2785
 
2836
 
Line 2792... Line 2843...
2792
  my($gentype) = shift;
2843
  my($gentype) = shift;
2793
  my($tag)     = shift;
2844
  my($tag)     = shift;
2794
  my($array)   = shift;
2845
  my($array)   = shift;
2795
  my($file)    = shift;
2846
  my($file)    = shift;
2796
  my($ofile)   = shift;
2847
  my($ofile)   = shift;
-
 
2848
  my($count)   = 0;
-
 
2849
 
-
 
2850
  ## Save the length of the basename for later.  We can not convert the
-
 
2851
  ## slashes on $file as it needs to keep the back slashes since that's
-
 
2852
  ## what comes from generated_filenames() below.  This is, of course, if
-
 
2853
  ## we are converting slashes in the first place.
-
 
2854
  my($fcopy) = $file;
-
 
2855
  $fcopy =~ s/.*[\/\\]//;
-
 
2856
  my($blen) = length($fcopy);
2797
 
2857
 
-
 
2858
  ## Turn it into a regular expression
2798
  $file = $self->escape_regex_special($file);
2859
  $file = $self->escape_regex_special($file);
2799
 
2860
 
2800
  foreach my $gen ($self->get_component_list($gentype, 1)) {
2861
  foreach my $gen ($self->get_component_list($gentype, 1)) {
2801
    my($input) = $gen;
2862
    my($input) = $gen;
2802
    foreach my $ext (@{$self->{'valid_components'}->{$gentype}}) {
2863
    foreach my $ext (@{$self->{'valid_components'}->{$gentype}}) {
Line 2816... Line 2877...
2816
    }
2877
    }
2817
 
2878
 
2818
    ## See if we need to add the file.  We only need to bother
2879
    ## See if we need to add the file.  We only need to bother
2819
    ## if the length of $gen is less than or equal to the length of
2880
    ## if the length of $gen is less than or equal to the length of
2820
    ## $file because they couldn't possibly match if they weren't.
2881
    ## $file because they couldn't possibly match if they weren't.
2821
    if (length(basename($gen)) <= length(basename($file))) {
2882
    if (length($self->mpc_basename($gen)) <= $blen) {
2822
      foreach my $re ($self->generated_filenames($gen, $gentype,
2883
      foreach my $re ($self->generated_filenames($gen, $gentype,
2823
                                                 $tag, $input, 1)) {
2884
                                                 $tag, $input)) {
2824
        if ($re =~ /$file(.*)?$/) {
2885
        if ($re =~ /$file(.*)?$/) {
2825
          my($created) = $re;
2886
          my($created) = $re;
2826
          if (defined $ofile) {
2887
          if (defined $ofile) {
2827
            $created = $self->prepend_gendir($created, $ofile, $gentype);
2888
            $created = $self->prepend_gendir($created, $ofile, $gentype);
2828
          }
2889
          }
2829
          if (!$self->already_added($array, $created)) {
2890
          if (!$self->already_added($array, $created)) {
2830
            push(@$array, $created);
2891
            push(@$array, $created);
-
 
2892
            ++$count;
2831
          }
2893
          }
2832
          last;
2894
          last;
2833
        }
2895
        }
2834
      }
2896
      }
2835
    }
2897
    }
2836
  }
2898
  }
-
 
2899
  return $count;
2837
}
2900
}
2838
 
2901
 
2839
 
2902
 
2840
sub add_corresponding_component_files {
2903
sub add_corresponding_component_files {
2841
  my($self)   = shift;
2904
  my($self)     = shift;
2842
  my($ftags)  = shift;
2905
  my($filecomp) = shift;
2843
  my($tag)    = shift;
2906
  my($tag)      = shift;
2844
  my($names)  = undef;
-
 
2845
  my($grname) = $grouped_key . $tag;
2907
  my($grname)   = $grouped_key . $tag;
2846
 
-
 
2847
  ## Collect up all of the files that have already been listed
-
 
2848
  ## with the extension removed.
-
 
2849
  my(%filecomp) = ();
-
 
2850
  foreach my $filetag (@$ftags) {
-
 
2851
    $names = $self->{$filetag};
-
 
2852
    foreach my $name (keys %$names) {
-
 
2853
      foreach my $comp (keys %{$$names{$name}}) {
-
 
2854
        foreach my $sfile (@{$$names{$name}->{$comp}}) {
-
 
2855
          my($mod) = $sfile;
-
 
2856
          $mod =~ s/\.[^\.]+$//;
-
 
2857
          $filecomp{$mod} = $comp;
-
 
2858
        }
-
 
2859
      }
-
 
2860
    }
-
 
2861
  }
-
 
2862
 
2908
 
2863
  ## Create a hash array keyed off of the existing files of the type
2909
  ## Create a hash array keyed off of the existing files of the type
2864
  ## that we plan on adding.
2910
  ## that we plan on adding.
2865
  my($fexist)  = 0;
2911
  my($fexist)  = 0;
2866
  my(%scfiles) = ();
2912
  my(%scfiles) = ();
2867
  $names = $self->{$tag};
2913
  my($names)   = $self->{$tag};
2868
  foreach my $name (keys %$names) {
2914
  foreach my $name (keys %$names) {
2869
    ## Check to see if files exist in the default group
2915
    ## Check to see if files exist in the default group
2870
    if (defined $$names{$name}->{$defgroup} &&
2916
    if (defined $$names{$name}->{$defgroup} &&
2871
        defined $$names{$name}->{$defgroup}->[0]) {
2917
        defined $$names{$name}->{$defgroup}->[0]) {
2872
      $fexist = 1;
2918
      $fexist = 1;
Line 2884... Line 2930...
2884
  }
2930
  }
2885
 
2931
 
2886
  ## Check each file against a possible new file addition
2932
  ## Check each file against a possible new file addition
2887
  my($adddefaultgroup) = 0;
2933
  my($adddefaultgroup) = 0;
2888
  my($oktoadddefault)  = 0;
2934
  my($oktoadddefault)  = 0;
2889
  foreach my $sfile (keys %filecomp) {
2935
  foreach my $sfile (keys %$filecomp) {
2890
    my($found) = 0;
2936
    my($found) = 0;
2891
    foreach my $ext (@exts) {
2937
    foreach my $ext (@exts) {
2892
      if (exists $scfiles{"$sfile$ext"}) {
2938
      if (exists $scfiles{"$sfile$ext"}) {
2893
        $found = 1;
2939
        $found = 1;
2894
        last;
2940
        last;
Line 2896... Line 2942...
2896
    }
2942
    }
2897
 
2943
 
2898
    if (!$found) {
2944
    if (!$found) {
2899
      ## Get the array of files for the selected component name
2945
      ## Get the array of files for the selected component name
2900
      my($array) = [];
2946
      my($array) = [];
2901
      my($comp)  = $filecomp{$sfile};
2947
      my($comp)  = $$filecomp{$sfile};
2902
      foreach my $name (keys %$names) {
2948
      foreach my $name (keys %$names) {
2903
        if (defined $$names{$name}->{$comp}) {
2949
        if (defined $$names{$name}->{$comp}) {
2904
          $array = $$names{$name}->{$comp};
2950
          $array = $$names{$name}->{$comp};
2905
        }
2951
        }
2906
      }
2952
      }
2907
 
2953
 
2908
      ## First check to see if the file exists
2954
      ## First, see if it will be generated so that we can correctly
2909
      foreach my $ext (@exts) {
2955
      ## deal with 'gendir' settings.
2910
        if (-r "$sfile$ext") {
2956
      foreach my $gentype (keys %{$self->{'generated_exts'}}) {
2911
          push(@$array, "$sfile$ext");
2957
        $found += $self->list_generated_file($gentype, $tag, $array, $sfile);
2912
          $found = 1;
-
 
2913
          last;
-
 
2914
        }
-
 
2915
      }
2958
      }
2916
 
2959
 
2917
      ## If it doesn't exist, see if it will be generated
2960
      ## Next check to see if the file exists
2918
      if (!$found) {
2961
      if (!$found) {
2919
        foreach my $gentype (keys %{$self->{'generated_exts'}}) {
2962
        foreach my $ext (@exts) {
-
 
2963
          if (-r "$sfile$ext") {
-
 
2964
            my($file) = "$sfile$ext";
2920
          $self->list_generated_file($gentype, $tag, $array, $sfile);
2965
            if (!$self->already_added($array, $file)) {
-
 
2966
              push(@$array, $file);
-
 
2967
              ++$found;
-
 
2968
            }
-
 
2969
            last;
-
 
2970
          }
2921
        }
2971
        }
2922
      }
2972
      }
2923
 
2973
 
2924
      ## If we have any files at all in the component array, check
2974
      ## If we have any files at all in the component array, check
2925
      ## to see if we need to add a new group name
2975
      ## to see if we need to add a new group name
2926
      if (defined $$array[0]) {
2976
      if (defined $$array[0]) {
-
 
2977
        if ($comp eq $defgroup) {
-
 
2978
          $adddefaultgroup = 1;
-
 
2979
        }
-
 
2980
        else {
2927
        my($compexists) = undef;
2981
          my($compexists) = undef;
2928
        my($grval)      = $self->get_assignment($grname);
2982
          my($grval)      = $self->get_assignment($grname);
2929
        if (defined $grval) {
2983
          if (defined $grval) {
2930
          foreach my $grkey (@{$self->create_array($grval)}) {
2984
            foreach my $grkey (@{$self->create_array($grval)}) {
2931
            if ($grkey eq $comp) {
2985
              if ($grkey eq $comp) {
2932
              $compexists = 1;
2986
                $compexists = 1;
2933
              last;
2987
                last;
-
 
2988
              }
2934
            }
2989
            }
2935
          }
2990
          }
2936
        }
-
 
2937
 
2991
 
2938
        if (!$compexists) {
2992
          if (!$compexists) {
2939
          if ($comp eq $defgroup) {
-
 
2940
            $adddefaultgroup = 1;
-
 
2941
          }
-
 
2942
          else {
-
 
2943
            $self->process_assignment_add($grname, $comp);
2993
            $self->process_assignment_add($grname, $comp);
2944
            $oktoadddefault = 1;
-
 
2945
            $adddefaultgroup |= $fexist;
-
 
2946
          }
2994
          }
-
 
2995
          $oktoadddefault = 1;
-
 
2996
          $adddefaultgroup |= $fexist;
2947
        }
2997
        }
2948
 
2998
 
2949
        ## Put the array back into the component list
2999
        ## Put the array back into the component list
-
 
3000
        if ($found) {
2950
        foreach my $name (keys %$names) {
3001
          foreach my $name (keys %$names) {
2951
          $$names{$name}->{$comp} = $array;
3002
            $$names{$name}->{$comp} = $array;
-
 
3003
          }
2952
        }
3004
        }
2953
      }
3005
      }
2954
    }
3006
    }
2955
  }
3007
  }
2956
 
3008
 
Line 3020... Line 3072...
3020
    $self->set_project_name($self->get_default_project_name());
3072
    $self->set_project_name($self->get_default_project_name());
3021
  }
3073
  }
3022
 
3074
 
3023
  ## Generate the default pch file names (if needed)
3075
  ## Generate the default pch file names (if needed)
3024
  my(@files) = $self->generate_default_file_list(
3076
  my(@files) = $self->generate_default_file_list(
-
 
3077
                                 '.', [],
3025
                                 '.', [], $self->get_assignment('recurse'));
3078
                                 undef, $self->get_assignment('recurse'));
3026
  $self->generate_default_pch_filenames(\@files);
3079
  $self->generate_default_pch_filenames(\@files);
3027
 
3080
 
3028
  ## If the pch file names are empty strings then we need to fix that
3081
  ## If the pch file names are empty strings then we need to fix that
3029
  $self->fix_pch_filenames();
3082
  $self->fix_pch_filenames();
3030
 
3083
 
Line 3052... Line 3105...
3052
 
3105
 
3053
  ## Now that all of the source files have been added
3106
  ## Now that all of the source files have been added
3054
  ## we need to remove those that have need to be removed
3107
  ## we need to remove those that have need to be removed
3055
  $self->remove_excluded('source_files');
3108
  $self->remove_excluded('source_files');
3056
 
3109
 
-
 
3110
  ## Collect up all of the source file that have already been listed
-
 
3111
  ## with the extension removed.
-
 
3112
  my(%sourcecomp) = ();
-
 
3113
  foreach my $sourcetag (keys %sourceComponents) {
-
 
3114
    my($names) = $self->{$sourcetag};
-
 
3115
    foreach my $name (keys %$names) {
-
 
3116
      foreach my $comp (keys %{$$names{$name}}) {
-
 
3117
        foreach my $sfile (@{$$names{$name}->{$comp}}) {
-
 
3118
          my($mod) = $sfile;
-
 
3119
          $mod =~ s/\.[^\.]+$//;
-
 
3120
          $sourcecomp{$mod} = $comp;
-
 
3121
        }
-
 
3122
      }
-
 
3123
    }
-
 
3124
  }
-
 
3125
 
3057
  ## Add %specialComponents files based on the
3126
  ## Add %specialComponents files based on the
3058
  ## source_components (i.e. .h and .i or .inl based on .cpp)
3127
  ## source_components (i.e. .h and .i or .inl based on .cpp)
3059
  my(@scomp) = keys %sourceComponents;
-
 
3060
  foreach my $tag (keys %specialComponents) {
3128
  foreach my $tag (keys %specialComponents) {
3061
    $self->add_corresponding_component_files(\@scomp, $tag);
3129
    $self->add_corresponding_component_files(\%sourcecomp, $tag);
3062
  }
3130
  }
3063
 
3131
 
3064
  ## Now, if the %specialComponents are still empty
3132
  ## Now, if the %specialComponents are still empty
3065
  ## then take any file that matches the components extension
3133
  ## then take any file that matches the components extension
3066
  foreach my $tag (keys %specialComponents) {
3134
  foreach my $tag (keys %specialComponents) {
Line 3076... Line 3144...
3076
          foreach my $name (keys %$names) {
3144
          foreach my $name (keys %$names) {
3077
            foreach my $key (keys %{$$names{$name}}) {
3145
            foreach my $key (keys %{$$names{$name}}) {
3078
              push(@all, @{$$names{$name}->{$key}});
3146
              push(@all, @{$$names{$name}->{$key}});
3079
            }
3147
            }
3080
          }
3148
          }
3081
          $ok = ($#all == -1);
3149
          $ok = (!defined $all[0]);
3082
        }
3150
        }
3083
        if ($ok) {
3151
        if ($ok) {
3084
          $self->generate_default_components(\@files, $tag);
3152
          $self->generate_default_components(\@files, $tag);
3085
        }
3153
        }
3086
      }
3154
      }
Line 3088... Line 3156...
3088
  }
3156
  }
3089
 
3157
 
3090
  ## Now that all of the other files have been added
3158
  ## Now that all of the other files have been added
3091
  ## we need to remove those that have need to be removed
3159
  ## we need to remove those that have need to be removed
3092
  my(@rmkeys) = keys %{$self->{'remove_files'}};
3160
  my(@rmkeys) = keys %{$self->{'remove_files'}};
3093
  if ($#rmkeys != -1) {
3161
  if (defined $rmkeys[0]) {
3094
    $self->remove_excluded(@rmkeys);
3162
    $self->remove_excluded(@rmkeys);
3095
  }
3163
  }
3096
 
-
 
3097
  ## Generate default target names after all source files are added
-
 
3098
  $self->generate_default_target_names();
-
 
3099
}
3164
}
3100
 
3165
 
3101
 
3166
 
3102
sub set_project_name {
3167
sub set_project_name {
3103
  my($self) = shift;
3168
  my($self) = shift;
Line 3160... Line 3225...
3160
  ## By default, if 'convert_slashes' is true, then we convert slashes
3225
  ## By default, if 'convert_slashes' is true, then we convert slashes
3161
  ## to backslashes.  There are cases where we do not want to convert
3226
  ## to backslashes.  There are cases where we do not want to convert
3162
  ## the slashes, in that case get_component_list() was called with
3227
  ## the slashes, in that case get_component_list() was called with
3163
  ## an additional parameter indicating this.
3228
  ## an additional parameter indicating this.
3164
  if (!$noconvert && $self->{'convert_slashes'}) {
3229
  if (!$noconvert && $self->{'convert_slashes'}) {
3165
    for(my $i = 0; $i <= $#list; $i++) {
3230
    foreach my $item (@list) {
3166
      $list[$i] = $self->slash_to_backslash($list[$i]);
3231
      $item =~ s/\//\\/g;
3167
    }
3232
    }
3168
  }
3233
  }
3169
 
3234
 
3170
  if ($self->{'sort_files'}) {
3235
  if ($self->{'sort_files'}) {
3171
    @list = sort { $self->file_sorter($a, $b) } @list;
3236
    @list = sort { $self->file_sorter($a, $b) } @list;
Line 3183... Line 3248...
3183
  my($type)    = shift;
3248
  my($type)    = shift;
3184
  my($comps)   = shift;
3249
  my($comps)   = shift;
3185
  my(@outputs) = ();
3250
  my(@outputs) = ();
3186
 
3251
 
3187
  foreach my $array ($self->generated_filename_arrays($cinput, $based,
3252
  foreach my $array ($self->generated_filename_arrays($cinput, $based,
3188
                                                      $type, $ainput, 1)) {
3253
                                                      $type, $ainput)) {
3189
    foreach my $built (@$array) {
3254
    foreach my $built (@$array) {
3190
      if (@$comps == 0) {
3255
      if (@$comps == 0) {
3191
        push(@outputs, $built);
3256
        push(@outputs, $built);
3192
        last;
3257
        last;
3193
      }
3258
      }
Line 3196... Line 3261...
3196
        push(@outputs, $built);
3261
        push(@outputs, $built);
3197
        last;
3262
        last;
3198
      }
3263
      }
3199
      else {
3264
      else {
3200
        my($base) = $built;
3265
        my($base) = $built;
3201
        if ($self->{'convert_slashes'}) {
3266
        $base =~ s/\\/\//g if ($self->{'convert_slashes'});
3202
          $base =~ s/\\/\//g;
-
 
3203
        }
-
 
3204
        my($re) = $self->escape_regex_special(basename($base));
3267
        my($re) = $self->escape_regex_special($self->mpc_basename($base));
3205
        foreach my $c (@$comps) {
3268
        foreach my $c (@$comps) {
3206
          ## We only match if the built file name matches from
3269
          ## We only match if the built file name matches from
3207
          ## beginning to end or from a slash to the end.
3270
          ## beginning to end or from a slash to the end.
3208
          if ($c =~ /^$re$/ || $c =~ /[\/\\]$re$/) {
3271
          if ($c =~ /^$re$/ || $c =~ /[\/\\]$re$/) {
3209
            push(@outputs, $built);
3272
            push(@outputs, $built);
Line 3223... Line 3286...
3223
  my($type)   = shift;
3286
  my($type)   = shift;
3224
  my($cmd)    = shift;
3287
  my($cmd)    = shift;
3225
  my($based)  = shift;
3288
  my($based)  = shift;
3226
  my(@params) = @_;
3289
  my(@params) = @_;
3227
 
3290
 
-
 
3291
 
3228
  if ($type =~ /^custom_type/) {
3292
  if ($type eq 'feature') {
-
 
3293
    return $self->get_feature_value($cmd, $based);
-
 
3294
  }
-
 
3295
  elsif (index($type, 'custom_type') == 0) {
3229
    return $self->get_custom_value($cmd, $based, @params);
3296
    return $self->get_custom_value($cmd, $based, @params);
3230
  }
3297
  }
3231
  elsif ($type =~ /^$grouped_key/) {
3298
  elsif (index($type, $grouped_key) == 0) {
3232
    return $self->get_grouped_value($type, $cmd, $based);
3299
    return $self->get_grouped_value($type, $cmd, $based);
3233
  }
3300
  }
3234
 
3301
 
3235
  return undef;
3302
  return undef;
3236
}
3303
}
3237
 
3304
 
3238
 
3305
 
-
 
3306
sub get_feature_value {
-
 
3307
  my($self)   = shift;
-
 
3308
  my($cmd)    = shift;
-
 
3309
  my($based)  = shift;
-
 
3310
 
-
 
3311
  if ($cmd eq 'value') {
-
 
3312
    my($val) = $self->{'feature_parser'}->get_value($based);
-
 
3313
    if (defined $val && $val != 0) {
-
 
3314
      return 1;
-
 
3315
    }
-
 
3316
  }
-
 
3317
 
-
 
3318
  return undef;
-
 
3319
}
-
 
3320
 
-
 
3321
 
3239
sub get_grouped_value {
3322
sub get_grouped_value {
3240
  my($self)  = shift;
3323
  my($self)  = shift;
3241
  my($type)  = shift;
3324
  my($type)  = shift;
3242
  my($cmd)   = shift;
3325
  my($cmd)   = shift;
3243
  my($based) = shift;
3326
  my($based) = shift;
Line 3294... Line 3377...
3294
sub get_command_subs {
3377
sub get_command_subs {
3295
  my($self)  = shift;
3378
  my($self)  = shift;
3296
  my(%valid) = ();
3379
  my(%valid) = ();
3297
 
3380
 
3298
  ## Add the built-in OS compatibility commands
3381
  ## Add the built-in OS compatibility commands
3299
  if ($self->{'convert_slashes'}) {
3382
  if (UNIVERSAL::isa($self, 'WinProjectBase')) {
3300
    $valid{'cat'}   = 'type';
3383
    $valid{'cat'}   = 'type';
-
 
3384
    $valid{'cmp'}   = 'fc';
3301
    $valid{'cp'}    = 'copy /y';
3385
    $valid{'cp'}    = 'copy /y';
3302
    $valid{'mkdir'} = 'mkdir';
3386
    $valid{'mkdir'} = 'mkdir';
3303
    $valid{'mv'}    = 'move /y';
3387
    $valid{'mv'}    = 'move /y';
-
 
3388
    $valid{'os'}    = 'win32';
3304
    $valid{'rm'}    = 'del /f/s/q';
3389
    $valid{'rm'}    = 'del /f/s/q';
3305
    $valid{'nul'}   = 'nul';
3390
    $valid{'nul'}   = 'nul';
3306
  }
3391
  }
3307
  else {
3392
  else {
3308
    $valid{'cat'}   = 'cat';
3393
    $valid{'cat'}   = 'cat';
-
 
3394
    $valid{'cmp'}   = 'cmp';
3309
    $valid{'cp'}    = 'cp -f';
3395
    $valid{'cp'}    = 'cp -f';
3310
    $valid{'mkdir'} = 'mkdir -p';
3396
    $valid{'mkdir'} = 'mkdir -p';
3311
    $valid{'mv'}    = 'mv -f';
3397
    $valid{'mv'}    = 'mv -f';
-
 
3398
    $valid{'os'}    = 'unix';
3312
    $valid{'rm'}    = 'rm -rf';
3399
    $valid{'rm'}    = 'rm -rf';
3313
    $valid{'nul'}   = '/dev/null';
3400
    $valid{'nul'}   = '/dev/null';
3314
  }
3401
  }
3315
 
3402
 
3316
  ## Add the project specific compatibility commands
3403
  ## Add the project specific compatibility commands
Line 3322... Line 3409...
3322
 
3409
 
3323
  return \%valid;
3410
  return \%valid;
3324
}
3411
}
3325
 
3412
 
3326
 
3413
 
-
 
3414
sub replace_parameters {
-
 
3415
  my($self)   = shift;
-
 
3416
  my($str)    = shift;
-
 
3417
  my($valid)  = shift;
-
 
3418
  my($nowarn) = shift;
-
 
3419
  my($input)  = shift;
-
 
3420
  my($output) = shift;
-
 
3421
 
-
 
3422
  while ($str =~ /<%(\w+)(\(\w+\))?%>/) {
-
 
3423
    my($name)     = $1;
-
 
3424
    my($modifier) = $2;
-
 
3425
    if (defined $modifier) {
-
 
3426
      my($tmp) = $name;
-
 
3427
      $name = $modifier;
-
 
3428
      $name =~ s/[\(\)]//g;
-
 
3429
      $modifier = $tmp;
-
 
3430
    }
-
 
3431
 
-
 
3432
    if (exists $$valid{$name}) {
-
 
3433
      if (defined $$valid{$name}) {
-
 
3434
        my($replace) = $$valid{$name};
-
 
3435
        if (defined $modifier) {
-
 
3436
          if ($modifier eq 'noextension') {
-
 
3437
            $replace =~ s/\.[^\.]+$//;
-
 
3438
          }
-
 
3439
          else {
-
 
3440
            $self->warning("Uknown parameter modifier $modifier.");
-
 
3441
          }
-
 
3442
        }
-
 
3443
        $str =~ s/<%\w+(\(\w+\))?%>/$replace/;
-
 
3444
      }
-
 
3445
      else {
-
 
3446
        $str =~ s/<%\w+(\(\w+\))?%>//;
-
 
3447
      }
-
 
3448
    }
-
 
3449
    else {
-
 
3450
      $str =~ s/<%\w+(\(\w+\))?%>//;
-
 
3451
 
-
 
3452
      ## We only want to warn the user that we did not recognize the
-
 
3453
      ## pseudo template parameter if there was an input and an output
-
 
3454
      ## file passed to this function.  If this variable was used
-
 
3455
      ## without the parenthesis (as in an if statement), then we don't
-
 
3456
      ## want to warn the user.
-
 
3457
      if (defined $input && defined $output) {
-
 
3458
        if (!defined $$nowarn{$name}) {
-
 
3459
          $self->warning("<%$name%> was not recognized.");
-
 
3460
        }
-
 
3461
 
-
 
3462
        ## If we didn't recognize the pseudo template parameter then
-
 
3463
        ## we don't want to return anything back.
-
 
3464
        return undef;
-
 
3465
      }
-
 
3466
    }
-
 
3467
  }
-
 
3468
 
-
 
3469
  return $str;
-
 
3470
}
-
 
3471
 
-
 
3472
 
3327
sub convert_command_parameters {
3473
sub convert_command_parameters {
3328
  my($self)   = shift;
3474
  my($self)   = shift;
3329
  my($str)    = shift;
3475
  my($str)    = shift;
3330
  my($input)  = shift;
3476
  my($input)  = shift;
3331
  my($output) = shift;
3477
  my($output) = shift;
Line 3335... Line 3481...
3335
  ## Add in the values that change for every call to this function
3481
  ## Add in the values that change for every call to this function
3336
  $valid{'temporary'} = 'temp.$$$$.' . int(rand(0xffffffff));
3482
  $valid{'temporary'} = 'temp.$$$$.' . int(rand(0xffffffff));
3337
 
3483
 
3338
  if (defined $input) {
3484
  if (defined $input) {
3339
    $valid{'input'}          = $input;
3485
    $valid{'input'}          = $input;
3340
    $valid{'input_basename'} = basename($input);
3486
    $valid{'input_basename'} = $self->mpc_basename($input);
3341
    $valid{'input_noext'}    = $input;
3487
    $valid{'input_noext'}    = $input;
3342
    $valid{'input_noext'}    =~ s/(\.[^\.]+)$//;
3488
    $valid{'input_noext'}    =~ s/(\.[^\.]+)$//;
3343
    $valid{'input_ext'}      = $1;
3489
    $valid{'input_ext'}      = $1;
3344
  }
3490
  }
3345
 
3491
 
Line 3350... Line 3496...
3350
      my($noext) = $out;
3496
      my($noext) = $out;
3351
      $noext =~ s/(\.[^\.]+)$//;
3497
      $noext =~ s/(\.[^\.]+)$//;
3352
 
3498
 
3353
      $valid{'output_ext'}       = $1;
3499
      $valid{'output_ext'}       = $1;
3354
      $valid{'output_noext'}    .= (!$first ? ' ' : '') . $noext;
3500
      $valid{'output_noext'}    .= (!$first ? ' ' : '') . $noext;
3355
      $valid{'output_basename'} .= (!$first ? ' ' : '') . basename($out);
3501
      $valid{'output_basename'} .= (!$first ? ' ' : '') .
-
 
3502
                                   $self->mpc_basename($out);
3356
      $first = 0;
3503
      $first = 0;
3357
    }
3504
    }
3358
  }
3505
  }
3359
 
3506
 
3360
  ## Add in the specific types of output files
3507
  ## Add in the specific types of output files
Line 3375... Line 3522...
3375
        }
3522
        }
3376
      }
3523
      }
3377
    }
3524
    }
3378
  }
3525
  }
3379
 
3526
 
3380
  while ($str =~ /<%(\w+)(\(\w+\))?%>/) {
-
 
3381
    my($name)     = $1;
-
 
3382
    my($modifier) = $2;
-
 
3383
    if (defined $modifier) {
-
 
3384
      my($tmp) = $name;
-
 
3385
      $name = $modifier;
-
 
3386
      $name =~ s/[\(\)]//g;
-
 
3387
      $modifier = $tmp;
-
 
3388
    }
-
 
3389
 
-
 
3390
    if (exists $valid{$name}) {
-
 
3391
      if (defined $valid{$name}) {
-
 
3392
        my($replace) = $valid{$name};
-
 
3393
        if (defined $modifier) {
-
 
3394
          if ($modifier eq 'noextension') {
-
 
3395
            $replace =~ s/\.[^\.]+$//;
-
 
3396
          }
-
 
3397
          else {
-
 
3398
            $self->warning("Uknown parameter modifier $modifier.");
-
 
3399
          }
-
 
3400
        }
-
 
3401
        $str =~ s/<%\w+(\(\w+\))?%>/$replace/;
-
 
3402
      }
-
 
3403
      else {
-
 
3404
        $str =~ s/<%\w+(\(\w+\))?%>//;
-
 
3405
      }
-
 
3406
    }
-
 
3407
    else {
-
 
3408
      $str =~ s/<%\w+(\(\w+\))?%>//;
-
 
3409
 
-
 
3410
      ## We only want to warn the user that we did not recognize the
-
 
3411
      ## pseudo template parameter if there was an input and an output
3527
  return $self->replace_parameters($str, \%valid, \%nowarn, $input, $output);
3412
      ## file passed to this function.  If this variable was used
-
 
3413
      ## without the parenthesis (as in an if statement), then we don't
-
 
3414
      ## want to warn the user.
-
 
3415
      if (defined $input && defined $output) {
-
 
3416
        if (!defined $nowarn{$name}) {
-
 
3417
          $self->warning("<%$name%> was not recognized.");
-
 
3418
        }
-
 
3419
 
-
 
3420
        ## If we didn't recognize the pseudo template parameter then
-
 
3421
        ## we don't want to return anything back.
-
 
3422
        return undef;
-
 
3423
      }
-
 
3424
    }
-
 
3425
  }
-
 
3426
 
-
 
3427
  return $str;
-
 
3428
}
3528
}
3429
 
3529
 
3430
 
3530
 
3431
sub get_custom_value {
3531
sub get_custom_value {
3432
  my($self)   = shift;
3532
  my($self)   = shift;
Line 3441... Line 3541...
3441
 
3541
 
3442
    ## Check for directories in the component list.  If the component
3542
    ## Check for directories in the component list.  If the component
3443
    ## type is not automatic, we may have directories here and will need
3543
    ## type is not automatic, we may have directories here and will need
3444
    ## to get the file list for that type.
3544
    ## to get the file list for that type.
3445
    my($once) = undef;
3545
    my($once) = undef;
3446
    for(my $i = 0; $i <= $#array; ++$i) {
3546
    for(my $i = 0; $i < scalar(@array); ++$i) {
3447
      if (-d $array[$i]) {
3547
      if (-d $array[$i]) {
3448
        if (!defined $once) {
3548
        if (!defined $once) {
3449
          $once = {'recurse' => $self->get_assignment('recurse'),
3549
          $once = {'recurse' => $self->get_assignment('recurse'),
3450
                   'pchh'    => $self->get_assignment('pch_header'),
3550
                   'pchh'    => $self->get_assignment('pch_header'),
3451
                   'pchc'    => $self->get_assignment('pch_source'),
3551
                   'pchc'    => $self->get_assignment('pch_source'),
Line 3479... Line 3579...
3479
      ## Remove the extension
3579
      ## Remove the extension
3480
      $cinput =~ s/\.[^\.]+$//;
3580
      $cinput =~ s/\.[^\.]+$//;
3481
 
3581
 
3482
      ## If we are converting slashes,
3582
      ## If we are converting slashes,
3483
      ## change them back for this parameter
3583
      ## change them back for this parameter
3484
      if ($self->{'convert_slashes'}) {
3584
      $ainput =~ s/\\/\//g if ($self->{'convert_slashes'});
3485
        $ainput =~ s/\\/\//g;
-
 
3486
      }
-
 
3487
 
3585
 
3488
      ## Add all of the output files
3586
      ## Add all of the output files
3489
      foreach my $vc (keys %{$self->{'valid_components'}}, $generic_key) {
3587
      foreach my $vc (keys %{$self->{'valid_components'}}, $generic_key) {
3490
        push(@outputs,
3588
        push(@outputs,
3491
             $self->check_custom_output($based, $cinput,
3589
             $self->check_custom_output($based, $cinput,
Line 3554... Line 3652...
3554
      foreach my $file (@{$self->{'custom_output_files'}->{$based}}) {
3652
      foreach my $file (@{$self->{'custom_output_files'}->{$based}}) {
3555
        my($source) = 0;
3653
        my($source) = 0;
3556
        foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
3654
        foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
3557
          if ($file =~ /$ext$/) {
3655
          if ($file =~ /$ext$/) {
3558
            $source = 1;
3656
            $source = 1;
-
 
3657
            ## We've found a file that matches one of the source file
-
 
3658
            ## extensions.  Now we have to make sure that it doesn't
-
 
3659
            ## match a template file extension.
-
 
3660
            foreach my $text (@{$self->{'valid_components'}->{'template_files'}}) {
-
 
3661
              if ($file =~ /$text$/) {
-
 
3662
                $source = 0;
3559
            last;
3663
                last;
-
 
3664
              }
-
 
3665
            }
-
 
3666
            last if ($source);
3560
          }
3667
          }
3561
        }
3668
        }
3562
        if (!$source) {
3669
        if (!$source) {
3563
          push(@$value, $file);
3670
          push(@$value, $file);
3564
        }
3671
        }
Line 3571... Line 3678...
3571
      $val =~ s/\\\.//g;
3678
      $val =~ s/\\\.//g;
3572
    }
3679
    }
3573
    $value = \@array;
3680
    $value = \@array;
3574
  }
3681
  }
3575
  elsif ($cmd eq 'dependencies') {
3682
  elsif ($cmd eq 'dependencies') {
-
 
3683
    ## If we are converting slashes, change them back for this parameter
-
 
3684
    $based =~ s/\\/\//g if ($self->{'convert_slashes'});
3576
    $value = $self->{'custom_special_depend'}->{$based};
3685
    $value = $self->{'custom_special_depend'}->{$based};
3577
  }
3686
  }
3578
  elsif (defined $customDefined{$cmd} &&
3687
  elsif (defined $customDefined{$cmd} &&
3579
         ($customDefined{$cmd} & 0x04) != 0) {
3688
         ($customDefined{$cmd} & 0x04) != 0) {
3580
    $value = $self->get_assignment($cmd,
3689
    $value = $self->get_assignment($cmd,
Line 3749... Line 3858...
3749
            if ($status) {
3858
            if ($status) {
3750
              ## If they are different, then rename the temporary file
3859
              ## If they are different, then rename the temporary file
3751
              if ($different) {
3860
              if ($different) {
3752
                unlink($name);
3861
                unlink($name);
3753
                if (rename($tmp, $name)) {
3862
                if (rename($tmp, $name)) {
-
 
3863
                  $self->post_file_creation($name);
3754
                  $self->add_file_written($oname);
3864
                  $self->add_file_written($oname);
3755
                }
3865
                }
3756
                else {
3866
                else {
3757
                  $error = "Unable to open $name for output.";
3867
                  $error = "Unable to open $name for output.";
3758
                  $status = 0;
3868
                  $status = 0;
Line 3964... Line 4074...
3964
sub reset_values {
4074
sub reset_values {
3965
  my($self) = shift;
4075
  my($self) = shift;
3966
 
4076
 
3967
  ## Only put data structures that need to be cleared
4077
  ## Only put data structures that need to be cleared
3968
  ## out when the mpc file is done being read, not at the
4078
  ## out when the mpc file is done being read, not at the
3969
  ## end of each project within the mpc file.
4079
  ## end of each project within the mpc file.  Those go in
-
 
4080
  ## the closing curly brace section of parse_line().
3970
  $self->{'project_info'}  = [];
4081
  $self->{'project_info'}  = [];
3971
  $self->{'lib_locations'} = {};
4082
  $self->{'lib_locations'} = {};
-
 
4083
  $self->reset_generating_types();
3972
}
4084
}
3973
 
4085
 
3974
 
4086
 
3975
sub add_default_matching_assignments {
4087
sub add_default_matching_assignments {
3976
  my($self) = shift;
4088
  my($self) = shift;
3977
  my($lang) = $self->get_language();
4089
  my($lang) = $self->get_language();
3978
 
4090
 
3979
  if (defined $lang) {
4091
  if (defined $lang) {
3980
    foreach my $key (keys %{$language{$lang}->[0]}) {
4092
    foreach my $key (keys %{$language{$lang}->[0]}) {
3981
      if (!defined $language{$lang}->[2]->{$key}) {
4093
      if (!defined $language{$lang}->[2]->{$key}) {
3982
         $language{$lang}->[2]->{$key} = [];
4094
        $language{$lang}->[2]->{$key} = [];
-
 
4095
        if (defined $default_matching_assignments{$key}) {
-
 
4096
          push(@{$language{$lang}->[2]->{$key}},
-
 
4097
               @{$default_matching_assignments{$key}});
-
 
4098
        }
3983
        foreach my $keyword (@default_matching_assignments) {
4099
        foreach my $keyword (@default_matching_assignments) {
3984
          push(@{$language{$lang}->[2]->{$key}}, $keyword);
4100
          push(@{$language{$lang}->[2]->{$key}}, $keyword);
3985
        }
4101
        }
3986
      }
4102
      }
3987
    }
4103
    }
Line 4043... Line 4159...
4043
sub update_project_info {
4159
sub update_project_info {
4044
  my($self)    = shift;
4160
  my($self)    = shift;
4045
  my($tparser) = shift;
4161
  my($tparser) = shift;
4046
  my($append)  = shift;
4162
  my($append)  = shift;
4047
  my($names)   = shift;
4163
  my($names)   = shift;
4048
  my($sep)     = shift;
4164
  my($sep)     = shift || '';
4049
  my($pi)      = $self->get_project_info();
4165
  my($pi)      = $self->get_project_info();
4050
  my($value)   = '';
4166
  my($value)   = '';
4051
  my($arr)     = ($append && defined $$pi[0] ? pop(@$pi) : []);
4167
  my($arr)     = ($append && defined $$pi[0] ? pop(@$pi) : []);
4052
 
4168
 
4053
  ## Set up the hash table when we are starting a new project_info
4169
  ## Set up the hash table when we are starting a new project_info
4054
  if ($append == 0) {
4170
  if (!$append) {
4055
    $self->{'project_info_hash_table'} = {};
4171
    $self->{'project_info_hash_table'} = {};
4056
  }
4172
  }
4057
 
4173
 
4058
  ## Append the values of all names into one string
4174
  ## Append the values of all names into one string
4059
  my(@narr) = @$names;
4175
  my($ncount) = scalar(@$names) - 1;
4060
  for(my $i = 0; $i <= $#narr; $i++) {
4176
  for(my $i = 0; $i <= $ncount; $i++) {
4061
    my($key) = $narr[$i];
4177
    $value .= $self->translate_value(
4062
    $value .= $self->translate_value($key,
4178
                               $$names[$i],
4063
                                     $tparser->get_value_with_default($key)) .
4179
                               $tparser->get_value_with_default($$names[$i]));
4064
              (defined $sep && $i != $#narr ? $sep : '');
4180
    $value .= $sep if ($i != $ncount);
4065
  }
4181
  }
4066
 
4182
 
4067
  ## If we haven't seen this value yet, put it on the array
4183
  ## If we haven't seen this value yet, put it on the array
4068
  if (!defined $self->{'project_info_hash_table'}->{"@narr $value"}) {
4184
  if (!defined $self->{'project_info_hash_table'}->{"@$names $value"}) {
4069
    $self->{'project_info_hash_table'}->{"@narr $value"} = 1;
4185
    $self->{'project_info_hash_table'}->{"@$names $value"} = 1;
4070
    #$self->save_project_value("@narr", $value);
-
 
4071
    push(@$arr, $value);
4186
    push(@$arr, $value);
4072
  }
4187
  }
4073
 
4188
 
4074
  ## Always push the array back onto the project_info
4189
  ## Always push the array back onto the project_info
4075
  push(@$pi, $arr);
4190
  push(@$pi, $arr);
Line 4086... Line 4201...
4086
 
4201
 
4087
  ## Perform any additions, subtractions
4202
  ## Perform any additions, subtractions
4088
  ## or overrides for the template values.
4203
  ## or overrides for the template values.
4089
  foreach my $name (@$names) {
4204
  foreach my $name (@$names) {
4090
    if (defined $name && defined $atemp->{lc($name)}) {
4205
    if (defined $name && defined $atemp->{lc($name)}) {
-
 
4206
      my($base) = $name;
-
 
4207
      $base =~ s/.*:://;
-
 
4208
      my($replace) = (defined $self->{'valid_names'}->{$base} &&
-
 
4209
                      ($self->{'valid_names'}->{$base} & 0x04) == 0);
4091
      foreach my $val (@{$atemp->{lc($name)}}) {
4210
      foreach my $val (@{$atemp->{lc($name)}}) {
-
 
4211
        if ($replace && index($$val[1], '<%') >= 0) {
-
 
4212
          $$val[1] = $self->replace_parameters($$val[1],
-
 
4213
                                               $self->{'command_subs'});
-
 
4214
        }
4092
        my($arr) = $self->create_array($$val[1]);
4215
        my($arr) = $self->create_array($$val[1]);
4093
        if ($$val[0] > 0) {
4216
        if ($$val[0] > 0) {
4094
          if (!defined $value) {
4217
          if (!defined $value) {
4095
            $value = '';
4218
            $value = '';
4096
          }
4219
          }
Line 4103... Line 4226...
4103
          else {
4226
          else {
4104
            $value .= " $$val[1]";
4227
            $value .= " $$val[1]";
4105
          }
4228
          }
4106
        }
4229
        }
4107
        elsif ($$val[0] < 0) {
4230
        elsif ($$val[0] < 0) {
4108
          my($parts) = undef;
-
 
4109
          if (defined $value) {
4231
          if (defined $value) {
-
 
4232
            my($parts) = undef;
4110
            if (UNIVERSAL::isa($value, 'ARRAY')) {
4233
            if (UNIVERSAL::isa($value, 'ARRAY')) {
4111
              $parts = $value;
4234
              $parts = $value;
4112
            }
4235
            }
4113
            else {
4236
            else {
4114
              $parts = $self->create_array($value);
4237
              $parts = $self->create_array($value);
Line 4146... Line 4269...
4146
 
4269
 
4147
 
4270
 
4148
sub expand_variables {
4271
sub expand_variables {
4149
  my($self)            = shift;
4272
  my($self)            = shift;
4150
  my($value)           = shift;
4273
  my($value)           = shift;
4151
  my($keys)            = shift;
-
 
4152
  my($rel)             = shift;
4274
  my($rel)             = shift;
4153
  my($expand_template) = shift;
4275
  my($expand_template) = shift;
4154
  my($scope)           = shift;
4276
  my($scope)           = shift;
4155
  my($expand)          = shift;
4277
  my($expand)          = shift;
4156
  my($warn)            = shift;
4278
  my($warn)            = shift;
4157
  my($cwd)             = $self->getcwd();
4279
  my($cwd)             = $self->getcwd();
4158
  my($start)           = 0;
4280
  my($start)           = 0;
4159
 
4281
 
4160
  ## Fix up the value for Windows switch the \\'s to /
4282
  ## Fix up the value for Windows switch the \\'s to /
4161
  if ($self->{'convert_slashes'}) {
4283
  $cwd =~ s/\\/\//g if ($self->{'convert_slashes'});
4162
    $cwd =~ s/\\/\//g;
-
 
4163
  }
-
 
4164
 
4284
 
4165
  while(substr($value, $start) =~ /(\$\(([^)]+)\))/) {
4285
  while(substr($value, $start) =~ /(\$\(([^)]+)\))/) {
4166
    my($whole)  = $1;
4286
    my($whole)  = $1;
4167
    my($name)   = $2;
4287
    my($name)   = $2;
4168
    my($val)    = $$rel{$name};
4288
    my($val)    = $$rel{$name};
4169
 
4289
 
4170
    if (defined $val) {
4290
    if (defined $val) {
4171
      if ($expand) {
4291
      if ($expand) {
4172
        if ($self->{'convert_slashes'}) {
4292
        $val =~ s/\//\\/g if ($self->{'convert_slashes'});
4173
          $val = $self->slash_to_backslash($val);
-
 
4174
        }
-
 
4175
        substr($value, $start) =~ s/\$\([^)]+\)/$val/;
4293
        substr($value, $start) =~ s/\$\([^)]+\)/$val/;
4176
        $whole = $val;
4294
        $whole = $val;
4177
      }
4295
      }
4178
      else {
4296
      else {
4179
        ## Fix up the value for Windows switch the \\'s to /
4297
        ## Fix up the value for Windows switch the \\'s to /
4180
        if ($self->{'convert_slashes'}) {
4298
        $val =~ s/\\/\//g if ($self->{'convert_slashes'});
4181
          $val =~ s/\\/\//g;
-
 
4182
        }
-
 
4183
 
4299
 
4184
        ## Here we make an assumption that if we convert slashes to
-
 
4185
        ## back-slashes, we also have a case-insensitive file system.
-
 
4186
        my($icwd) = ($self->{'convert_slashes'} ? lc($cwd) : $cwd);
4300
        my($icwd) = ($self->{'case_insensitive'} ? lc($cwd) : $cwd);
4187
        my($ival) = ($self->{'convert_slashes'} ? lc($val) : $val);
4301
        my($ival) = ($self->{'case_insensitive'} ? lc($val) : $val);
4188
        my($iclen) = length($icwd);
4302
        my($iclen) = length($icwd);
4189
        my($ivlen) = length($ival);
4303
        my($ivlen) = length($ival);
4190
 
4304
 
4191
        ## If the relative value contains the current working
4305
        ## If the relative value contains the current working
4192
        ## directory plus additional subdirectories, we must pull
4306
        ## directory plus additional subdirectories, we must pull
Line 4215... Line 4329...
4215
            $ival =~ s/\/$//;
4329
            $ival =~ s/\/$//;
4216
          }
4330
          }
4217
          if (defined $append) {
4331
          if (defined $append) {
4218
            $ival .= $append;
4332
            $ival .= $append;
4219
          }
4333
          }
4220
          if ($self->{'convert_slashes'}) {
4334
          $ival =~ s/\//\\/g if ($self->{'convert_slashes'});
4221
            $ival = $self->slash_to_backslash($ival);
-
 
4222
          }
-
 
4223
          substr($value, $start) =~ s/\$\([^)]+\)/$ival/;
4335
          substr($value, $start) =~ s/\$\([^)]+\)/$ival/;
4224
          $whole = $ival;
4336
          $whole = $ival;
4225
        }
4337
        }
4226
      }
4338
      }
4227
    }
4339
    }
Line 4234... Line 4346...
4234
      my($sname) = (defined $scope ? $scope . "::$name" : undef);
4346
      my($sname) = (defined $scope ? $scope . "::$name" : undef);
4235
      my($arr) = $self->adjust_value([$sname, $name],
4347
      my($arr) = $self->adjust_value([$sname, $name],
4236
                                     (defined $val ? $val : []));
4348
                                     (defined $val ? $val : []));
4237
      if (defined $$arr[0]) {
4349
      if (defined $$arr[0]) {
4238
        $val = "@$arr";
4350
        $val = "@$arr";
4239
        if ($self->{'convert_slashes'}) {
4351
        $val =~ s/\//\\/g if ($self->{'convert_slashes'});
4240
          $val = $self->slash_to_backslash($val);
-
 
4241
        }
-
 
4242
        substr($value, $start) =~ s/\$\([^)]+\)/$val/;
4352
        substr($value, $start) =~ s/\$\([^)]+\)/$val/;
4243
 
4353
 
4244
        ## We have replaced the template value, but that template
4354
        ## We have replaced the template value, but that template
4245
        ## value may contain a $() construct that may need to get
4355
        ## value may contain a $() construct that may need to get
4246
        ## replaced too.
4356
        ## replaced too.
Line 4277... Line 4387...
4277
          push(@built, $rel);
4387
          push(@built, $rel);
4278
        }
4388
        }
4279
      }
4389
      }
4280
      $value = \@built;
4390
      $value = \@built;
4281
    }
4391
    }
4282
    elsif ($value =~ /\$/) {
4392
    elsif (index($value, '$') >= 0) {
4283
      my($ovalue) = $value;
4393
      my($ovalue) = $value;
4284
      my(@keys) = keys %{$self->{'expanded'}};
4394
      my(@keys) = keys %{$self->{'expanded'}};
4285
      if (defined $keys[0]) {
4395
      if (defined $keys[0]) {
4286
        $value = $self->expand_variables($value, \@keys,
4396
        $value = $self->expand_variables($value,
4287
                                         $self->{'expanded'},
4397
                                         $self->{'expanded'},
4288
                                         $expand_template, $scope, 1);
4398
                                         $expand_template, $scope, 1);
4289
      }
4399
      }
4290
 
4400
 
4291
      if ($ovalue eq $value) {
4401
      if ($ovalue eq $value) {
4292
        my($rel) = ($self->get_use_env() ? \%ENV : $self->get_relative());
4402
        my($rel) = ($self->get_use_env() ? \%ENV : $self->get_relative());
4293
        @keys = keys %$rel;
4403
        @keys = keys %$rel;
4294
        if (defined $keys[0]) {
4404
        if (defined $keys[0]) {
4295
          $value = $self->expand_variables($value, \@keys, $rel,
4405
          $value = $self->expand_variables($value, $rel,
4296
                                           $expand_template, $scope,
4406
                                           $expand_template, $scope,
4297
                                           $self->get_expand_vars(), 1);
4407
                                           $self->get_expand_vars(), 1);
4298
        }
4408
        }
4299
      }
4409
      }
4300
    }
4410
    }
Line 4447... Line 4557...
4447
sub project_file_name {
4557
sub project_file_name {
4448
  my($self) = shift;
4558
  my($self) = shift;
4449
  my($name) = shift;
4559
  my($name) = shift;
4450
 
4560
 
4451
  if (!defined $name) {
4561
  if (!defined $name) {
4452
    $name = $self->project_name();
4562
    $name = $self->get_assignment('project_name');
4453
  }
4563
  }
4454
 
4564
 
4455
  return $self->get_modified_project_file_name(
4565
  return $self->get_modified_project_file_name(
4456
                                     $self->project_file_prefix() . $name,
4566
                                     $self->project_file_prefix() . $name,
4457
                                     $self->project_file_extension());
4567
                                     $self->project_file_extension());
Line 4499... Line 4609...
4499
 
4609
 
4500
# ************************************************************
4610
# ************************************************************
4501
# Virtual Methods To Be Overridden
4611
# Virtual Methods To Be Overridden
4502
# ************************************************************
4612
# ************************************************************
4503
 
4613
 
-
 
4614
sub post_file_creation {
-
 
4615
  #my($self) = shift;
-
 
4616
  #my($file) = shift;
-
 
4617
}
-
 
4618
 
-
 
4619
 
4504
sub escape_spaces {
4620
sub escape_spaces {
4505
  #my($self) = shift;
4621
  #my($self) = shift;
4506
  return 0;
4622
  return 0;
4507
}
4623
}
4508
 
4624
 
Line 4513... Line 4629...
4513
  return $dir;
4629
  return $dir;
4514
}
4630
}
4515
 
4631
 
4516
sub get_quote_symbol {
4632
sub get_quote_symbol {
4517
  #my($self) = shift;
4633
  #my($self) = shift;
4518
  return '"';
4634
  return '\\"';
4519
}
4635
}
4520
 
4636
 
4521
sub get_gt_symbol {
4637
sub get_gt_symbol {
4522
  #my($self) = shift;
4638
  #my($self) = shift;
4523
  return '>';
4639
  return '>';