diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2002-09-20 18:56:57 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2002-09-20 18:56:57 +0000 |
commit | 0b5f01af96a75cef8e9dff967442d5ac387386a5 (patch) | |
tree | 9def194801da6962bcc513378d87e72fb382f69a | |
parent | b45759a852fc4542f7e9071328ae897fa4e56784 (diff) | |
download | MPC-0b5f01af96a75cef8e9dff967442d5ac387386a5.tar.gz |
ChangeLogTag: Fri Sep 20 13:52:23 2002 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/Creator.pm | 45 | ||||
-rw-r--r-- | modules/NMakeProjectCreator.pm | 14 | ||||
-rw-r--r-- | modules/ProjectCreator.pm | 79 | ||||
-rw-r--r-- | modules/TemplateParser.pm | 67 | ||||
-rw-r--r-- | templates/em3.mpd | 4 | ||||
-rw-r--r-- | templates/em3vcp.mpd | 4 | ||||
-rw-r--r-- | templates/nmake.mpd | 4 | ||||
-rw-r--r-- | templates/vc6.mpd | 4 | ||||
-rw-r--r-- | templates/vc6dsp.mpd | 4 | ||||
-rw-r--r-- | templates/vc7.mpd | 6 |
10 files changed, 175 insertions, 56 deletions
diff --git a/modules/Creator.pm b/modules/Creator.pm index af4a5de7..0ed52268 100644 --- a/modules/Creator.pm +++ b/modules/Creator.pm @@ -120,6 +120,35 @@ sub generate { } +sub parse_assignment { + my($self) = shift; + my($line) = shift; + my($values) = shift; + my($status) = 1; + + if ($line =~ /^(\w+)\s*=\s*(.*)?/) { + my($name) = lc($1); + my($value) = $2; + push(@$values, "assignment", $name, $value); + } + elsif ($line =~ /^(\w+)\s*\+=\s*(.*)?/) { + my($name) = lc($1); + my($value) = $2; + push(@$values, "assign_add", $name, $value); + } + elsif ($line =~ /^(\w+)\s*\-=\s*(.*)?/) { + my($name) = lc($1); + my($value) = $2; + push(@$values, "assign_sub", $name, $value); + } + else { + $status = 0; + } + + return $status; +} + + sub parse_known { my($self) = shift; my($line) = shift; @@ -179,20 +208,8 @@ sub parse_known { $errorString = "ERROR: No $type was defined"; $status = 0; } - elsif ($line =~ /^(\w+)\s*=\s*(.*)?/) { - my($name) = lc($1); - my($value) = $2; - push(@values, "assignment", $name, $value); - } - elsif ($line =~ /^(\w+)\s*\+=\s*(.*)?/) { - my($name) = lc($1); - my($value) = $2; - push(@values, "assign_add", $name, $value); - } - elsif ($line =~ /^(\w+)\s*\-=\s*(.*)?/) { - my($name) = lc($1); - my($value) = $2; - push(@values, "assign_sub", $name, $value); + elsif ($self->parse_assignment($line, \@values)) { + ## If this returns true, then we've found an assignment } elsif ($line =~ /^(\w+)\s*(\([^\)]+\))?\s*{$/) { my($comp) = lc($1); diff --git a/modules/NMakeProjectCreator.pm b/modules/NMakeProjectCreator.pm index 724d0fec..131f435f 100644 --- a/modules/NMakeProjectCreator.pm +++ b/modules/NMakeProjectCreator.pm @@ -21,6 +21,12 @@ use vars qw(@ISA); # Subroutine Section # ************************************************************ +sub sort_files { + my($self) = shift; + return 0; +} + + sub translate_value { my($self) = shift; my($key) = shift; @@ -38,14 +44,6 @@ sub translate_value { } -sub file_sorter { - my($self) = shift; - my($left) = shift; - my($right) = shift; - return lc($left) cmp lc($right); -} - - sub crlf { my($self) = shift; return $self->windows_crlf(); diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index c05e82fe..943bfc36 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -101,6 +101,7 @@ sub new { $self->{'writing_type'} = 0; $self->{'want_dynamic_projects'} = $dynamic; $self->{'want_static_projects'} = $static; + $self->{'flag_overrides'} = {}; ## Valid component names within a project along with the valid file extensions my(%vc) = ('source_files' => [ "\\.cpp", "\\.cxx", "\\.cc", "\\.c", "\\.C", ], @@ -116,9 +117,14 @@ sub new { my(%ec) = ('source_files' => [ "_T\\.cpp", "_T\\.cxx", "_T\\.cc", "_T\\.C", ], ); - $self->{'valid_components'} = \%vc; - $self->{'exclude_components'} = \%ec; - $self->{'skeleton_endings'} = [ "C", "S" ]; + ## Match up assignments with the valid components + my(%ma) = ('source_files' => [ 'includes' ], + 'idl_files' => [ 'idlflags' ], + ); + $self->{'matching_assignments'} = \%ma; + $self->{'valid_components'} = \%vc; + $self->{'exclude_components'} = \%ec; + $self->{'skeleton_endings'} = [ "C", "S" ]; ## Allow subclasses to override the default extensions $self->set_component_extensions(); @@ -203,6 +209,7 @@ sub parse_line { } $self->{$typecheck} = 0; $self->{'idl_defaulted'} = 0; + $self->{'flag_overrides'} = {}; $self->{'source_defaulted'} = 0; } else { @@ -300,9 +307,7 @@ sub parse_line { my($vc) = $self->{'valid_components'}; if (defined $$vc{$comp}) { - if ($self->parse_components($ih, $comp, $name)) { - } - else { + if (!$self->parse_components($ih, $comp, $name)) { $errorString = "ERROR: Unable to process $comp"; $status = 0; } @@ -336,6 +341,7 @@ sub parse_components { my($comps) = {}; my($order) = 0; my($set) = 0; + my(%flags) = (); if (defined $self->{$tag}) { $names = $self->{$tag}; @@ -388,8 +394,38 @@ sub parse_components { } } elsif (defined $current) { - my($array) = $$comps{$current}; - push(@$array, $line); + my(@values) = (); + ## If this returns true, then we've found an assignment + if ($self->parse_assignment($line, \@values)) { + my($over) = {}; + if (defined $self->{'flag_overrides'}->{$tag}) { + $over = $self->{'flag_overrides'}->{$tag}; + } + else { + $self->{'flag_overrides'}->{$tag} = $over; + } + + if ($values[0] eq 'assignment') { + $self->process_assignment($values[1], + $values[2], \%flags); + } + elsif ($values[0] eq 'assign_add') { + $self->process_assignment_add($values[1], + $values[2], \%flags); + } + elsif ($values[0] eq 'assign_sub') { + $self->process_assignment_sub($values[1], + $values[2], \%flags); + } + } + else { + my($over) = $self->{'flag_overrides'}->{$tag}; + if (defined $over) { + $$over{$line} = \%flags; + } + my($array) = $$comps{$current}; + push(@$array, $line); + } } else { $status = 0; @@ -405,9 +441,15 @@ sub process_assignment { my($self) = shift; my($name) = shift; my($value) = shift; + my($assign) = shift; my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign'); - my($assign) = $self->{$tag}; + ## If no hash table was passed in + if (!defined $assign) { + $assign = $self->{$tag}; + } + + ## If we haven't yet defined the hash table in this project if (!defined $assign) { $assign = {}; $self->{$tag} = $assign; @@ -430,15 +472,16 @@ sub process_assignment_add { my($self) = shift; my($name) = shift; my($value) = shift; - my($nval) = $self->get_assignment($name); + my($assign) = shift; + my($nval) = $self->get_assignment($name, $assign); if (defined $nval) { $nval = "$value $nval"; } else { $nval = $value; } - $self->process_assignment($name, $nval); - $self->process_duplicate_modification($name); + $self->process_assignment($name, $nval, $assign); + $self->process_duplicate_modification($name, $assign); } @@ -446,7 +489,8 @@ sub process_assignment_sub { my($self) = shift; my($name) = shift; my($value) = shift; - my($nval) = $self->get_assignment($name); + my($assign) = shift; + my($nval) = $self->get_assignment($name, $assign); if (defined $nval) { my($parts) = $self->create_array($nval); @@ -456,8 +500,8 @@ sub process_assignment_sub { $nval .= "$part "; } } - $self->process_assignment($name, $nval); - $self->process_duplicate_modification($name); + $self->process_assignment($name, $nval, $assign); + $self->process_duplicate_modification($name, $assign); } } @@ -465,13 +509,14 @@ sub process_assignment_sub { sub process_duplicate_modification { my($self) = shift; my($name) = shift; + my($assign) = shift; ## If we are modifying the libs, libpaths or includes assignment with ## either addition or subtraction, we are going to ## perform a little fix on the value to avoid multiple ## libraries and to try to insure the correct linking order if ($name eq "libs" || $name eq "libpaths" || $name eq "includes") { - my($nval) = $self->get_assignment($name); + my($nval) = $self->get_assignment($name, $assign); if (defined $nval) { my($parts) = $self->create_array($nval); my(%seen) = (); @@ -482,7 +527,7 @@ sub process_duplicate_modification { $seen{$part} = 1; } } - $self->process_assignment($name, $value); + $self->process_assignment($name, $value, $assign); } } } diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index 81b10ec9..84474890 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -26,7 +26,7 @@ my(@keywords) = ('if', 'else', 'endif', 'noextension', 'dirname', 'basename', 'basenoextension', 'foreach', 'forfirst', 'fornotfirst', 'fornotlast', 'forlast', 'endfor', - 'comment' + 'comment', 'flag_overrides', ); # ************************************************************ @@ -472,6 +472,38 @@ sub handle_end { } +sub get_flag_overrides { + my($self) = shift; + my($name) = shift; + my($value) = undef; + my($file) = $self->get_value($name); + my($prjc) = $self->{'prjc'}; + my($fo) = $prjc->{'flag_overrides'}; + + foreach my $key (keys %$fo) { + if ($key =~ /^$name/) { + foreach my $of (keys %{$$fo{$key}}) { + if ($of eq $file) { + foreach my $ma (keys %{$prjc->{'matching_assignments'}}) { + if ($ma eq $key) { + foreach my $aname (@{$prjc->{'matching_assignments'}->{$ma}}) { + if (defined $$fo{$key}->{$of}->{$aname}) { + $value = $$fo{$key}->{$of}->{$aname}; + } + } + last; + } + } + last; + } + } + last; + } + } + return $value; +} + + sub handle_if { my($self) = shift; my($val) = shift; @@ -488,7 +520,15 @@ sub handle_if { $val =~ s/^\s+//; $true = 0; } - if (!defined $self->get_value($val)) { + + if ($val =~ /flag_overrides\(([^\)]+)\)/) { + $val = $self->get_flag_overrides($1); + } + else { + $val = $self->get_value($val) + } + + if (!defined $val) { $self->{'if_skip'} = $true; } else { @@ -599,6 +639,22 @@ sub handle_basenoextension { } +sub handle_flag_overrides { + my($self) = shift; + my($name) = shift; + my($file) = $self->get_value($name); + my($prjc) = $self->{'prjc'}; + my($fo) = $prjc->{'flag_overrides'}; + + if (!$self->{'if_skip'}) { + my($value) = $self->get_flag_overrides($name); + if (defined $value) { + $self->append_current($value); + } + } +} + + ## Given a line that starts with an identifier, we split ## then name from the possible value stored inside ()'s and ## we stop looking at the line when we find the %> ending @@ -646,7 +702,7 @@ sub process_name { if ($line eq "") { } - elsif ($line =~ /^(\w+)(\(([^\)]+|\".*\")\))?%>/) { + elsif ($line =~ /^(\w+)(\(([^\)]+|\".*\"|flag_overrides\([^\)]+\))\))?%>/) { my($name, $val) = $self->split_name_value($line); $length += length($name); @@ -674,6 +730,9 @@ sub process_name { elsif ($name eq 'comment') { ## Ignore the contents of the comment } + elsif ($name eq 'flag_overrides') { + $self->handle_flag_overrides($val); + } elsif ($name eq 'noextension') { $self->handle_noextension($val); } @@ -737,7 +796,7 @@ sub collect_data { $prjc->update_project_info($self, 1, ['depends']); ## VC7 Projects need to know the GUID. - ## We need to save this value in our know values + ## We need to save this value in our known values ## since each guid generated will be different. We need ## this to correspond to the same guid used in the workspace. my($guid) = $prjc->update_project_info($self, 1, ['guid']); diff --git a/templates/em3.mpd b/templates/em3.mpd index 3e498fb3..099540b8 100644 --- a/templates/em3.mpd +++ b/templates/em3.mpd @@ -193,7 +193,7 @@ InputDir=<%dirname(idl_file)%> <%if(dirname_found)%> BuildCmds= \ cd $(InputDir) \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%> + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%> "$(InputDir)\$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -214,7 +214,7 @@ BuildCmds= \ $(BuildCmds) <%else%> BuildCmds= \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> $(InputPath) + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> $(InputPath) "$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) diff --git a/templates/em3vcp.mpd b/templates/em3vcp.mpd index 3e498fb3..099540b8 100644 --- a/templates/em3vcp.mpd +++ b/templates/em3vcp.mpd @@ -193,7 +193,7 @@ InputDir=<%dirname(idl_file)%> <%if(dirname_found)%> BuildCmds= \ cd $(InputDir) \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%> + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%> "$(InputDir)\$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -214,7 +214,7 @@ BuildCmds= \ $(BuildCmds) <%else%> BuildCmds= \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> $(InputPath) + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> $(InputPath) "$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) diff --git a/templates/nmake.mpd b/templates/nmake.mpd index 8efce07c..6165a952 100644 --- a/templates/nmake.mpd +++ b/templates/nmake.mpd @@ -204,13 +204,13 @@ InputDir=<%dirname(idl_file)%> <<tempfile.bat @echo off cd $(InputDir) - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%> + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%> << <%else%> ".\$(InputName)C.h" ".\$(InputName)C.i" ".\$(InputName)C.cpp" ".\$(InputName)S.h" ".\$(InputName)S.i" ".\$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" <<tempfile.bat @echo off - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> $(InputPath) + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> $(InputPath) << <%endif%> diff --git a/templates/vc6.mpd b/templates/vc6.mpd index 77343f53..00bf5e52 100644 --- a/templates/vc6.mpd +++ b/templates/vc6.mpd @@ -186,7 +186,7 @@ InputDir=<%dirname(idl_file)%> <%if(dirname_found)%> BuildCmds= \ cd $(InputDir) \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%> + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%> "$(InputDir)\$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -207,7 +207,7 @@ BuildCmds= \ $(BuildCmds) <%else%> BuildCmds= \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> $(InputPath) + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> $(InputPath) "$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) diff --git a/templates/vc6dsp.mpd b/templates/vc6dsp.mpd index 77343f53..00bf5e52 100644 --- a/templates/vc6dsp.mpd +++ b/templates/vc6dsp.mpd @@ -186,7 +186,7 @@ InputDir=<%dirname(idl_file)%> <%if(dirname_found)%> BuildCmds= \ cd $(InputDir) \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%> + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%> "$(InputDir)\$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -207,7 +207,7 @@ BuildCmds= \ $(BuildCmds) <%else%> BuildCmds= \ - <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> $(InputPath) + <%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> $(InputPath) "$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) diff --git a/templates/vc7.mpd b/templates/vc7.mpd index 476b893d..f3371564 100644 --- a/templates/vc7.mpd +++ b/templates/vc7.mpd @@ -150,12 +150,12 @@ Name="<%configuration%>|<%platform%>"> <Tool Name="VCCustomBuildTool" - Description="Invoking TAO_IDL Compiler on <%dirname(idl_file)%>" + Description="Invoking TAO_IDL Compiler on <%idl_file%> in <%dirname(idl_file)%>" <%if(dirname_found)%> CommandLine="cd <%dirname(idl_file)%> -<%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%basename(idl_file)%>" +<%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%basename(idl_file)%>" <%else%> - CommandLine="<%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%idlflags("-Sc")%> <%idl_file%>" + CommandLine="<%tao_idl_exe("$(ACE_ROOT)\\bin\\tao_idl")%> <%if(flag_overrides(idl_file))%><%flag_overrides(idl_file)%><%else%><%idlflags("-Sc")%><%endif%> <%idl_file%>" <%endif%> Outputs="<%noextension(idl_file)%>C.h;<%noextension(idl_file)%>C.i;<%noextension(idl_file)%>C.cpp;<%noextension(idl_file)%>S.h;<%noextension(idl_file)%>S.i;<%noextension(idl_file)%>S.cpp"/> </FileConfiguration> |