ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildSystem/BuildFile.pm (file contents):
Revision 1.4 by williamc, Tue Sep 12 13:01:39 2000 UTC vs.
Revision 1.30 by sashby, Tue Feb 27 11:59:44 2007 UTC

# Line 1 | Line 1
1 < # BuildFile
1 > #____________________________________________________________________
2 > # File: BuildFile.pm
3 > #____________________________________________________________________
4 > #  
5 > # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 > # Update: 2003-12-03 19:03:15+0100
7 > # Revision: $Id$
8   #
9 < # Interface
10 < # ---------
11 < # new(ConfigArea)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockClassPath() : Return the class path
9 < # ignore()      : return 1 if directory should be ignored 0 otherwise
10 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
12 use ActiveDoc::SimpleDoc;
13 use BuildSystem::ToolBox;
13   require 5.004;
14 + use Exporter;
15 + use ActiveDoc::SimpleDoc;
16  
17 < BEGIN {
18 < $buildfile="BuildFile";
19 < }
20 <
21 < sub new {
22 <        my $class=shift;
23 <        my $self={};
24 <        bless $self, $class;
25 <        $self->{area}=shift;
26 <        $self->{toolbox}=$self->{area}->toolbox();
27 <        $self->{Arch}=1;
28 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
29 <        return $self;
30 < }
31 <
32 < sub ignore {
33 <        my $self=shift;
34 <        return (defined $self->{ignore})?$self->{ignore}:0;
35 < }
36 <
37 < sub _initswitcher {
38 <        my $self=shift;
39 <        my $switch=ActiveDoc::SimpleDoc->new();
40 <        my $parse="makebuild";
41 <        $switch->newparse($parse);
42 <        $switch->addignoretags($parse);
43 <        $self->_commontags($switch,$parse);
44 <        $switch->addtag($parse,"Build", \&Build_start, $self);
45 <        $switch->addtag($parse,"none",
46 <                                        \&OutToMakefile,$self,
47 <                                        \&OutToMakefile, $self,
48 <                                        "", $self);
49 <        $switch->addtag($parse,"Bin",
50 <                                        \&Bin_start,$self,
51 <                                        \&OutToScreen, $self,
52 <                                        "", $self);
53 <        $switch->addtag($parse,"LibType",
54 <                                        \&LibType_Start,$self,
55 <                                        \&LibType_text, $self,
56 <                                        \&LibType_end,$self);
57 <        $switch->addtag($parse,"ConfigurationClass",
58 <                                        \&Class_StartTag,$self,
59 <                                        \&OutToMakefile, $self,
60 <                                        "", $self);
61 <        $switch->addtag($parse,"ClassPath",
62 <                                        \&setBlockClassPath,$self,
63 <                                        \&OutToMakefile, $self,
64 <                                        "", $self);
65 <        $switch->addtag($parse,"AssociateGroup",
66 <                                        "",$self,
67 <                                        \&AssociateGroup,$self,
68 <                                        "", $self);
69 <        $switch->addtag($parse,"Environment",
70 <                                        \&Environment_start,$self,
71 <                                        \&OutToMakefile, $self,
72 <                                        \&Environment_end,$self);
73 <        $switch->addtag($parse,"Export",
74 <                                        \&export_start,$self,
75 <                                        \&OutToMakefile, $self,
76 <                                        \&export_end,$self);
77 <        return $switch;
78 < }
79 <
80 < sub _commontags {
81 <        my $self=shift;
82 <        my $switch=shift;
83 <        my $parse=shift;
84 <
85 <        $switch->grouptag("Export",$parse);
86 <        $switch->addtag($parse,"Use",\&Use_start,$self,
87 <                                               \&OutToMakefile, $self,
88 <                                                "", $self);
89 <        $switch->addtag($parse,"Group",\&Group_start,$self,
90 <                                               \&OutToMakefile, $self,
91 <                                                "", $self);
92 <        $switch->grouptag("Group",$parse);
93 <        $switch->addtag($parse,"External",
94 <                                        \&External_StartTag,$self,
95 <                                        \&OutToMakefile, $self,
96 <                                        "", $self);
97 <        $switch->addtag($parse,"lib",
98 <                                        \&lib_start,$self,
99 <                                        \&OutToMakefile, $self,
100 <                                        "", $self);
101 <        $switch->addtag($parse,"Architecture",
102 <                                        \&Arch_Start,$self,
103 <                                        \&OutToMakefile, $self,
104 <                                        \&Arch_End,$self);
105 <        $switch->addtag($parse,"INCLUDE_PATH",
106 <                                        \&IncludePath_Start,$self,
107 <                                        \&OutToMakefile, $self,
108 <                                        "",$self);
109 <        return $switch;
110 < }
111 <
112 < sub GenerateMakefile {
113 <        my $self=shift;
114 <        my $infile=shift;
115 <        my $outfile=shift;
116 <
117 <        $self->{switch}=$self->_initswitcher();
118 <        $self->{switch}->filetoparse($infile);
119 <
120 <        # open a temporary gnumakefile to store output.
121 <        my $fh=FileHandle->new();
122 <        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
123 <                                                                "$!\n";
124 <        @{$self->{filehandlestack}}=($fh);
125 <
126 <        #  -- make an alias
127 <        *GNUmakefile=$fh;
128 <        if ( -e $ENV{LatestBuildFile} ) {
129 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
130 <        }
131 <        $ENV{LatestBuildFile}=$outfile;
132 <        $self->{switch}->parse("makebuild"); # sort out supported tags
133 <        close GNUmakefile;
134 < }
135 <
136 < sub ParseBuildFile {
137 <        my $self=shift;
138 <        my $base=shift;
139 <        my $path=shift;
140 <        my $filename=shift @_;
141 <        my $fullfilename;
142 <        if ( $filename!~/^\// ) {
143 <         $fullfilename="$base/$path/$filename";
144 <        }
145 <        else {
146 <         $fullfilename=$filename;
147 <        }
148 <        $self->{path}=$path;
149 <        #print "Processing $fullfilename\n";
150 <        $numbins=0;
151 <        $self->{envnum}=0;
152 <        $self->{envlevel}=0;
153 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
154 <                                                                "BuildFile.mk";
155 <        $self->{switch}=$self->_initswitcher();
156 <        $self->{switch}->filetoparse($fullfilename);
157 <
158 < #       $self->{switch}->{Strict_no_cr}='no';
159 <        #open a temporary gnumakefile to store output.
160 <        use Utilities::AddDir;
161 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
162 <        my $fh=FileHandle->new();
163 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
164 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
165 <        @{$self->{filehandlestack}}=($fh);
166 <        # make an alias
167 <        *GNUmakefile=$fh;
168 <        if ( -e $ENV{LatestBuildFile} ) {
169 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
170 <        }
171 < #       print "writing to :\n".
172 < #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
173 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
174 <        $self->{switch}->parse("makebuild"); # sort out supported tags
175 <        if ( $numbins > 0 ) {
176 <         print GNUmakefile <<ENDTEXT;
177 < ifndef BINMODE
178 < help::
179 < \t\@echo Generic Binary targets
180 < \t\@echo ----------------------
181 < endif
182 < ENDTEXT
183 <         foreach $target ( keys %$targettypes ) {
184 <         print GNUmakefile <<ENDTEXT;
185 < ifndef BINMODE
186 < help::
187 < \t\@echo $target
188 < endif
189 < ENDTEXT
17 > @ISA=qw(Exporter);
18 > @EXPORT_OK=qw( );
19 > #
20 > sub new()
21 >   ###############################################################
22 >   # new                                                         #
23 >   ###############################################################
24 >   # modified : Wed Dec  3 19:03:22 2003 / SFA                   #
25 >   # params   :                                                  #
26 >   #          :                                                  #
27 >   # function :                                                  #
28 >   #          :                                                  #
29 >   ###############################################################
30 >   {
31 >   my $proto=shift;
32 >   my $class=ref($proto) || $proto;
33 >   $self={};
34 >   bless $self,$class;
35 >   $self->{DEPENDENCIES} = {};
36 >   $self->{content} = {};
37 >   $self->{scramdoc}=ActiveDoc::SimpleDoc->new();
38 >   $self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs');
39 >   return $self;
40 >   }
41 >
42 > sub parse()
43 >   {
44 >   my $self=shift;
45 >   my ($filename)=@_;
46 >   $self->{scramdoc}->filetoparse($filename);
47 >   $self->{scramdoc}->parse("builder");
48 >   # We're done with the SimpleDoc object so delete it:
49 >   delete $self->{scramdoc};
50 >   }
51 >
52 > sub classpath()
53 >   {
54 >   my ($object,$name,%attributes)=@_;
55 >   # The getter part:
56 >   if (ref($object) eq __PACKAGE__)
57 >      {
58 >      return $self->{content}->{CLASSPATH};
59 >      }
60 >  
61 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'})
62 >      : push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'});
63 >   }
64 >
65 > sub productstore()
66 >   {
67 >   my ($object,$name,%attributes)=@_;
68 >   # The getter part:
69 >   if (ref($object) eq __PACKAGE__)
70 >      {
71 >      # Return an array of ProductStore hashes:
72 >      return $self->{content}->{PRODUCTSTORE};
73 >      }
74 >  
75 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes)
76 >      : push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ;
77 >   }
78 >
79 > sub include()
80 >   {
81 >   my $self=shift;
82 >   # Return an array of required includes:
83 >   return $self->{content}->{INCLUDE};
84 >   }
85 >
86 > sub include_path()
87 >   {
88 >   my ($object,$name,%attributes)=@_;
89 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'})
90 >      : push(@{$self->{content}->{INCLUDE}}, $attributes{'path'});
91 >   }
92 >
93 > sub use()
94 >   {
95 >   my $object=shift;
96 >   # The getter part:
97 >   if (ref($object) eq __PACKAGE__)
98 >      {
99 >      # Add or return uses (package deps):
100 >      @_ ? push(@{$self->{content}->{USE}},@_)
101 >         : @{$self->{content}->{USE}};
102 >      }
103 >   else
104 >      {
105 >      my ($name,%attributes)=@_;
106 >      $self->{DEPENDENCIES}->{$attributes{'name'}} = 1;
107 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'})
108 >         : push(@{$self->{content}->{USE}}, $attributes{'name'});
109 >      }
110 >   }
111 >
112 > sub architecture()
113 >   {
114 >   my ($object,$name,%attributes)=@_;
115 >   $self->pushlevel(\%attributes); # Set nested to 1;
116 >   }
117 >
118 > sub architecture_()
119 >   {
120 >   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
121 >   $self->poplevel();
122 >   }
123 >
124 > sub export()
125 >   {
126 >   $self->pushlevel(); # Set nested to 1;
127 >   }
128 >
129 > sub export_()
130 >   {
131 >   $self->{content}->{EXPORT} = $self->{tagcontent};
132 >   $self->poplevel();
133 >   }
134 >
135 > sub lib()
136 >   {
137 >   my ($object,$name,%attributes)=@_;
138 >   # The getter part:
139 >   if (ref($object) eq __PACKAGE__)
140 >      {
141 >      # Return an array of required libs:
142 >      return $self->{content}->{LIB};      
143 >      }
144 >  
145 >   my $libname;
146 >  
147 >   if (exists($attributes{'position'}))
148 >      {
149 >      if ($attributes{'position'} eq 'first')
150 >         {
151 >         $libname = "F:".$attributes{'name'};
152 >         }
153 >      else
154 >         {
155 >         # There was a position entry but it didn't make sense:
156 >         $libname = $attributes{'name'};
157 >         }
158 >      }
159 >   else
160 >      {
161 >      $libname = $attributes{'name'};
162 >      }
163 >   # We have a libname, add it to the list:
164 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname)
165 >      : push(@{$self->{content}->{LIB}}, $libname);
166 >   }
167 >
168 > sub libtype()
169 >   {
170 >   my ($object,$name,%attributes)=@_;
171 >   # The getter part:
172 >   if (ref($object) eq __PACKAGE__)
173 >      {
174 >      # Return an array of required libs:
175 >      return $self->{content}->{LIBTYPE};      
176 >      }
177 >
178 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'})
179 >      : push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'});
180 >   }
181 >
182 > sub skip()
183 >   {
184 >   my ($object,$name,%attributes)=@_;
185 >   $self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ]
186 >      : $self->{content}->{SKIPPEDDIRS} = [ 1 ];
187 >   }
188 >
189 > sub skip_message()
190 >   {
191 >   my ($object,$name,@message) = @_;
192 >   # Save any message text between <skip> tags:
193 >   if ($#message > -1)
194 >      {
195 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ])
196 >         : push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]);
197 >      }
198 >   }
199 >
200 > sub skip_()
201 >   {
202 >   my ($object,$name)=@_;
203 >   }
204 >
205 > sub makefile()
206 >   {
207 >   my ($object,$name,%attributes)=@_;
208 >   # The getter part:
209 >   if (ref($object) eq __PACKAGE__)
210 >      {
211 >      # Return Makefile content:
212 >      return $self->{content}->{MAKEFILE};
213 >      }
214 >  
215 >   # Set our own Char handler so we can collect the content
216 >   # of the Makefile tag:
217 >   $object->setHandlers(Char => \&makefile_content);
218 >   $self->{makefilecontent} = [];
219 >   }
220 >
221 > sub makefile_content()
222 >   {
223 >   my ($object, @strings) = @_;
224 >   push(@{$self->{makefilecontent}},@strings);
225 >   }
226 >
227 > sub makefile_()
228 >   {
229 >   my ($object,$name)=@_;
230 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join('',@{$self->{makefilecontent}}))
231 >      : push(@{$self->{content}->{MAKEFILE}}, join('',@{$self->{makefilecontent}}));
232 >   delete $self->{makefilecontent};
233 >   # Unset the Char handler to revert to the default behaviour:
234 >   $object->setHandlers(Char => 0);
235 >   }
236 >
237 > sub define_group()
238 >   {
239 >   my ($object,$name,%attributes)=@_;
240 >   $self->pushlevel(\%attributes); # Set nested to 1;
241 >   }
242 >
243 > sub define_group_()
244 >   {
245 >   $self->{content}->{DEFINED_GROUP}->{$self->{id}->{'name'}}=$self->{tagcontent};
246 >   $self->poplevel();
247 >   }
248 >
249 > sub group()
250 >   {
251 >   my $object=shift;
252 >   # The getter part:
253 >   if (ref($object) eq __PACKAGE__)
254 >      {
255 >      # Add or return groups:
256 >      @_ ? push(@{$self->{content}->{GROUP}},@_)
257 >         : @{$self->{content}->{GROUP}};
258 >      }
259 >   else
260 >      {
261 >      my ($name,%attributes)=@_;
262 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{GROUP}}, $attributes{'name'})
263 >         : push(@{$self->{content}->{GROUP}}, $attributes{'name'});
264 >      }
265 >   }
266 >
267 > sub flags()
268 >   {
269 >   my ($object,$name,%attributes)=@_;
270 >   # The getter part:
271 >   if (ref($object) eq __PACKAGE__)
272 >      {
273 >      # Return an array of ProductStore hashes:
274 >      return $self->{content}->{FLAGS};
275 >      }
276 >  
277 >   # Extract the flag name and its value:
278 >   my ($flagname,$flagvaluestring) = each %attributes;
279 >   $flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase
280 >   chomp($flagvaluestring);
281 >   # Split the value on whitespace so we can push all
282 >   # individual flags into an array:
283 >   my @flagvalues = split(' ',$flagvaluestring);
284 >   # Is current tag within another tag block?
285 >   if ($self->{nested} == 1)
286 >      {
287 >      # Check to see if the current flag name is already stored in the hash. If so,
288 >      # just add the new values to the array of flag values:
289 >      if (exists ($self->{tagcontent}->{FLAGS}->{$flagname}))
290 >         {
291 >         push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues);
292 >         }
293 >      else
294 >         {
295 >         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
296 >         }
297 >      }
298 >   else
299 >      {
300 >      if (exists ($self->{content}->{FLAGS}->{$flagname}))
301 >         {
302 >         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
303           }
304 <        }
305 <        close GNUmakefile;
306 < }
193 <
194 < sub ParseBuildFile_Export {
195 <        my $self=shift;
196 <        my $filename=shift;
197 <        my $bf=BuildSystem::BuildFile->new($self->{area});
198 <        if ( defined $self->{remoteproject} ) {
199 <           $bf->{remoteproject}=$self->{remoteproject};
200 <        }
201 <        $bf->_parseexport($filename);
202 <        undef $bf;
203 < }
204 <
205 < sub _location {
206 <        my $self=shift;
207 <        use File::Basename;
208 <
209 <        return dirname($self->{switch}->filetoparse());
210 < }
211 <
212 < sub _parseexport {
213 <        my $self=shift;
214 <        my $filename=shift;
215 <
216 <        my $switchex=ActiveDoc::SimpleDoc->new();
217 <        $switchex->filetoparse($filename);
218 <        $switchex->newparse("export");
219 <        $switchex->addignoretags("export");
220 <        $switchex->addtag("export","Export",
221 <                                        \&export_start_export,$self,
222 <                                        \&OutToMakefile, $self,
223 <                                        \&export_end_export,$self);
224 <        $self->_commontags($switchex,"export");
225 <        $switchex->allowgroup("__export","export");
226 < #       $switchex->{Strict_no_cr}='no';
227 <        $self->{switch}=$switchex;
228 <        $switchex->parse("export"); # sort out supported tags
229 < }
230 <
231 < sub _pushremoteproject {
232 <        my $self=shift;
233 <        my $path=shift;
234 <        
235 <        if ( defined $self->{remoteproject} ) {
236 <          push @{$self->{rpstack}}, $self->{remoteproject};
237 <        }
238 <        $self->{remoteproject}=$path;
239 < }
240 <
241 < sub _popremoteproject {
242 <        my $self=shift;
243 <        if ( $#{$self->{rpstack}} >=0 ) {
244 <          $self->{remoteproject}=pop @{$self->{rpstack}};
245 <        }
246 <        else {
247 <          undef $self->{remoteproject};
248 <        }
249 < }
250 <
251 < sub _toolmapper {
252 <        my $self=shift;
253 <        if ( ! defined $self->{mapper} ) {
254 <           require BuildSystem::ToolMapper;
255 <           $self->{mapper}=BuildSystem::ToolMapper->new();
256 <        }
257 <        return $self->{mapper};
258 < }
259 <
260 <
261 < # ---- Tag routines
262 <
263 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
264 < #   the type tag will pick up a pre-defined class type from project space.
265 <
266 < sub Class_StartTag {
267 <        my $self=shift;
268 <        my $name=shift;
269 <        my $hashref=shift;
270 <        
271 <        if ( $self->{Arch} ) {
272 <         if ( defined $$hashref{'type'} ) {
273 <                $ClassName=$$hashref{'type'};
304 >      else
305 >         {
306 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
307           }
308 <        }
309 < }
277 <
278 < sub IncludePath_Start {
279 <        my $self=shift;
280 <        my $name=shift;
281 <        my $hashref=shift;
282 <
283 <        $self->{switch}->checktag( $name, $hashref, 'path');
284 <        if ( $self->{Arch} ) {
285 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
286 <                                                $$hashref{'path'}."\n";
287 <        }
288 < }
308 >      }
309 >   }
310  
311 < #
312 < # generic build tag
313 < #
314 < sub Build_start {
315 <        my $self=shift;
316 <        my $name=shift;
317 <        my $hashref=shift;
318 <
319 <        $self->{switch}->checktag($name,$hashref,'class');
320 <        if ( $self->{Arch} ) {
321 <
322 <          # -- determine the build products name
323 <          my $name;
324 <          if ( exists $$hashref{'name'} ) {
325 <            $name=$$hashref{'name'};
326 <          }
327 <          else {
328 <            $self->{switch}->parseerror("No name specified for build product");
329 <            #$name="\$(buildname)";
309 <          }
310 <
311 <          # -- check we have a lookup for the class type
312 <          my $mapper=$self->_toolmapper();
313 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
314 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
315 <          }
316 <          else {
317 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
318 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
319 <
320 <           my $fh=$self->{filehandlestack}[0];
321 <           my @targets=();
322 <
323 <           # -- generate generic targets
324 <           print $fh "ifndef _BuildLink_\n";
325 <           print $fh "# -- Generic targets\n";
326 <           push @targets, $$hashref{'class'};
327 <           foreach $dtype ( @deftypes ) {
328 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
329 <                                                                $dtype."\n";
330 <           }
331 <           print $fh "\n";
332 <
333 <           # -- generate targets for each type
334 <           foreach $type ( @types ) {
335 <
336 <            # -- generic name for each type
337 <            my $pattern=$$hashref{'class'}."_".$type;
338 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
339 <            print $fh "# ------ $pattern rules ---------------\n";
340 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
341 <                                                        "_".$type."_$name\n\n";
342 <
343 <            # -- create a new directory for each type
344 <            push @targets, $pattern;
345 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
346 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
347 <            my $makefile=$here."/BuildFile.mk";
348 < #           AddDir::adddir($here);
349 <
350 <            # -- create link targets to the directory
351 <            push @targets, $dirname;
352 <            print $fh "# -- Link Targets to $type directories\n";
353 <            print $fh "$dirname: make_$dirname\n";
354 <            print $fh "\t\@cd $here; \\\n";
355 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
356 <                        " workdir=$here ".
357 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
358 <
359 <            # -- write target to make makefile for each directory
360 <            print $fh "# -- Build target directories\n";
361 <            print $fh "make_$dirname:\n";
362 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
363 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
364 <            print $fh "\t  mkdir $here; \\\n";
365 <            print $fh "\t fi;\\\n";
366 <            print $fh "\t cd $dirname; \\\n";
367 <            print $fh "\t echo include ".$self->{currentenv}." > ".
368 <                                                        "$makefile; \\\n";
369 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
370 <                                        " >> $makefile; \\\n";
371 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
372 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
373 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
374 <             foreach $f ( @file ) {
375 <              print $fh "\t echo -include $f >> $makefile; \\\n";
376 <             }
311 > sub allflags()
312 >   {
313 >   my $self=shift;
314 >   # Return hash data for flags:
315 >   return $self->{content}->{FLAGS};
316 >   }
317 >
318 > sub archspecific()
319 >   {
320 >   my $self=shift;
321 >  
322 >   # Check to see if there is arch-dependent data. If so, return it:
323 >   if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
324 >      {
325 >      while (my ($k,$v) = each %{$self->{content}->{ARCH}})
326 >         {
327 >         if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
328 >            {
329 >            return $self->{content}->{ARCH}->{$k};
330              }
378            print $fh "\tfi\n";
379            print $fh "\n";
380 #           print $typefile "$name :\n";
381 #           print $typefile "\t\$(_quietbuild_)";
382 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
383 #           print $typefile "\t\$(_quietstamp_)";
384 #           print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
385
386            # -- cleaning targets
387            push @targets, "clean_$dirname";
388            print $fh "# -- cleaning targets\n";
389            print $fh "clean::clean_$dirname\n";
390            print $fh "clean_".$dirname."::\n";
391            print $fh "\t\@echo cleaning $dirname\n";
392            print $fh "\t\@if [ -d $here ]; then \\\n";
393            print $fh "\tcd $here; \\\n";
394            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
395                        $here." _BuildLink_=1 -f ".
396                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
397            print $fh "\tfi\n\n";
398
399
400          }
401          # -- help targets
402          print $fh "helpheader::\n";
403          print $fh "\t\@echo Targets available:\n";
404          print $fh "\t\@echo ------------------\n\n";
405          print $fh "help::helpheader\n";
406          foreach $target ( @targets ) {
407            print $fh "help::\n";
408            print $fh "\t\@echo $target\n"
409          }
410          print $fh "endif\n";
411         } # end else
412        }
413 }
414
415 sub Bin_start {
416        my $self=shift;
417        my $name=shift;
418        my $hashref=shift;
419
420        my $fileclass;
421        my @tools;
422        my $tool;
423        my $filename;
424        my $objectname;
425        
426        $self->{switch}->checktag($name,$hashref,'file');
427        if ( $self->{Arch} ) {
428        if ( ! defined $$hashref{name} ) {
429                ($$hashref{name}=$$hashref{file})=~s/\..*//;
430        }
431        ($filename=$$hashref{file})=~s/\..*//;
432
433        # Create a new directory for each binary target
434        my $dirname="bin_".$$hashref{name};
435        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
436        open (binGNUmakefile,
437           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
438           "BuildFile.mk $!\n";
439
440        # Create the link targets
441        $numbins++;
442        my $fh=$self->{filehandlestack}[0];
443        print $fh <<ENDTEXT;
444
445 # Link Targets to binary directories
446 ifdef BINMODE
447 # We dont want to build a library here
448 override files:=
449 endif
450 ifndef BINMODE
451
452 define stepdown_$$hashref{'name'}
453 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
454 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
455 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
456 fi
457 endef
458
459 define stepdown2_$$hashref{'name'}
460 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
461 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
462 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
463 fi
464
465 endef
466
467 bin_$$hashref{'name'}_%:: dummy
468        \@\$(stepdown2_$$hashref{'name'})
469
470 $$hashref{'name'}_%:: dummy
471        \@\$(stepdown_$$hashref{'name'})
472
473 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
474        \@\$(stepdown_$$hashref{'name'})
475
476 binfiles+=$$hashref{'file'}
477 locbinfiles+=$dirname/$$hashref{'file'}
478 endif
479
480
481 ENDTEXT
482
483
484 # the binary specifics makefile
485        print binGNUmakefile "include ".$self->{currentenv}."\n";
486        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
487
488 # alias for bin_Insure
489        print binGNUmakefile <<ENDTEXT;
490
491 bin_insure:bin_Insure
492 ifdef MAKETARGET_bin_insure
493 MAKETARGET_$$hashref{name}_Insure=1
494 endif
495
496 # debuggging target
497 $$hashref{'name'}_echo_% :: echo_%
498
499 # help targets
500 help::
501 \t\@echo Targets For $$hashref{'name'}
502 \t\@echo -------------------------------------
503 \t\@echo $$hashref{'name'}  - default build
504 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
505 ENDTEXT
506
507 # Make generic rules for each type
508        $targettypes={
509                "bin" => 'o',
510                "bin_debug" => 'd',
511                "bin_debug_local" => 'l_d',
512                "bin_Insure" => 'Insure'
513        };
514        #
515        foreach $target ( keys %$targettypes ) {
516          print binGNUmakefile <<ENDTEXT;
517
518 # Type $target specifics
519 ifdef MAKETARGET_$target
520 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
521 endif
522 $target ::$$hashref{name}_$$targettypes{$target}
523
524 bintargets+=$$hashref{name}_$$targettypes{$target}
525 help::
526 \t\@echo $$hashref{name}_$$targettypes{$target}
527 clean::
528 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
529 \techo Removing \$(binarystore)/$$hashref{name}; \\
530 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
531 \tfi
532
533 ENDTEXT
534          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
535          ${"objectname_$$targettypes{$target}"}=$objectname;
536          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
537        } # end loop
538
539        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
540        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
541        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
542        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
543        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
544        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
545        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
546        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
547        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
548        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
549        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
550        print binGNUmakefile "\t\$(CClinkCmd)\n";
551        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
552        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
553        print binGNUmakefile "-include $$hashref{name}.dep\n";
554 print binGNUmakefile <<ENDTEXT;
555 clean::
556 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
557 \techo Removing \$(binarystore)/$$hashref{name}; \\
558 \trm \$(binarystore)/$$hashref{name}; \\
559 \tfi
560
561 $$hashref{name}_d.exe:\$(libslocal_d)
562 $$hashref{name}_o.exe:\$(libslocal)
563 ifdef MCCABE_DATA_DIR
564 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
565 endif
566 $$hashref{name}_Insure.exe:\$(libslocal_I)
567 $$hashref{name}_d:$$hashref{name}_d.exe
568        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
569 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
570        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
571 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
572        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
573 $$hashref{name}:$$hashref{name}_d.exe
574        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
575 $$hashref{name}_o:$$hashref{name}_o.exe
576        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
577 binfiles+=$$hashref{file}
578 ENDTEXT
579        }
580        close binGNUmakefile;
581 }
582
583 sub External_StartTag {
584        my $self=shift;
585        my $name=shift;
586        my $hashref=shift;
587        
588        my $tool;
589        if ( $self->{Arch} ) {
590        $self->{switch}->checktag($name,$hashref,'ref');
591
592        # -- oo toolbox stuff
593        # - get the appropriate tool object
594        $$hashref{'ref'}=~tr[A-Z][a-z];
595        if ( ! exists $$hashref{'version'} ) {
596         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
597        }
598        else {
599         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
600        }
601        if ( ! defined $tool ) {
602          $self->{switch}->parseerror("Unknown Tool Specified ("
603                                                        .$$hashref{'ref'}.")");
604        }
605
606        # -- old fashioned GNUmakefile stuff
607        print GNUmakefile $$hashref{'ref'};
608        if ( defined $$hashref{'version'} ) {
609                print GNUmakefile "_V_".$$hashref{'version'};
610        }
611        print GNUmakefile "=true\n";
612        
613        # -- Sub system also specified?
614        if ( exists $$hashref{'use'} ) {
615           # -- look for a buildfile
616           my @paths=$tool->getfeature("INCLUDE");
617           my $file="";
618           my ($path,$testfile);
619           foreach $path ( @paths ) {
620             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
621             if ( -f $testfile ) {
622                $file=$testfile;
623                $self->_pushremoteproject($path);
624             }
625           }
626           if ( $file eq "" ) {
627             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
628           }
629           $self->ParseBuildFile_Export($file);
630           $self->_popremoteproject();
331           }
332 <        }
333 < }      
334 <
335 < sub Group_start {
336 <        my $self=shift;
337 <        my $name=shift;
338 <        my $hashref=shift;
339 <        
340 <        $self->{switch}->checktag($name, $hashref, 'name');
341 <        if ( $self->{Arch} ) {
342 <        print GNUmakefile "GROUP_".$$hashref{'name'};
343 <        if ( defined $$hashref{'version'} ) {
344 <                print GNUmakefile "_V_".$$hashref{'version'};
345 <        }
346 <        print GNUmakefile "=true\n";
347 <        }
348 < }      
349 <
350 < sub Use_start {
351 <        my $self=shift;
352 <        my $name=shift;
353 <        my $hashref=shift;
354 <        my $filename;
355 <        use Utilities::SCRAMUtils;
356 <        
357 <        $self->{switch}->checktag($name, $hashref, "name");
358 <        if ( $self->{Arch} ) {
359 <        if ( exists $$hashref{'group'} ) {
360 <          print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
361 <        }
362 <        if ( ! defined $self->{remoteproject} ) {
363 <          $filename=SCRAMUtils::checkfile(
364 <                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
365 <        }
366 <        else {
367 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
368 <        print "trying $filename\n";
369 <          if ( ! -f $filename ) { $filename=""; };
370 <        }
371 <        if ( $filename ne "" ) {
372 <          $self->ParseBuildFile_Export( $filename );
373 <        }
374 <        else {
375 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
376 <                "decription file for <$name name=".$$hashref{name}.">");
377 <        }
378 <        }
379 < }
380 <
381 < sub CheckBuildFile {
382 <         my $self=shift;
383 <         my $classdir=shift;
384 <         my $ClassName="";
385 <         my $thisfile="$classdir/$buildfile";
386 <
387 <         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
388 <            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
389 <            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
390 <         }
391 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
392 <            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
393 <            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
394 <         }
395 <         return $ClassName;
396 < }
397 <
398 < # List association groups between <AssociateGroup> tags
399 < # seperated by newlines or spaces
400 < sub AssociateGroup {
401 <        my $self=shift;
402 <        my $name=shift;
403 <        my $string=shift;
404 <        my $word;
405 <
406 <        if ( $self->{Arch} ) {
407 <        foreach $word ( (split /\s/, $string) ){
408 <                chomp $word;
409 <                next if /^#/;
410 <                if ( $word=~/none/ ) {
411 <                        $self->{ignore}=1;
412 <                }
413 <        }
414 <        }
415 < }
416 <
417 < sub Arch_Start {
418 <        my $self=shift;
419 <        my $name=shift;
420 <        my $hashref=shift;
421 <
422 <        $self->{switch}->checktag($name, $hashref,'name');
423 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
424 <                                                : ($self->{Arch}=0);
425 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
426 < }
427 <
428 < sub Arch_End {
429 <        my $self=shift;
430 <        my $name=shift;
431 <
432 <        pop @{$self->{ARCHBLOCK}};
433 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
434 < }
435 <
436 < # Split up the Class Block String into a useable array
437 < sub _CutBlock {
438 <    my $self=shift;
439 <    my $string= shift @_;
440 <    @BlockClassA = split /\//, $string;
441 < }
442 <
443 < sub OutToMakefile {
444 <        my $self=shift;
445 <        my $name=shift;
446 <        my @vars=@_;
447 <
448 <        if ( $self->{Arch} ) {
449 <          print GNUmakefile @vars;
450 <        }
451 < }
452 <
453 < sub OutToScreen {
454 <        my $name=shift;
455 <        my @vars=@_;
456 <
457 <        if ( $self->{Arch} ) {
458 <          print @vars;
459 <        }
460 < }
461 < sub setBlockClassPath {
462 <        my $self=shift;
463 <        my $name=shift;
464 <        my $hashref=shift;
465 <
466 <        $self->{switch}->checktag($name, $hashref, 'path');
467 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
468 <        $self->_CutBlock($$hashref{path});
469 < }
470 <
471 < sub BlockClassPath {
472 <        my $self=shift;
473 <        return $self->{BlockClassPath};
474 < }
475 <
476 < sub export_start_export {
477 <        my $self=shift;
478 <        my $name=shift;
479 <        my $hashref=shift;
480 <
481 <        $self->{switch}->opengroup("__export");
482 < }
483 <
484 < sub export_start {
485 <        my $self=shift;
486 <        my $name=shift;
487 <        my $hashref=shift;
488 <
489 <        $self->{switch}->opengroup("__export");
490 <        if ( exists $$hashref{autoexport} ) {
491 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
492 <          if ( $$hashref{autoexport}=~/true/ ) {
493 <           $self->{switch}->allowgroup("__export","makebuild");
494 <          }
495 <          else {
496 <           $self->{switch}->disallowgroup("__export","makebuild");
497 <          }
498 <        }
499 <        # -- allow default setting from other makefiles
500 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
501 < }
502 <
503 < sub export_end_export {
504 <        my $self=shift;
505 <        $self->{switch}->closegroup("__export");
506 < }
507 <
508 < sub export_end {
509 <        my $self=shift;
510 <        $self->{switch}->closegroup("__export");
511 <        print GNUmakefile "endif\n";
512 < }
513 <
514 < #
515 < # Standard lib tag
516 < #
517 < sub lib_start {
518 <        my $self=shift;
519 <        my $name=shift;
520 <        my $hashref=shift;
521 <
522 <        $self->{switch}->checktag($name, $hashref, 'name');
523 <        if ( $self->{Arch} ) {
524 <           print GNUmakefile "lib+=$$hashref{name}\n";
525 <        }
526 < }
332 >      }
333 >   return "";
334 >   }
335 >
336 > sub bin()
337 >   {
338 >   my ($object,$name,%attributes) = @_;
339 >   $self->pushlevel(\%attributes);# Set nested to 1;
340 >   }
341 >
342 > sub bin_()
343 >   {
344 >   # Need unique name for the binary (always use name of product). Either use "name"
345 >   # given, or use "file" value minus the ending:
346 >   if (exists ($self->{id}->{'name'}))
347 >      {
348 >      $name = $self->{id}->{'name'};
349 >      }
350 >   else
351 >      {
352 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
353 >      }
354 >
355 >   # Store the data:
356 >   $self->productcollector($name,'bin','BIN');
357 >   $self->poplevel();
358 >   }
359 >
360 > sub module()
361 >   {
362 >   my ($object,$name,%attributes) = @_;
363 >   $self->pushlevel(\%attributes);# Set nested to 1;
364 >   }
365 >
366 > sub module_()
367 >   {
368 >   # Need unique name for the module (always use name of product). Either use "name"
369 >   # given, or use "file" value minus the ending:
370 >   if (exists ($self->{id}->{'name'}))
371 >      {
372 >      $name = $self->{id}->{'name'};
373 >      }
374 >   else
375 >      {
376 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
377 >      }
378 >
379 >   # Store the data:
380 >   $self->productcollector($name,'mod','MODULE');
381 >   $self->poplevel();
382 >   }
383 >
384 > sub application()
385 >   {
386 >   my ($object,$name,%attributes) = @_;
387 >   $self->pushlevel(\%attributes);# Set nested to 1;
388 >   }
389 >
390 > sub application_()
391 >   {
392 >   # Need unique name for the application (always use name of product). Either use "name"
393 >   # given, or use "file" value minus the ending:
394 >   if (exists ($self->{id}->{'name'}))
395 >      {
396 >      $name = $self->{id}->{'name'};
397 >      }
398 >   else
399 >      {
400 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
401 >      }
402 >
403 >   # Store the data:
404 >   $self->productcollector($name,'app','APPLICATION');
405 >   $self->poplevel();
406 >   }
407 >
408 > sub library()
409 >   {
410 >   my ($object,$name,%attributes) = @_;
411 >   $self->pushlevel(\%attributes);# Set nested to 1;
412 >   }
413 >
414 > sub library_()
415 >   {
416 >   # Need unique name for the library (always use name of product). Either use "name"
417 >   # given, or use "file" value minus the ending:
418 >   if (exists ($self->{id}->{'name'}))
419 >      {
420 >      $name = $self->{id}->{'name'};
421 >      }
422 >   else
423 >      {
424 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
425 >      }
426 >
427 >   # Store the data:
428 >   $self->productcollector($name,'lib','LIBRARY');
429 >   $self->poplevel();
430 >   }
431 >
432 > sub plugin()
433 >   {
434 >   my ($object,$name,%attributes) = @_;
435 >   $self->pushlevel(\%attributes);# Set nested to 1;
436 >   }
437 >
438 > sub plugin_()
439 >   {
440 >   # Need unique name for the plugin (always use name of product). Either use "name"
441 >   # given, or use "file" value minus the ending:
442 >   if (exists ($self->{id}->{'name'}))
443 >      {
444 >      $name = $self->{id}->{'name'};
445 >      }
446 >   else
447 >      {
448 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
449 >      }
450 >
451 >   # Store the data:
452 >   $self->productcollector($name,'plugin','PLUGIN');
453 >   $self->poplevel();
454 >   }
455 >
456 > sub unittest()
457 >   {
458 >   my ($object,$name,%attributes) = @_;
459 >   $self->pushlevel(\%attributes);# Set nested to 1;
460 >   }
461 >
462 > sub unittest_()
463 >   {
464 >   # Need unique name for the unittest (always use name of product). Either use "name"
465 >   # given, or use "file" value minus the ending:
466 >   if (exists ($self->{id}->{'name'}))
467 >      {
468 >      $name = $self->{id}->{'name'};
469 >      }
470 >   else
471 >      {
472 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
473 >      }
474 >
475 >   # Store the data:
476 >   $self->productcollector($name,'unittest','unittest');
477 >   $self->poplevel();
478 >   }
479 >
480 > sub productcollector()
481 >   {
482 >   my $self=shift;
483 >   my ($name,$typeshort,$typefull)=@_;
484 >   # Create a new Product object for storage of data:
485 >   use BuildSystem::Product;
486 >   my $product = BuildSystem::Product->new();
487 >   # Store the name:
488 >   $product->name($name);
489 >   $product->type($typeshort);
490 >   # Store the files. Take the BuildFile path as the initial path for
491 >   # expanding source file globs:
492 >   $product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]);
493 >   # Store the data content:
494 >   $product->_data($self->{tagcontent});
495 >   # And store in a hash (all build products in same place):
496 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
497 >   }
498 >
499 > sub pushlevel
500 >   {
501 >   my $self = shift;
502 >   my ($info)=@_;
503 >  
504 >   $self->{id} = $info if (defined $info);
505 >   $self->{nested} = 1;
506 >   $self->{tagcontent}={};
507 >   }
508 >
509 > sub poplevel
510 >   {
511 >   my $self = shift;
512 >   delete $self->{id};
513 >   delete $self->{nested};
514 >   delete $self->{tagcontent};
515 >   }
516 >
517 > sub dependencies()
518 >   {
519 >   my $self=shift;
520 >   # Make a copy of the variable so that
521 >   # we don't have a DEPENDENCIES entry in RAWDATA:
522 >   my %DEPS=%{$self->{DEPENDENCIES}};
523 >   delete $self->{DEPENDENCIES};
524 >   return \%DEPS;
525 >   }
526 >
527 > sub skippeddirs()
528 >   {
529 >   my $self=shift;
530 >   my ($here)=@_;
531 >   my $skipped;
532 >
533 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
534 >      {
535 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
536 >      delete $self->{content}->{SKIPPEDDIRS};
537 >      }
538 >  
539 >   delete $self->{content}->{SKIPPEDDIRS};
540 >   return $skipped;
541 >   }
542 >
543 > sub hasexport()
544 >   {
545 >   my $self=shift;
546 >   # Check to see if there is a valid export block:
547 >   my $nkeys = $self->exporteddatatypes();
548 >   $nkeys > 0 ? return 1 : return 0;
549 >   }
550 >
551 > sub has()
552 >   {
553 >   my $self=shift;
554 >   my ($datatype)=@_;  
555 >   (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
556 >   }
557 >
558 > sub exported()
559 >   {
560 >   my $self=shift;
561 >   # Return a hash. Keys are type of data provided:
562 >   return ($self->{content}->{EXPORT});
563 >   }
564 >
565 > sub exporteddatatypes()
566 >   {
567 >   my $self=shift;
568 >   # Return exported data types:
569 >   return keys %{$self->{content}->{EXPORT}};
570 >   }
571 >
572 > sub defined_group()
573 >   {
574 >   my $self=shift;
575 >
576 >   if (exists($self->{content}->{DEFINED_GROUP}))
577 >      {  
578 >      # Return a list of keys (group names) for defined groups:
579 >      return [ keys %{$self->{content}->{DEFINED_GROUP}} ];
580 >      }
581 >   else
582 >      {
583 >      return 0;
584 >      }
585 >   }
586 >
587 > sub dataforgroup()
588 >   {
589 >   my $self=shift;
590 >   my ($groupname)=@_;
591 >   # Return hash containing data for defined group
592 >   # $groupname or return undef:
593 >   return $self->{content}->{DEFINED_GROUP}->{$groupname};
594 >   }
595 >
596 > sub buildproducts()
597 >   {
598 >   my $self=shift;
599 >   # Returns hash of build products and their data:
600 >   return $self->{content}->{BUILDPRODUCTS};
601 >   }
602 >
603 > sub values()
604 >   {
605 >   my $self=shift;
606 >   my ($type)=@_;
607 >   # Get a list of values from known types
608 >   return $self->{content}->{BUILDPRODUCTS}->{$type};
609 >   }
610 >
611 > sub basic_tags()
612 >   {
613 >   my $self=shift;
614 >   my $datatags=[];
615 >   my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE PLUGIN BUILDPRODUCTS) ];
616 >   my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
617 >   my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
618 >   my @all_skip_tags;
619 >  
620 >   push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
621 >
622 >   foreach my $t (keys %{$self->{content}})
623 >      {
624 >      push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
625 >      }
626 >   return @{$datatags};
627 >   }
628 >
629 > sub clean()
630 >   {
631 >   my $self=shift;
632 >   my (@tags) = @_;
633 >
634 >   # Delete some useless entries:
635 >   delete $self->{makefilecontent};
636 >   delete $self->{simpledoc};
637 >   delete $self->{id};
638 >   delete $self->{tagcontent};
639 >   delete $self->{nested};
640 >
641 >   delete $self->{DEPENDENCIES};
642 >  
643 >   map
644 >      {
645 >      delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
646 >      } @tags;
647 >  
648 >   return $self;
649 >   }
650 >
651 > sub AUTOLOAD()
652 >   {
653 >   my ($xmlparser,$name,%attributes)=@_;
654 >   return if $AUTOLOAD =~ /::DESTROY$/;
655 >   my $name=$AUTOLOAD;
656 >   $name =~ s/.*://;
657 >   }
658  
659 < #
829 < # libtype specification
830 < #
831 < sub LibType_Start {
832 <        my $self=shift;
833 <        my $name=shift;
834 <        my $hashref=shift;
835 <
836 <        if ( $self->{Arch} ) {
837 <        if ( defined $self->{libtype_conext} ) {
838 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
839 <                " without a </$name> tag to close previous context");
840 <        }
841 <        else {
842 <        $self->{libtype_conext}=1;
843 <        $self->{switch}->checktag($name, $hashref, 'type');
844 <        
845 <        print GNUmakefile "# Specify Library Type\n";
846 <        print GNUmakefile "DefaultLibsOff=yes\n";
847 <        if ( $$hashref{'type'}=~/^archive/i ) {
848 <          print GNUmakefile "LibArchive=true\n";
849 <        }
850 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
851 <          print GNUmakefile "LibDebugArchive=true\n";
852 <        }
853 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
854 <          print GNUmakefile "LibDebugShared=true\n";
855 <        }
856 <        elsif ($$hashref{'type'}=~/shared/i ) {
857 <          print GNUmakefile 'LibShared=true'."\n";
858 <        }
859 <        print GNUmakefile "\n";
860 <        }
861 <        }
862 < }
863 <
864 < sub LibType_text {
865 <        my $self=shift;
866 <        my $name=shift;
867 <        my $string=shift;
868 <
869 <        if ( $self->{Arch} ) {
870 <          $string=~s/\n/ /g;
871 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
872 <          print GNUmakefile $string;
873 <          print GNUmakefile "\n";
874 <        }
875 < }
876 <
877 < sub LibType_end {
878 <        my $self=shift;
879 <        my $name=shift;
880 <
881 <        undef $self->{libtype_conext};
882 < }
883 <
884 < sub Environment_start {
885 <        my $self=shift;
886 <        my $name=shift;
887 <        my $hashref=shift;
888 <
889 <        if ( $self->{Arch} ) {
890 <          $self->{envnum}++;
891 <
892 <          # open a new Environment File
893 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
894 <                $self->{envnum}.".mk";
895 <          use FileHandle;
896 <          my $fh=FileHandle->new();
897 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
898 <          push @{$self->{filehandlestack}}, $fh;
899 <          *GNUmakefile=$fh;
900 <
901 <          # include the approprate environment file
902 <          if ( $self->{envlevel} == 0 ) {
903 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
904 <                $self->{path}."/BuildFile.mk\n";
905 <          }
906 <          else {
907 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
908 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
909 <          }
910 <          $self->{envlevel}++;
911 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
912 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
913 <        }
914 < }
915 <
916 < sub Environment_end {
917 <        my $self=shift;
918 <        my $fd;
919 <
920 <        if ( $self->{Arch} ) {
921 <          $self->{envlevel}--;
922 <          if ( $self->{envlevel} < 0 ) {
923 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
924 <            exit 1;
925 <          }
926 <          close GNUmakefile;
927 <          # restore the last filehandle
928 <          $fd=pop @{$self->{filehandlestack}};
929 <          close $fd;
930 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
931 <          if ( $self->{envlevel} < 1 ) {
932 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
933 <                        "BuildFile.mk";
934 <          }
935 <          else {
936 <            $self->{currentenv}=
937 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
938 <                $self->{Envlevels}[$self->{envlevel}];
939 <          }
940 <        }
941 < }
659 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines