diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-09-16 16:50:31 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-09-16 16:50:31 +0000 |
commit | 25949958531eb4353d80b520ca327d1d8c971cc6 (patch) | |
tree | 7adf74fd2a5f026351bc0dca4be8a0222cb42089 | |
parent | 9af0fb9f3511c2bdd5f6d477cb5ab63dc3624927 (diff) | |
download | MPC-25949958531eb4353d80b520ca327d1d8c971cc6.tar.gz |
ChangeLogTag: Tue Sep 16 11:49:19 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/AutomakeProjectCreator.pm | 4 | ||||
-rw-r--r-- | modules/Creator.pm | 64 | ||||
-rw-r--r-- | modules/FeatureParser.pm | 2 | ||||
-rw-r--r-- | modules/Parser.pm | 22 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 70 | ||||
-rw-r--r-- | modules/TemplateInputReader.pm | 4 | ||||
-rw-r--r-- | modules/TemplateParser.pm | 47 | ||||
-rw-r--r-- | modules/VC71WorkspaceCreator.pm | 4 | ||||
-rw-r--r-- | modules/VC7WorkspaceCreator.pm | 6 | ||||
-rw-r--r-- | modules/WorkspaceCreator.pm | 25 |
10 files changed, 90 insertions, 158 deletions
diff --git a/modules/AutomakeProjectCreator.pm b/modules/AutomakeProjectCreator.pm index a0c95fa4..2266e858 100644 --- a/modules/AutomakeProjectCreator.pm +++ b/modules/AutomakeProjectCreator.pm @@ -44,7 +44,7 @@ sub fill_value { my($names) = $self->{'source_files'}; foreach my $name (keys %$names) { my($comps) = $$names{$name}; - foreach my $key (sort keys %$comps) { + foreach my $key (keys %$comps) { foreach my $item (@{$$comps{$key}}) { my($dname) = dirname($item); if ($dname ne '.' && $dname !~ /^\.\.\//) { @@ -53,7 +53,7 @@ sub fill_value { } } } - my($str) = join(':', keys %vpath); + my($str) = join(':', sort keys %vpath); if ($str ne '') { $value = 'VPATH = .:' . $str . $self->crlf(); } diff --git a/modules/Creator.pm b/modules/Creator.pm index c97af376..21071be4 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -119,28 +119,28 @@ sub generate_default_input { sub parse_file { - my($self) = shift; - my($input) = shift; - my($typecheck) = $self->{'type_check'}; - my($oline) = $self->line_number(); + my($self) = shift; + my($input) = shift; + my($oline) = $self->get_line_number(); ## Read the input file and get the last line number my($status, $errorString) = $self->read_file($input); - my($linenumber) = $self->line_number(); if (!$status) { print STDERR $self->getcwd() . - "/$input: line $linenumber:\n$errorString\n"; + "/$input: line " . $self->get_line_number() . + ":\n$errorString\n"; } - elsif ($status && $self->{$typecheck}) { + elsif ($status && $self->{$self->{'type_check'}}) { ## If we are at the end of the file and the type we are looking at ## is still defined, then we have an error print STDERR $self->getcwd() . - "/$input: line $linenumber:\nERROR: Did not " . + "/$input: line " . $self->get_line_number() . + ":\nERROR: Did not " . "find the end of the $self->{'grammar_type'}\n"; $status = 0; } - $self->line_number($oline); + $self->set_line_number($oline); return $status; } @@ -187,15 +187,15 @@ sub parse_assignment { my($values) = shift; my($status) = 1; - if ($line =~ /^(\w+)\s*=\s*(.*)?/) { + if ($line =~ /^(\w+)\s*\+=\s*(.*)?/) { my($name) = lc($1); my($value) = $2; - push(@$values, 'assignment', $name, $value); + push(@$values, 'assign_add', $name, $value); } - elsif ($line =~ /^(\w+)\s*\+=\s*(.*)?/) { + elsif ($line =~ /^(\w+)\s*=\s*(.*)?/) { my($name) = lc($1); my($value) = $2; - push(@$values, 'assign_add', $name, $value); + push(@$values, 'assignment', $name, $value); } elsif ($line =~ /^(\w+)\s*\-=\s*(.*)?/) { my($name) = lc($1); @@ -217,7 +217,6 @@ sub parse_known { my($errorString) = ''; my($type) = $self->{'grammar_type'}; my(@values) = (); - my($typecheck) = $self->{'type_check'}; ## ## Each regexp that looks for the '{' looks for it at the @@ -231,14 +230,15 @@ sub parse_known { elsif ($line =~ /^$type\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) { my($name) = $1; my($parents) = $2; - if ($self->{$typecheck}) { + if ($self->{$self->{'type_check'}}) { $errorString = "ERROR: Did not find the end of the $type"; $status = 0; } else { if (defined $parents) { my(@parents) = (); - foreach my $parent (split(/[:,]/, $parents)) { + $parents =~ s/^://; + foreach my $parent (split(',', $parents)) { $parent =~ s/^\s+//; $parent =~ s/\s+$//; if ($parent ne '') { @@ -257,7 +257,7 @@ sub parse_known { } } elsif ($line =~ /^}$/) { - if ($self->{$typecheck}) { + if ($self->{$self->{'type_check'}}) { push(@values, $type, $line); } else { @@ -271,7 +271,7 @@ sub parse_known { my(@names) = split(/\s*,\s*/, $name); push(@values, $type, \@names); } - elsif (!$self->{$typecheck}) { + elsif (!$self->{$self->{'type_check'}}) { $errorString = "ERROR: No $type was defined"; $status = 0; } @@ -419,8 +419,7 @@ sub transform_file_name { sub file_written { my($self) = shift; my($file) = shift; - my($full) = $self->getcwd() . '/' . $file; - return (defined $all_written{$full}); + return (defined $all_written{$self->getcwd() . '/' . $file}); } @@ -437,8 +436,7 @@ sub add_file_written { } push(@{$self->{'files_written'}}, $file); - my($full) = $self->getcwd() . '/' . $file; - $all_written{$full} = 1; + $all_written{$self->getcwd() . '/' . $file} = 1; } @@ -482,17 +480,18 @@ sub process_assignment { my($name) = shift; my($value) = shift; my($assign) = shift; - my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign'); + ## If no hash table was passed in if (!defined $assign) { - $assign = $self->{$tag}; - } + my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign'); + $assign = $self->{$tag}; - ## If we haven't yet defined the hash table in this project - if (!defined $assign) { - $assign = {}; - $self->{$tag} = $assign; + ## If we haven't yet defined the hash table in this project + if (!defined $assign) { + $assign = {}; + $self->{$tag} = $assign; + } } if (defined $value) { @@ -500,10 +499,11 @@ sub process_assignment { $value =~ s/\s+$//; ## Modify the assignment value before saving it - $value = $self->modify_assignment_value($value); + $$assign{$name} = $self->modify_assignment_value($value); + } + else { + $$assign{$name} = undef; } - - $$assign{$name} = $value; } diff --git a/modules/FeatureParser.pm b/modules/FeatureParser.pm index 4f232b63..c5d608bc 100644 --- a/modules/FeatureParser.pm +++ b/modules/FeatureParser.pm @@ -37,7 +37,7 @@ sub new { if (!$status) { ## We only want to warn the user about problems ## with the feature file. - my($lnumber) = $self->line_number(); + my($lnumber) = $self->get_line_number(); $warn =~ s/ERROR/WARNING/; print "$f: line $lnumber:\n$warn\n"; } diff --git a/modules/Parser.pm b/modules/Parser.pm index 25a2a1b1..7977ae1a 100644 --- a/modules/Parser.pm +++ b/modules/Parser.pm @@ -127,15 +127,16 @@ sub read_file { } -sub line_number { - my($self) = shift; - my($number) = shift; +sub get_line_number { + my($self) = shift; + return $self->{'line_number'}; +} - if (defined $number) { - $self->{'line_number'} = $number; - } - return $self->{'line_number'}; +sub set_line_number { + my($self) = shift; + my($number) = shift; + $self->{'line_number'} = $number; } @@ -156,15 +157,14 @@ sub get_include_path { sub search_include_path { my($self) = shift; my($file) = shift; - my($found) = undef; foreach my $include ('.', @{$self->{'include'}}) { if (-r "$include/$file") { - $found = "$include/$file"; - last; + return "$include/$file"; } } - return $found; + + return undef; } diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index fa0e5589..d0d6c399 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -218,7 +218,6 @@ sub parse_line { my($self) = shift; my($ih) = shift; my($line) = shift; - my($type) = $self->{'grammar_type'}; my($status, $errorString, @values) = $self->parse_known($line); @@ -230,7 +229,7 @@ sub parse_line { ## sort. if ($status && defined $values[0]) { - if ($values[0] eq $type) { + if ($values[0] eq $self->{'grammar_type'}) { my($name) = $values[1]; my($typecheck) = $self->{'type_check'}; if (defined $name && $name eq '}') { @@ -267,19 +266,8 @@ sub parse_line { } if ($status) { -# ## Now add in the features that have been defined -# $self->{$typecheck} = 0; -# $self->{'type_specific_assign'} = {}; -# ($status, $errorString) = $self->process_features(); -# -# if ($status) { -# ## If the feature added any type specific assignments -# ## then we need to processs them before we write the project -# $self->process_type_specific_assignments(); - - ## End of project; Write out the file. - ($status, $errorString) = $self->write_project(); -# } + ## End of project; Write out the file. + ($status, $errorString) = $self->write_project(); foreach my $key (keys %{$self->{'valid_components'}}) { delete $self->{$key}; @@ -641,8 +629,7 @@ sub parse_components { if (defined $over) { $$over{$line} = \%flags; } - my($array) = $$comps{$current}; - push(@$array, $line); + push(@{$$comps{$current}}, $line); } } else { @@ -674,11 +661,9 @@ sub parse_verbatim { while($_ = $fh->getline()) { my($line) = $self->strip_line($_); - if ($line eq '') { - } - elsif ($line =~ /^}/) { + if ($line =~ /^}/) { ## This is not an error, - ## this is the end of the components + ## this is the end of the verbatim last; } else { @@ -690,35 +675,6 @@ sub parse_verbatim { } -#sub save_feature { -# my($self) = shift; -# my($fh) = shift; -# my($names) = shift; -# my(@lines) = ("project {\n"); -# my($curly) = 1; -# -# while($_ = $fh->getline()) { -# my($line) = $self->strip_line($_); -# push(@lines, "$line\n"); -# -# ## This is a very simplistic way of finding the end of -# ## the feature definition. It will work as long as no spurious -# ## open curly braces are counted. -# if ($line =~ /{$/) { -# ++$curly; -# } -# elsif ($line =~ /^}$/) { -# --$curly; -# } -# if ($curly == 0) { -# $self->{'feature_defined'} = 0; -# last; -# } -# } -# push(@{$self->{'feature_definitions'}}, [ $names, \@lines ]); -#} - - sub process_feature { my($self) = shift; my($fh) = shift; @@ -1491,7 +1447,6 @@ sub generated_source_listed { my($arr) = shift; my($names) = $self->{$tag}; my(@gen) = $self->generated_extensions($gent, $tag); - my(@found) = (); ## Find out which generated source files are listed foreach my $name (keys %$names) { @@ -1503,14 +1458,15 @@ sub generated_source_listed { foreach my $i (@$arr) { my($ifile) = $self->escape_regex_special($i); if ($val =~ /$ifile$ext$/) { - push(@found, $val); + return 1; } } } } } } - return (defined $found[0]); + + return 0; } @@ -1868,17 +1824,17 @@ sub get_grouped_value { my($based) = shift; my($value) = undef; + ## Make it all lowercase + $type = lc($type); + ## Remove the grouped_ part $type =~ s/^$grouped_key//; ## Add the s if it isn't there - if ($type !~ /s$/i) { + if ($type !~ /s$/) { $type .= 's'; } - ## Make it all lowercase - $type = lc($type); - my($names) = $self->{$type}; if ($cmd eq 'files') { foreach my $name (keys %$names) { diff --git a/modules/TemplateInputReader.pm b/modules/TemplateInputReader.pm index 40f663ca..3dbd7d4f 100644 --- a/modules/TemplateInputReader.pm +++ b/modules/TemplateInputReader.pm @@ -119,9 +119,9 @@ sub parse_line { elsif ($line =~ /^conditional_include\s+"([\w\s\-\+\/\\\.]+)"$/) { my($file) = $self->search_include_path("$1.$mpt"); if (defined $file) { - my($ol) = $self->{'line_number'}; + my($ol) = $self->get_line_number(); ($status, $errorString) = $self->read_file($file); - $self->{'line_number'} = $ol; + $self->set_line_number($ol); } } else { diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index 042c368f..621d39fb 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -54,7 +54,8 @@ sub new { $self->{'ti'} = $prjc->get_template_input(); $self->{'cslashes'} = $prjc->convert_slashes(); $self->{'addtemp'} = $prjc->get_addtemp(); - $self->{'crlf'} = undef; + $self->{'crlf'} = $prjc->crlf(); + $self->{'clen'} = length($self->{'crlf'}); $self->{'values'} = {}; $self->{'defaults'} = {}; $self->{'lines'} = []; @@ -496,7 +497,7 @@ sub handle_if { my($val) = shift; my($name) = 'endif'; - push(@{$self->{'lstack'}}, $self->line_number() . " $val"); + push(@{$self->{'lstack'}}, $self->get_line_number() . " $val"); if (!$self->{'if_skip'}) { my($true) = 1; push(@{$self->{'sstack'}}, $name); @@ -564,7 +565,7 @@ sub handle_foreach { my($status) = 1; my($errorString) = ''; - push(@{$self->{'lstack'}}, $self->line_number()); + push(@{$self->{'lstack'}}, $self->get_line_number()); if (!$self->{'if_skip'}) { my($vname) = undef; if ($val =~ /([^,]+),(.*)/) { @@ -726,33 +727,12 @@ sub handle_marker { sub split_name_value { my($self) = shift; my($line) = shift; - my($length) = length($line); my($name) = undef; my($val) = undef; - for(my $i = 0; $i < $length; ++$i) { - my($ch) = substr($line, $i, 1); - if (!defined $name && $ch eq '(') { - $name = substr($line, 0, $i); - $val = ''; - } - elsif (!defined $name && $ch eq '%') { - if (substr($line, $i + 1, 1) eq '>') { - $name = substr($line, 0, $i); - last; - } - } - elsif (defined $val && $ch ne ')') { - $val .= $ch; - } - elsif (defined $val && $ch eq ')') { - if (substr($line, $i + 1, 2) eq '%>') { - last; - } - else { - $val .= $ch; - } - } + if ($line =~ /([^%\(]+)(\(([^%]+)\))?%>/) { + $name = $1; + $val = $3; } return lc($name), $val; @@ -854,9 +834,6 @@ sub collect_data { my($self) = shift; my($prjc) = $self->{'prjc'}; - ## Save crlf so we don't have to keep going back to the prjc - $self->{'crlf'} = $prjc->crlf(); - ## Collect the components into {'values'} somehow foreach my $key (keys %{$prjc->{'valid_components'}}) { my(@list) = $prjc->get_component_list($key); @@ -907,8 +884,6 @@ sub parse_line { my($errorString) = ''; my($length) = length($line); my($name) = 0; - my($crlf) = $self->{'crlf'}; - my($clen) = length($crlf); my($startempty) = ($line eq '' ? 1 : 0); my($append_name) = 0; @@ -917,8 +892,8 @@ sub parse_line { ## not need to add a newline to the end. if ($self->{'foreach'}->{'processing'} == 0 && !$self->is_only_keyword($line)) { - $line .= $crlf; - $length += $clen; + $line .= $self->{'crlf'}; + $length += $self->{'clen'}; } if ($self->{'foreach'}->{'count'} < 0) { @@ -992,7 +967,7 @@ sub parse_line { ## If the line started out empty and we're not ## skipping from the start or the built up line is not empty if ($startempty || - ($self->{'built'} ne $crlf && $self->{'built'} ne '')) { + ($self->{'built'} ne $self->{'crlf'} && $self->{'built'} ne '')) { push(@{$self->{'lines'}}, $self->{'built'}); } } @@ -1018,7 +993,7 @@ sub parse_file { } if (!$status) { - my($linenumber) = $self->line_number(); + my($linenumber) = $self->get_line_number(); $errorString = "$input: line $linenumber:\n$errorString\n"; } diff --git a/modules/VC71WorkspaceCreator.pm b/modules/VC71WorkspaceCreator.pm index 8f9d4999..1362e756 100644 --- a/modules/VC71WorkspaceCreator.pm +++ b/modules/VC71WorkspaceCreator.pm @@ -26,9 +26,9 @@ use vars qw(@ISA); sub pre_workspace { my($self) = shift; my($fh) = shift; - my($crlf) = $self->crlf(); - print $fh "Microsoft Visual Studio Solution File, Format Version 8.00$crlf"; + print $fh "Microsoft Visual Studio Solution File, Format Version 8.00" . + $self->crlf(); } diff --git a/modules/VC7WorkspaceCreator.pm b/modules/VC7WorkspaceCreator.pm index a1161200..62d4e104 100644 --- a/modules/VC7WorkspaceCreator.pm +++ b/modules/VC7WorkspaceCreator.pm @@ -43,9 +43,9 @@ sub workspace_file_name { sub pre_workspace { my($self) = shift; my($fh) = shift; - my($crlf) = $self->crlf(); - print $fh "Microsoft Visual Studio Solution File, Format Version 7.00$crlf"; + print $fh "Microsoft Visual Studio Solution File, Format Version 7.00" . + $self->crlf(); } @@ -123,7 +123,7 @@ sub write_comps { ## I hate to add yet another loop through all the projects, but ## we must have some way to map plain project names to guids. my(%name_to_guid_map) = (); - foreach my $project(sort @list) { + foreach my $project(@list) { my($name, $deps, $guid) = @{$$pjs{$project}}; $name_to_guid_map{$name} = $guid; } diff --git a/modules/WorkspaceCreator.pm b/modules/WorkspaceCreator.pm index 35e62855..974943ba 100644 --- a/modules/WorkspaceCreator.pm +++ b/modules/WorkspaceCreator.pm @@ -906,13 +906,14 @@ sub add_implicit_project_dependencies { ## append the dependency and remove the file in question from the ## project so that the next time around the foreach, we don't find it ## as a dependent on the one that we just modified. - foreach my $key (sort keys %{$self->{'project_file_list'}}) { - foreach my $ikey (keys %{$self->{'project_file_list'}}) { + my(@pflkeys) = keys %{$self->{'project_file_list'}}; + foreach my $key (@pflkeys) { + foreach my $ikey (@pflkeys) { if ($key ne $ikey && - (!defined $bidir{$ikey} || - !$self->array_contains($bidir{$ikey}, [$key])) && ($self->{'project_file_list'}->{$key}->[1] eq - $self->{'project_file_list'}->{$ikey}->[1])) { + $self->{'project_file_list'}->{$ikey}->[1]) && + (!defined $bidir{$ikey} || + !$self->array_contains($bidir{$ikey}, [$key]))) { my(@over) = (); if ($self->array_contains( $self->{'project_file_list'}->{$key}->[2], @@ -1276,9 +1277,6 @@ sub get_modified_workspace_name { my($self) = shift; my($name) = shift; my($ext) = shift; - my($pwd) = $self->getcwd(); - my($type) = $self->{'wctype'}; - my($wsname) = $self->get_workspace_name(); ## If this is a per project workspace, then we should not ## modify the workspace name. It may overwrite another workspace @@ -1287,6 +1285,10 @@ sub get_modified_workspace_name { return "$name$ext"; } + my($pwd) = $self->getcwd(); + my($type) = $self->{'wctype'}; + my($wsname) = $self->get_workspace_name(); + if (!defined $previous_workspace_name{$type}->{$pwd}) { $previous_workspace_name{$type}->{$pwd} = $wsname; $self->{'current_workspace_name'} = undef; @@ -1318,10 +1320,9 @@ sub generate_recursive_input_list { sub verify_build_ordering { - my($self) = shift; - my($projects) = $self->get_projects(); + my($self) = shift; - foreach my $project (@$projects) { + foreach my $project (@{$self->{'projects'}}) { $self->get_validated_ordering($project, 1); } } @@ -1339,7 +1340,7 @@ sub get_validated_ordering { ($name, $deps) = @{$$pjs{$project}}; if (defined $deps && $deps ne '') { my($darr) = $self->create_array($deps); - my($projects) = $self->get_projects(); + my($projects) = $self->{'projects'}; foreach my $dep (@$darr) { my($found) = 0; ## Avoid circular dependencies |