Subversion Repositories gelsvn

Rev

Rev 107 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 107 Rev 198
Line 86... Line 86...
86
                      'template_pre_extension'      => 0x08,
86
                      'template_pre_extension'      => 0x08,
87
                      'header_pre_extension'        => 0x08,
87
                      'header_pre_extension'        => 0x08,
88
                      'inline_pre_extension'        => 0x08,
88
                      'inline_pre_extension'        => 0x08,
89
                      'documentation_pre_extension' => 0x08,
89
                      'documentation_pre_extension' => 0x08,
90
                      'resource_pre_extension'      => 0x08,
90
                      'resource_pre_extension'      => 0x08,
-
 
91
                      'generic_pre_extension'       => 0x08,
91
                      'pre_filename'                => 0x08,
92
                      'pre_filename'                => 0x08,
92
                      'source_pre_filename'         => 0x08,
93
                      'source_pre_filename'         => 0x08,
93
                      'template_pre_filename'       => 0x08,
94
                      'template_pre_filename'       => 0x08,
94
                      'header_pre_filename'         => 0x08,
95
                      'header_pre_filename'         => 0x08,
95
                      'inline_pre_filename'         => 0x08,
96
                      'inline_pre_filename'         => 0x08,
96
                      'documentation_pre_filename'  => 0x08,
97
                      'documentation_pre_filename'  => 0x08,
97
                      'resource_pre_filename'       => 0x08,
98
                      'resource_pre_filename'       => 0x08,
-
 
99
                      'generic_pre_filename'        => 0x08,
98
                      'source_outputext'            => 0x0a,
100
                      'source_outputext'            => 0x0a,
99
                      'template_outputext'          => 0x0a,
101
                      'template_outputext'          => 0x0a,
100
                      'header_outputext'            => 0x0a,
102
                      'header_outputext'            => 0x0a,
101
                      'inline_outputext'            => 0x0a,
103
                      'inline_outputext'            => 0x0a,
102
                      'documentation_outputext'     => 0x0a,
104
                      'documentation_outputext'     => 0x0a,
Line 268... Line 270...
268
  $self->{'defaulted'}             = {};
270
  $self->{'defaulted'}             = {};
269
  $self->{'custom_types'}          = {};
271
  $self->{'custom_types'}          = {};
270
  $self->{'parents_read'}          = {};
272
  $self->{'parents_read'}          = {};
271
  $self->{'inheritance_tree'}      = {};
273
  $self->{'inheritance_tree'}      = {};
272
  $self->{'remove_files'}          = {};
274
  $self->{'remove_files'}          = {};
-
 
275
  $self->{'expanded'}              = {};
273
 
276
 
274
  my($typefeaturef) = dirname($gfeature) . '/' .
277
  my($typefeaturef) = $self->mpc_dirname($gfeature) . '/' .
275
                      $self->{'pctype'} . '.features';
278
                      $self->{'pctype'} . '.features';
276
  $typefeaturef = undef if (! -r $typefeaturef);
279
  $typefeaturef = undef if (! -r $typefeaturef);
277
  $self->{'feature_parser'}        = new FeatureParser($features,
280
  $self->{'feature_parser'}        = new FeatureParser($features,
278
                                                       $gfeature,
281
                                                       $gfeature,
279
                                                       $typefeaturef,
282
                                                       $typefeaturef,
Line 627... Line 630...
627
            $self->{'parents_read'}          = {};
630
            $self->{'parents_read'}          = {};
628
            $self->{'inheritance_tree'}      = {};
631
            $self->{'inheritance_tree'}      = {};
629
            $self->{'remove_files'}          = {};
632
            $self->{'remove_files'}          = {};
630
            $self->{'custom_special_output'} = {};
633
            $self->{'custom_special_output'} = {};
631
            $self->{'custom_special_depend'} = {};
634
            $self->{'custom_special_depend'} = {};
-
 
635
            $self->{'expanded'}              = {};
632
            $self->reset_generating_types();
636
            $self->reset_generating_types();
633
          }
637
          }
634
        }
638
        }
635
        $self->{$typecheck} = 0;
639
        $self->{$typecheck} = 0;
636
      }
640
      }
Line 732... Line 736...
732
        elsif ($comp eq 'specific') {
736
        elsif ($comp eq 'specific') {
733
          my($type) = $self->get_process_project_type($name);
737
          my($type) = $self->get_process_project_type($name);
734
          if ($type eq $self->{'pctype'} ||
738
          if ($type eq $self->{'pctype'} ||
735
              $type eq $self->get_default_component_name()) {
739
              $type eq $self->get_default_component_name()) {
736
            ($status, $errorString) = $self->parse_scope(
740
            ($status, $errorString) = $self->parse_scope(
737
                                        $ih, $values[1], $type,
741
                                        $ih, $comp, $type,
738
                                        $self->{'valid_names'},
742
                                        $self->{'valid_names'},
739
                                        $self->get_assignment_hash(),
743
                                        $self->get_assignment_hash(),
740
                                        {});
744
                                        {});
741
          }
745
          }
742
          else {
746
          else {
743
            ## We still need to parse the scope, but we will be
747
            ## We still need to parse the scope, but we will be
744
            ## throwing away whatever is processed.  However, it
748
            ## throwing away whatever is processed.  However, it
745
            ## could still be invalid code that will cause an error.
749
            ## could still be invalid code that will cause an error.
746
            ($status, $errorString) = $self->parse_scope(
750
            ($status, $errorString) = $self->parse_scope(
747
                                        $ih, $values[1], undef,
751
                                        $ih, $comp, undef,
748
                                        $self->{'valid_names'},
752
                                        $self->{'valid_names'},
749
                                        undef,
753
                                        undef,
750
                                        $self->get_assignment_hash());
754
                                        $self->get_assignment_hash());
751
          }
755
          }
752
        }
756
        }
753
        elsif ($comp eq 'define_custom') {
757
        elsif ($comp eq 'define_custom') {
754
          ($status, $errorString) = $self->parse_define_custom($ih, $name);
758
          ($status, $errorString) = $self->parse_define_custom($ih, $name);
755
        }
759
        }
-
 
760
        elsif ($comp eq 'expand') {
-
 
761
          ($status, $errorString) = $self->parse_scope($ih, $comp, $name);
-
 
762
        }
756
        else {
763
        else {
757
          $errorString = "Invalid component name: $comp";
764
          $errorString = "Invalid component name: $comp";
758
          $status = 0;
765
          $status = 0;
759
        }
766
        }
760
      }
767
      }
Line 876... Line 883...
876
 
883
 
877
  return 1, undef;
884
  return 1, undef;
878
}
885
}
879
 
886
 
880
 
887
 
-
 
888
sub handle_scoped_unknown {
-
 
889
  my($self)  = shift;
-
 
890
  my($fh)    = shift;
-
 
891
  my($type)  = shift;
-
 
892
  my($flags) = shift;
-
 
893
  my($line)  = shift;
-
 
894
 
-
 
895
  if (defined $type) {
-
 
896
    if ($type eq $self->get_default_component_name()) {
-
 
897
      return 0, 'Can not set expansion in this context';
-
 
898
    }
-
 
899
    else {
-
 
900
      if (!defined $self->{'expanded'}->{$type}) {
-
 
901
        my($ok) = 1;
-
 
902
        while($line =~ /\$(\w+)/) {
-
 
903
          my($name) = $1;
-
 
904
          my($val)  = '';
-
 
905
          if ($name eq 'PWD') {
-
 
906
            $val = $self->getcwd();
-
 
907
          }
-
 
908
          elsif (defined $ENV{$name}) {
-
 
909
            $val = $ENV{$name};
-
 
910
          }
-
 
911
          else {
-
 
912
            $ok = undef;
-
 
913
            last;
-
 
914
          }
-
 
915
          $line =~ s/\$\w+/$val/;
-
 
916
        }
-
 
917
        $self->{'expanded'}->{$type} = $line if ($ok);
-
 
918
      }
-
 
919
      return 1, undef;
-
 
920
    }
-
 
921
  }
-
 
922
 
-
 
923
  ## If the type is not defined, then this is something other than an
-
 
924
  ## assignment in a 'specific' section and should be flagged as an error
-
 
925
  return 0, "Unrecognized line: $line";
-
 
926
}
-
 
927
 
881
sub process_component_line {
928
sub process_component_line {
882
  my($self)    = shift;
929
  my($self)    = shift;
883
  my($tag)     = shift;
930
  my($tag)     = shift;
884
  my($line)    = shift;
931
  my($line)    = shift;
885
  my($flags)   = shift;
932
  my($flags)   = shift;
Line 960... Line 1007...
960
    my(@files) = ();
1007
    my(@files) = ();
961
    if ($line =~ /^"([^"]+)"$/) {
1008
    if ($line =~ /^"([^"]+)"$/) {
962
      push(@files, $1);
1009
      push(@files, $1);
963
    }
1010
    }
964
    elsif ($line =~ /[\?\*\[\]]/) {
1011
    elsif ($line =~ /[\?\*\[\]]/) {
965
      @files = glob($line);
1012
      @files = $self->mpc_glob($line);
966
    }
1013
    }
967
    else {
1014
    else {
968
      push(@files, $line);
1015
      push(@files, $line);
969
    }
1016
    }
970
 
1017
 
Line 1200... Line 1247...
1200
  if ($status && $#exclude != -1 && defined $grname) {
1247
  if ($status && $#exclude != -1 && defined $grname) {
1201
    my($alldir)  = $self->get_assignment('recurse') || $flags{'recurse'};
1248
    my($alldir)  = $self->get_assignment('recurse') || $flags{'recurse'};
1202
    my(%checked) = ();
1249
    my(%checked) = ();
1203
    my(@files)   = ();
1250
    my(@files)   = ();
1204
    foreach my $exc (@exclude) {
1251
    foreach my $exc (@exclude) {
1205
      my($dname) = dirname($exc);
1252
      my($dname) = $self->mpc_dirname($exc);
1206
      if (!defined $checked{$dname}) {
1253
      if (!defined $checked{$dname}) {
1207
        $checked{$dname} = 1;
1254
        $checked{$dname} = 1;
1208
        push(@files, $self->generate_default_file_list($dname,
1255
        push(@files, $self->generate_default_file_list($dname,
1209
                                                       \@exclude, $alldir));
1256
                                                       \@exclude, $alldir));
1210
      }
1257
      }
Line 1612... Line 1659...
1612
      ## need to get the modified assignment value before we attempt to
1659
      ## need to get the modified assignment value before we attempt to
1613
      ## do so.
1660
      ## do so.
1614
      $value = $self->modify_assignment_value($name, $value);
1661
      $value = $self->modify_assignment_value($name, $value);
1615
      foreach my $val (@{$self->create_array($value)}) {
1662
      foreach my $val (@{$self->create_array($value)}) {
1616
        if (!exists $parts{$val}) {
1663
        if (!exists $parts{$val}) {
-
 
1664
          my($qt) = ($val =~ /\s/ ? '"' : '');
1617
          $allowed .= $val . ' ';
1665
          $allowed .= $qt . $val . $qt . ' ';
1618
        }
1666
        }
1619
      }
1667
      }
1620
      $allowed =~ s/\s+$//;
1668
      $allowed =~ s/\s+$//;
1621
      return $allowed;
1669
      return $allowed;
1622
    }
1670
    }
Line 2510... Line 2558...
2510
                  my(@front) = ();
2558
                  my(@front) = ();
2511
                  my(@copy)  = @$array;
2559
                  my(@copy)  = @$array;
2512
 
2560
 
2513
                  @$array = ();
2561
                  @$array = ();
2514
                  foreach my $input (@input) {
2562
                  foreach my $input (@input) {
2515
                    my($part) = $input;
2563
                    my($part) = $self->remove_wanted_extension(
2516
                    foreach my $wanted (@{$self->{'valid_components'}->{$gentype}}) {
-
 
2517
                      if ($part =~ s/$wanted$//) {
2564
                                   $input,
2518
                        last;
2565
                                   $self->{'valid_components'}->{$gentype});
2519
                      }
-
 
2520
                    }
-
 
-
 
2566
 
2521
                    $part = $self->escape_regex_special($part);
2567
                    $part = $self->escape_regex_special($part);
2522
                    my(@files) = $self->generated_filenames($part, $gentype,
2568
                    my(@files) = $self->generated_filenames($part, $gentype,
2523
                                                            $tag, $input, 1);
2569
                                                            $tag, $input, 1);
2524
                    if ($#copy != -1) {
2570
                    if ($#copy != -1) {
2525
                      my($found) = 0;
2571
                      my($found) = 0;
Line 2678... Line 2724...
2678
          if ($key ne $defgroup) {
2724
          if ($key ne $defgroup) {
2679
            $group = $key;
2725
            $group = $key;
2680
          }
2726
          }
2681
 
2727
 
2682
          foreach my $val (@$array) {
2728
          foreach my $val (@$array) {
2683
            my($f) = $val;
2729
            my($f) = $self->remove_wanted_extension(
2684
            foreach my $wanted (@{$self->{'valid_components'}->{$gentype}}) {
-
 
2685
              if ($f =~ s/$wanted$//) {
2730
                              $val,
2686
                last;
-
 
2687
              }
-
 
2688
            }
-
 
2689
 
-
 
2690
            ## If the user provided file does not match any of the
2731
                              $self->{'valid_components'}->{$gentype});
2691
            ## extensions specified by the custom definition, we need
-
 
2692
            ## to remove the extension or else this file will not be
-
 
2693
            ## added to the project.
-
 
2694
            if ($f eq $val) {
-
 
2695
              $f =~ s/\.[^\.]+$//;
-
 
2696
            }
-
 
2697
 
-
 
2698
            push(@arr, $f);
2732
            push(@arr, $f);
2699
          }
2733
          }
2700
        }
2734
        }
2701
      }
2735
      }
2702
 
2736
 
Line 4109... Line 4143...
4109
 
4143
 
4110
  return $value;
4144
  return $value;
4111
}
4145
}
4112
 
4146
 
4113
 
4147
 
4114
sub relative {
4148
sub expand_variables {
4115
  my($self)            = shift;
4149
  my($self)            = shift;
4116
  my($value)           = shift;
4150
  my($value)           = shift;
-
 
4151
  my($keys)            = shift;
-
 
4152
  my($rel)             = shift;
4117
  my($expand_template) = shift;
4153
  my($expand_template) = shift;
4118
  my($scope)           = shift;
4154
  my($scope)           = shift;
4119
 
-
 
4120
  if (defined $value) {
-
 
4121
    if (UNIVERSAL::isa($value, 'ARRAY')) {
-
 
4122
      my(@built) = ();
-
 
4123
      foreach my $val (@$value) {
-
 
4124
        push(@built, $self->relative($val, $expand_template, $scope));
-
 
4125
      }
-
 
4126
      $value = \@built;
4155
  my($expand)          = shift;
4127
    }
-
 
4128
    elsif ($value =~ /\$/) {
-
 
4129
      my($useenv) = $self->get_use_env();
-
 
4130
      my($rel)    = ($useenv ? \%ENV : $self->get_relative());
-
 
4131
      my(@keys)   = keys %$rel;
4156
  my($warn)            = shift;
4132
 
-
 
4133
      if (defined $keys[0]) {
-
 
4134
        my($expand) = $self->get_expand_vars();
-
 
4135
        my($cwd)    = $self->getcwd();
4157
  my($cwd)             = $self->getcwd();
4136
        my($start)  = 0;
4158
  my($start)           = 0;
4137
 
4159
 
4138
        ## Fix up the value for Windows switch the \\'s to /
4160
  ## Fix up the value for Windows switch the \\'s to /
4139
        if ($self->{'convert_slashes'}) {
4161
  if ($self->{'convert_slashes'}) {
Line 4223... Line 4245...
4223
              ## value may contain a $() construct that may need to get
4245
        ## value may contain a $() construct that may need to get
4224
              ## replaced too.
4246
        ## replaced too.
4225
              $whole = '';
4247
        $whole = '';
4226
            }
4248
      }
4227
            else {
4249
      else {
4228
              if ($expand) {
4250
        if ($expand && $warn) {
4229
                $self->warning("Unable to expand $name.");
4251
          $self->warning("Unable to expand $name.");
4230
              }
4252
        }
4231
            }
4253
      }
4232
          }
4254
    }
4233
          $start += length($whole);
4255
    $start += length($whole);
4234
        }
4256
  }
-
 
4257
 
-
 
4258
  return $value;
4235
      }
4259
}
-
 
4260
 
-
 
4261
 
-
 
4262
sub relative {
-
 
4263
  my($self)            = shift;
-
 
4264
  my($value)           = shift;
-
 
4265
  my($expand_template) = shift;
-
 
4266
  my($scope)           = shift;
-
 
4267
 
-
 
4268
  if (defined $value) {
-
 
4269
    if (UNIVERSAL::isa($value, 'ARRAY')) {
-
 
4270
      my(@built) = ();
-
 
4271
      foreach my $val (@$value) {
-
 
4272
        my($rel) = $self->relative($val, $expand_template, $scope);
-
 
4273
        if (UNIVERSAL::isa($rel, 'ARRAY')) {
-
 
4274
          push(@built, @$rel);
-
 
4275
        }
-
 
4276
        else {
-
 
4277
          push(@built, $rel);
-
 
4278
        }
-
 
4279
      }
-
 
4280
      $value = \@built;
4236
    }
4281
    }
-
 
4282
    elsif ($value =~ /\$/) {
-
 
4283
      my($ovalue) = $value;
-
 
4284
      my(@keys) = keys %{$self->{'expanded'}};
-
 
4285
      if (defined $keys[0]) {
-
 
4286
        $value = $self->expand_variables($value, \@keys,
-
 
4287
                                         $self->{'expanded'},
-
 
4288
                                         $expand_template, $scope, 1);
-
 
4289
      }
-
 
4290
 
-
 
4291
      if ($ovalue eq $value) {
-
 
4292
        my($rel) = ($self->get_use_env() ? \%ENV : $self->get_relative());
-
 
4293
        @keys = keys %$rel;
-
 
4294
        if (defined $keys[0]) {
-
 
4295
          $value = $self->expand_variables($value, \@keys, $rel,
-
 
4296
                                           $expand_template, $scope,
-
 
4297
                                           $self->get_expand_vars(), 1);
-
 
4298
        }
-
 
4299
      }
-
 
4300
    }
-
 
4301
  }
-
 
4302
 
-
 
4303
  ## Values that have strings enclosed in double quotes are to
-
 
4304
  ## be interpreted as elements of an array
-
 
4305
  if (defined $value && $value =~ /^"[^"]+"(\s+"[^"]+")+$/) {
-
 
4306
    $value = $self->create_array($value);
4237
  }
4307
  }
4238
 
4308
 
4239
  return $value;
4309
  return $value;
4240
}
4310
}
4241
 
4311
 
Line 4401... Line 4471...
4401
  $self->process_assignment('exename',    undef);
4471
  $self->process_assignment('exename',    undef);
4402
  $self->process_assignment('sharedname', undef);
4472
  $self->process_assignment('sharedname', undef);
4403
  $self->process_assignment('staticname', undef);
4473
  $self->process_assignment('staticname', undef);
4404
}
4474
}
4405
 
4475
 
-
 
4476
 
-
 
4477
sub remove_wanted_extension {
-
 
4478
  my($self)  = shift;
-
 
4479
  my($name)  = shift;
-
 
4480
  my($array) = shift;
-
 
4481
  my($orig)  = $name;
-
 
4482
 
-
 
4483
  foreach my $wanted (@$array) {
-
 
4484
    if ($name =~ s/$wanted$//) {
-
 
4485
      last;
-
 
4486
    }
-
 
4487
  }
-
 
4488
 
-
 
4489
  ## If the user provided file does not match any of the
-
 
4490
  ## extensions specified by the custom definition, we need
-
 
4491
  ## to remove the extension or else this file will not be
-
 
4492
  ## added to the project.
-
 
4493
  if ($name eq $orig) {
-
 
4494
    $name =~ s/\.[^\.]+$//;
-
 
4495
  }
-
 
4496
 
-
 
4497
  return $name;
-
 
4498
}
-
 
4499
 
4406
# ************************************************************
4500
# ************************************************************
4407
# Virtual Methods To Be Overridden
4501
# Virtual Methods To Be Overridden
4408
# ************************************************************
4502
# ************************************************************
4409
 
4503
 
4410
sub escape_spaces {
4504
sub escape_spaces {