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.12 by williamc, Tue Nov 14 15:18:41 2000 UTC vs.
Revision 1.31 by muzaffar, Tue Nov 6 14:13:49 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,Builder)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockParse(Block) : perform a parse to modify the block
9 < # BlockClassPath() : Return the class path
10 < # ignore()      : return 1 if directory should be ignored 0 otherwise
11 < # classname()   : get/set the associated class
12 < # buildfile()   : get/set BuildFile location
13 < # makefile()    : get the generated makefile
14 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
16 use ActiveDoc::SimpleDoc;
17 use BuildSystem::ToolBox;
13   require 5.004;
14 + use Exporter;
15 + use ActiveDoc::SimpleDoc;
16  
17 < BEGIN {
18 < $buildfile="BuildFile";
22 < }
23 <
24 < sub new {
25 <        my $class=shift;
26 <        my $self={};
27 <        bless $self, $class;
28 <        $self->{area}=shift;
29 <        $self->{Builder}=shift;
30 <        $self->{toolbox}=$self->{area}->toolbox();
31 <        $self->{localtop}=$self->{area}->location();
32 <        # -- set RELEASTOP
33 <        my $rarea=$self->{area}->linkarea();
34 <        if ( ! defined $rarea ) {
35 <          $self->{releasetop}=$self->{localtop};
36 <        }
37 <        else {
38 <          $self->{releasetop}=$rarea->location();
39 <        }
40 <        $self->{releasetop}=$self->{area}->location();
41 <        $self->{Arch}=1;
42 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
43 <        return $self;
44 < }
45 <
46 < sub buildfile {
47 <        my $self=shift;
48 <        if ( @_ ) {
49 <          $self->{buildfile}=shift;
50 <        }
51 <        return $self->{buildfile};
52 < }
53 <
54 < sub makefile {
55 <        my $self=shift;
56 <        if ( @_ ) {
57 <          $self->{makefile}=shift;
58 <        }
59 <        return $self->{makefile};
60 < }
61 <
62 < sub BlockParse {
63 <        my $self=shift;
64 <        $self->{block}=shift;
65 <
66 <        # -- set up the block parse
67 <        my $switch=$self->_initswitcher();
68 <        my $parse="block";
69 <        $switch->newparse($parse);
70 <        $switch->addignoretags($parse);
71 <        $switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self);
72 <        $switch->filetoparse($self->buildfile());
73 <
74 <        # -- parse away
75 <        $self->{switch}=$switch;
76 <        $switch->parse("block");
77 < }
78 <
79 < sub Parsetofh {
80 <        my $self=shift;
81 <        my $fh=shift;
82 <        $self->{buildblock}=shift;
83 <
84 <        # -- set up for parse
85 <        @{$self->{filehandlestack}}=($fh);
86 <        $self->{switch}->filetoparse($self->buildfile());
87 <        *GNUmakefile=$fh;
88 <
89 <        # -- generate makefile
90 <        $self->{switch}->parse("makebuild"); # sort out supported tags
91 <
92 <        # -- Clean up
93 <        close GNUmakefile;
94 < }
95 <
96 < sub ignore {
97 <        my $self=shift;
98 <        return (defined $self->{ignore})?$self->{ignore}:0;
99 < }
100 <
101 < sub _initswitcher {
102 <        my $self=shift;
103 <        my $switch=ActiveDoc::SimpleDoc->new();
104 <        my $parse="makebuild";
105 <        $switch->newparse($parse);
106 <        $switch->addignoretags($parse);
107 <        $self->_commontags($switch,$parse);
108 <        #$switch->addtag($parse,"Build", \&Build_start, $self);
109 <        $switch->addtag($parse,"none",
110 <                                        \&OutToMakefile,$self,
111 <                                        \&OutToMakefile, $self,
112 <                                        "", $self);
113 <        $switch->addtag($parse,"Bin",
114 <                                        \&Bin_start,$self,
115 <                                        \&OutToScreen, $self,
116 <                                        "", $self);
117 <         $switch->addtag($parse,"ProductStore",
118 <                                        \&Store_start,$self,
119 <                                        "", $self,
120 <                                        "", $self);
121 <        $switch->addtag($parse,"LibType",
122 <                                        \&LibType_Start,$self,
123 <                                        \&LibType_text, $self,
124 <                                        \&LibType_end,$self);
125 <        $switch->addtag($parse,"ConfigurationClass",
126 <                                        \&Class_StartTag,$self,
127 <                                        \&OutToMakefile, $self,
128 <                                        "", $self);
129 <        $switch->addtag($parse,"ClassPath",
130 <                                        \&setBlockClassPath,$self,
131 <                                        \&OutToMakefile, $self,
132 <                                        "", $self);
133 <        $switch->addtag($parse,"AssociateGroup",
134 <                                        "",$self,
135 <                                        \&AssociateGroup,$self,
136 <                                        "", $self);
137 <        $switch->addtag($parse,"Environment",
138 <                                        \&Environment_start,$self,
139 <                                        \&OutToMakefile, $self,
140 <                                        \&Environment_end,$self);
141 <        $switch->addtag($parse,"Export",
142 <                                        \&export_start,$self,
143 <                                        \&OutToMakefile, $self,
144 <                                        \&export_end,$self);
145 <        return $switch;
146 < }
147 <
148 < sub _commontags {
149 <        my $self=shift;
150 <        my $switch=shift;
151 <        my $parse=shift;
152 <
153 <        $switch->grouptag("Export",$parse);
154 <        $switch->addtag($parse,"Use",\&Use_start,$self,
155 <                                               \&OutToMakefile, $self,
156 <                                                "", $self);
157 <        $switch->addtag($parse,"Group",\&Group_start,$self,
158 <                                               \&OutToMakefile, $self,
159 <                                                "", $self);
160 <        $switch->grouptag("Group",$parse);
161 <        $switch->addtag($parse,"External",
162 <                                        \&External_StartTag,$self,
163 <                                        \&OutToMakefile, $self,
164 <                                        "", $self);
165 <        $switch->addtag($parse,"lib",
166 <                                        \&lib_start,$self,
167 <                                        \&OutToMakefile, $self,
168 <                                        "", $self);
169 <        $switch->addtag($parse,"Architecture",
170 <                                        \&Arch_Start,$self,
171 <                                        \&OutToMakefile, $self,
172 <                                        \&Arch_End,$self);
173 <        $switch->addtag($parse,"INCLUDE_PATH",
174 <                                        \&IncludePath_Start,$self,
175 <                                        \&OutToMakefile, $self,
176 <                                        "",$self);
177 <        return $switch;
178 < }
179 <
180 < sub GenerateMakefile {
181 <        my $self=shift;
182 <        my $infile=shift;
183 <        my $outfile=shift;
184 <
185 <        $self->{switch}=$self->_initswitcher();
186 <        $self->{switch}->filetoparse($infile);
187 <
188 <        # open a temporary gnumakefile to store output.
189 <        my $fh=FileHandle->new();
190 <        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
191 <                                                                "$!\n";
192 <        @{$self->{filehandlestack}}=($fh);
193 <
194 <        #  -- make an alias
195 <        *GNUmakefile=$fh;
196 <        if ( -e $ENV{LatestBuildFile} ) {
197 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
198 <        }
199 <        $self->{switch}->parse("makebuild"); # sort out supported tags
200 <        close GNUmakefile;
201 <        return $outfile;
202 < }
203 <
204 < sub ParseBuildFile {
205 <        my $self=shift;
206 <        my $base=shift;
207 <        my $path=shift;
208 <        my $filename=shift @_;
209 <        my $fullfilename;
210 <        if ( $filename!~/^\// ) {
211 <         $fullfilename="$base/$path/$filename";
212 <        }
213 <        else {
214 <         $fullfilename=$filename;
215 <        }
216 <        $self->{path}=$path;
217 <        #print "Processing $fullfilename\n";
218 <        $numbins=0;
219 <        $self->{envnum}=0;
220 <        $self->{envlevel}=0;
221 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
222 <                                                                "BuildFile.mk";
223 <        $self->{currentenv}=$self->{makefile};
224 <        $self->{switch}=$self->_initswitcher();
225 <        $self->{switch}->filetoparse($fullfilename);
226 <
227 < #       $self->{switch}->{Strict_no_cr}='no';
228 <        #open a temporary gnumakefile to store output.
229 <        use Utilities::AddDir;
230 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
231 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
232 <        $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
233 < }
234 <
235 < sub classname {
236 <        my $self=shift;
237 <        if ( @_ ) {
238 <          $self->{classname}=shift;
239 <        }
240 <        return $self->{classname};
241 < }
242 <
243 < sub ParseBuildFile_Export {
244 <        my $self=shift;
245 <        my $filename=shift;
246 <        my $bf=BuildSystem::BuildFile->new($self->{area},$self->{Builder});
247 <        if ( defined $self->{remoteproject} ) {
248 <           $bf->{remoteproject}=$self->{remoteproject};
249 <        }
250 <        $bf->_parseexport($filename);
251 <        undef $bf;
252 < }
253 <
254 < sub _location {
255 <        my $self=shift;
256 <        use File::Basename;
257 <
258 <        return dirname($self->{switch}->filetoparse());
259 < }
260 <
261 < sub _parseexport {
262 <        my $self=shift;
263 <        my $filename=shift;
264 <
265 <        my $switchex=ActiveDoc::SimpleDoc->new();
266 <        $switchex->filetoparse($filename);
267 <        $switchex->newparse("export");
268 <        $switchex->addignoretags("export");
269 <        $switchex->addtag("export","Export",
270 <                                        \&export_start_export,$self,
271 <                                        \&OutToMakefile, $self,
272 <                                        \&export_end_export,$self);
273 <        $self->_commontags($switchex,"export");
274 <        $switchex->allowgroup("__export","export");
275 < #       $switchex->{Strict_no_cr}='no';
276 <        $self->{switch}=$switchex;
277 <        $switchex->parse("export"); # sort out supported tags
278 < }
279 <
280 < sub _pushremoteproject {
281 <        my $self=shift;
282 <        my $path=shift;
283 <        
284 <        if ( defined $self->{remoteproject} ) {
285 <          push @{$self->{rpstack}}, $self->{remoteproject};
286 <        }
287 <        $self->{remoteproject}=$path;
288 < }
289 <
290 < sub _popremoteproject {
291 <        my $self=shift;
292 <        if ( $#{$self->{rpstack}} >=0 ) {
293 <          $self->{remoteproject}=pop @{$self->{rpstack}};
294 <        }
295 <        else {
296 <          undef $self->{remoteproject};
297 <        }
298 < }
299 <
300 < sub _toolmapper {
301 <        my $self=shift;
302 <        if ( ! defined $self->{mapper} ) {
303 <           require BuildSystem::ToolMapper;
304 <           $self->{mapper}=BuildSystem::ToolMapper->new();
305 <        }
306 <        return $self->{mapper};
307 < }
308 <
309 <
310 < # ---- Tag routines
311 <
312 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
313 < #   the type tag will pick up a pre-defined class type from project space.
314 <
315 < sub Class_StartTag {
316 <        my $self=shift;
317 <        my $name=shift;
318 <        my $hashref=shift;
319 <        
320 <        if ( $self->{Arch} ) {
321 <         if ( defined $$hashref{'type'} ) {
322 <                 $self->classname($$hashref{'type'});
323 <         }
324 <        }
325 < }
326 <
327 < sub IncludePath_Start {
328 <        my $self=shift;
329 <        my $name=shift;
330 <        my $hashref=shift;
331 <
332 <        $self->{switch}->checktag( $name, $hashref, 'path');
333 <        if ( $self->{Arch} ) {
334 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
335 <                                                $$hashref{'path'}."\n";
336 <        }
337 < }
338 <
339 < #
340 < # --- <Build class=> tag
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 +   my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::BuildFile" version="1.0">';
47 +   my $ftail='</doc>';
48 +   $self->{scramdoc}->filetoparse($filename);
49 +   $self->{scramdoc}->parse("builder",$fhead,$ftail);
50 +   # We're done with the SimpleDoc object so delete it:
51 +   delete $self->{scramdoc};
52 +   }
53 +
54 + sub classpath()
55 +   {
56 +   my ($object,$name,%attributes)=@_;
57 +   # The getter part:
58 +   if (ref($object) eq __PACKAGE__)
59 +      {
60 +      return $self->{content}->{CLASSPATH};
61 +      }
62 +  
63 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'})
64 +      : push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'});
65 +   }
66 +
67 + sub productstore()
68 +   {
69 +   my ($object,$name,%attributes)=@_;
70 +   # The getter part:
71 +   if (ref($object) eq __PACKAGE__)
72 +      {
73 +      # Return an array of ProductStore hashes:
74 +      return $self->{content}->{PRODUCTSTORE};
75 +      }
76 +  
77 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes)
78 +      : push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ;
79 +   }
80 +
81 + sub include()
82 +   {
83 +   my $self=shift;
84 +   # Return an array of required includes:
85 +   return $self->{content}->{INCLUDE};
86 +   }
87 +
88 + sub include_path()
89 +   {
90 +   my ($object,$name,%attributes)=@_;
91 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'})
92 +      : push(@{$self->{content}->{INCLUDE}}, $attributes{'path'});
93 +   }
94 +
95 + sub use()
96 +   {
97 +   my $object=shift;
98 +   # The getter part:
99 +   if (ref($object) eq __PACKAGE__)
100 +      {
101 +      # Add or return uses (package deps):
102 +      @_ ? push(@{$self->{content}->{USE}},@_)
103 +         : @{$self->{content}->{USE}};
104 +      }
105 +   else
106 +      {
107 +      my ($name,%attributes)=@_;
108 +      $self->{DEPENDENCIES}->{$attributes{'name'}} = 1;
109 +      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'})
110 +         : push(@{$self->{content}->{USE}}, $attributes{'name'});
111 +      }
112 +   }
113 +
114 + sub architecture()
115 +   {
116 +   my ($object,$name,%attributes)=@_;
117 +   $self->pushlevel(\%attributes); # Set nested to 1;
118 +   }
119 +
120 + sub architecture_()
121 +   {
122 +   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
123 +   $self->poplevel();
124 +   }
125 +
126 + sub export()
127 +   {
128 +   $self->pushlevel(); # Set nested to 1;
129 +   }
130 +
131 + sub export_()
132 +   {
133 +   $self->{content}->{EXPORT} = $self->{tagcontent};
134 +   $self->poplevel();
135 +   }
136 +
137 + sub lib()
138 +   {
139 +   my ($object,$name,%attributes)=@_;
140 +   # The getter part:
141 +   if (ref($object) eq __PACKAGE__)
142 +      {
143 +      # Return an array of required libs:
144 +      return $self->{content}->{LIB};      
145 +      }
146 +  
147 +   my $libname;
148 +  
149 +   if (exists($attributes{'position'}))
150 +      {
151 +      if ($attributes{'position'} eq 'first')
152 +         {
153 +         $libname = "F:".$attributes{'name'};
154 +         }
155 +      else
156 +         {
157 +         # There was a position entry but it didn't make sense:
158 +         $libname = $attributes{'name'};
159 +         }
160 +      }
161 +   else
162 +      {
163 +      $libname = $attributes{'name'};
164 +      }
165 +   # We have a libname, add it to the list:
166 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname)
167 +      : push(@{$self->{content}->{LIB}}, $libname);
168 +   }
169 +
170 + sub libtype()
171 +   {
172 +   my ($object,$name,%attributes)=@_;
173 +   # The getter part:
174 +   if (ref($object) eq __PACKAGE__)
175 +      {
176 +      # Return an array of required libs:
177 +      return $self->{content}->{LIBTYPE};      
178 +      }
179 +
180 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'})
181 +      : push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'});
182 +   }
183 +
184 + sub skip()
185 +   {
186 +   my ($object,$name,%attributes)=@_;
187 +   $self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ]
188 +      : $self->{content}->{SKIPPEDDIRS} = [ 1 ];
189 +   }
190 +
191 + sub skip_message()
192 +   {
193 +   my ($object,$name,@message) = @_;
194 +   # Save any message text between <skip> tags:
195 +   if ($#message > -1)
196 +      {
197 +      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ])
198 +         : push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]);
199 +      }
200 +   }
201 +
202 + sub skip_()
203 +   {
204 +   my ($object,$name)=@_;
205 +   }
206 +
207 + sub makefile()
208 +   {
209 +   my ($object,$name,%attributes)=@_;
210 +   # The getter part:
211 +   if (ref($object) eq __PACKAGE__)
212 +      {
213 +      # Return Makefile content:
214 +      return $self->{content}->{MAKEFILE};
215 +      }
216 +  
217 +   # Set our own Char handler so we can collect the content
218 +   # of the Makefile tag:
219 +   $object->setHandlers(Char => \&makefile_content);
220 +   $self->{makefilecontent} = [];
221 +   }
222 +
223 + sub makefile_content()
224 +   {
225 +   my ($object, @strings) = @_;
226 +   foreach my $str (@strings)
227 +      {
228 +      push(@{$self->{makefilecontent}},$str);
229 +      }
230 +   }
231 +
232 + sub makefile_()
233 +   {
234 +   my ($object,$name)=@_;
235 +   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@{$self->{makefilecontent}}))
236 +      : push(@{$self->{content}->{MAKEFILE}}, join("\n",@{$self->{makefilecontent}}));
237 +   delete $self->{makefilecontent};
238 +   # Unset the Char handler to revert to the default behaviour:
239 +   $object->setHandlers(Char => 0);
240 +   }
241 +
242 + sub define_group()
243 +   {
244 +   my ($object,$name,%attributes)=@_;
245 +   $self->pushlevel(\%attributes); # Set nested to 1;
246 +   }
247 +
248 + sub define_group_()
249 +   {
250 +   $self->{content}->{DEFINED_GROUP}->{$self->{id}->{'name'}}=$self->{tagcontent};
251 +   $self->poplevel();
252 +   }
253 +
254 + sub group()
255 +   {
256 +   my $object=shift;
257 +   # The getter part:
258 +   if (ref($object) eq __PACKAGE__)
259 +      {
260 +      # Add or return groups:
261 +      @_ ? push(@{$self->{content}->{GROUP}},@_)
262 +         : @{$self->{content}->{GROUP}};
263 +      }
264 +   else
265 +      {
266 +      my ($name,%attributes)=@_;
267 +      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{GROUP}}, $attributes{'name'})
268 +         : push(@{$self->{content}->{GROUP}}, $attributes{'name'});
269 +      }
270 +   }
271 +
272 + sub flags()
273 +   {
274 +   my ($object,$name,%attributes)=@_;
275 +   # The getter part:
276 +   if (ref($object) eq __PACKAGE__)
277 +      {
278 +      # Return an array of ProductStore hashes:
279 +      return $self->{content}->{FLAGS};
280 +      }
281 +  
282 +   # Extract the flag name and its value:
283 +   my ($flagname,$flagvaluestring) = each %attributes;
284 +   $flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase
285 +   chomp($flagvaluestring);
286 +   my @flagvalues = ( $flagvaluestring );
287 +   # Is current tag within another tag block?
288 +   if ($self->{nested} == 1)
289 +      {
290 +      # Check to see if the current flag name is already stored in the hash. If so,
291 +      # just add the new values to the array of flag values:
292 +      if (exists ($self->{tagcontent}->{FLAGS}->{$flagname}))
293 +         {
294 +         push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues);
295 +         }
296 +      else
297 +         {
298 +         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
299 +         }
300 +      }
301 +   else
302 +      {
303 +      if (exists ($self->{content}->{FLAGS}->{$flagname}))
304 +         {
305 +         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
306 +         }
307 +      else
308 +         {
309 +         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
310 +         }
311 +      }
312 +   }
313  
314 < #
315 < # Parameter collection
316 < #
317 < sub BuildBlock_start {
318 <        my $self=shift;
319 <        my $name=shift;
320 <        my $hashref=shift;
321 <
322 <
323 <        my $blockobjid=$self->__blockobjid($hashref);
324 <
325 <        if ( $self->{Arch} ) {
326 <
327 <           # -- get any objects that match
328 <           my $inheritobj=$self->{block}->getobj($blockobjid);
329 <
330 <           # -- create an object with inherited properties
331 <           my $obj;
332 <           if ( ! defined $inheritobj ) {
362 <               # -- check we have a lookup for the class type
363 <               my $mapper=$self->_toolmapper();
364 <               if ( ! $mapper->exists($$hashref{'class'}) ) {
365 <                 $self->{switch}->parseerror("Unknown class : ".
366 <                                                        $$hashref{'class'});
367 <               }
368 <               $obj=BuildSystem::BuildClass->new();
369 <           }
370 <           else {
371 <               # -- inherit the properties from class with the same id class
372 <               $obj=$inheritobj->child();
373 <           }
374 <
375 <           # -- add changes from our tag
376 <           $obj->paramupdate($hashref);
377 <
378 <           # -- store the new object in the block
379 <           $self->{block}->setobj($obj,$blockobjid);
380 <        }
381 < }
382 <
383 < sub BuilderClass_buildmakefile {
384 <        my $self=shift;
385 <        my $name=shift;
386 <        my $hashref=shift;
387 <
388 <        my $blockobjid=$self->__blockobjid($hashref);
389 <
390 <        if ( $self->{Arch} ) {
391 <           # -- get the matching block object
392 <           my $blockobj=$self->{buildblock}->getobj($blockobjid);
393 <
394 <           # -- top level buildfile
395 <           my $fh=$self->{filehandlestack}[0];
396 <
397 <           # -- var initialisation
398 <           my @deftypes=();
399 <           my $buildname="";
400 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
401 <
402 <           # -- error checking
403 <           if ( ! defined $blockobj->param("default") ) {
404 <             $self->error("No default build parameter defined for ".
405 <                $$hashref{'class'}." ".$$hashref{'id'});
406 <           }
407 <           if ( ! defined $blockobj->param("name") ) {
408 <             $self->error("\"name\" parameter defined for ".
409 <                $$hashref{'class'}." ".$$hashref{'id'});
410 <           }
411 <
412 <
413 <           foreach $param ( $blockobj->paramlist() ) {
414 <             # -- check for params that need special handling
415 <             if ( $param eq "default" ) {
416 <                @deftypes=split /,/, $param;
417 <             }
418 <             elsif ( $param eq "name" ) {
419 <                $buildname=$blockobj->param($param);
420 <             }
421 <             else {
422 <                # -- simple transfer of block object parameters to makefile
423 <                print $fh $param.":=".$blockobj->param($param)."\n";
424 <             }
425 <           }
426 <
427 <           # -- construct the targets in the top makefile
428 <           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
429 <           $self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types);
430 <        }
431 < }
432 <
433 < sub _blockobjid {
434 <        my $self=shift;
435 <        my $hashref=shift;
436 <
437 <        $self->{switch}->checktag($name,$hashref,'class');
438 <        $self->{switch}->checktag($name,$hashref,'id');
439 <        my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'};
440 <
441 <        return $blockobjid;
442 < }
443 <
444 < sub Build_start {
445 <        my $self=shift;
446 <        my $name=shift;
447 <        my $hashref=shift;
448 <
449 <        $self->{switch}->checktag($name,$hashref,'class');
450 <        $self->{switch}->checktag($name,$hashref,'id');
451 <        if ( $self->{Arch} ) {
452 <
453 <          # -- determine the build products name
454 <          my $name;
455 <          if ( exists $$hashref{'name'} ) {
456 <            $name=$$hashref{'name'};
457 <          }
458 <          else {
459 <            $self->{switch}->parseerror("No name specified for build product");
460 <            #$name="\$(buildname)";
461 <          }
462 <
463 <          # -- check we have a lookup for the class type
464 <          my $mapper=$self->_toolmapper();
465 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
466 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
467 <          }
468 <          else {
469 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
470 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
471 <
472 <           my $fh=$self->{filehandlestack}[0];
473 <           my @targets=();
474 <
475 <           # -- generate generic targets
476 <           print $fh "ifndef _BuildLink_\n";
477 <           print $fh "# -- Generic targets\n";
478 <           push @targets, $$hashref{'class'};
479 <           foreach $dtype ( @deftypes ) {
480 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
481 <                                                                $dtype."\n";
482 <           }
483 <           print $fh "\n";
484 <
485 <           # -- generate targets for each type
486 <           foreach $type ( @types ) {
487 <
488 <            # -- generic name for each type
489 <            my $pattern=$$hashref{'class'}."_".$type;
490 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
491 <            print $fh "# ------ $pattern rules ---------------\n";
492 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
493 <                                                        "_".$type."_$name\n\n";
494 <
495 <            # -- create a new directory for each type
496 <            push @targets, $pattern;
497 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
498 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
499 <            my $makefile=$here."/BuildFile.mk";
500 < #           AddDir::adddir($here);
501 <
502 <            # -- create link targets to the directory
503 <            push @targets, $dirname;
504 <            print $fh "# -- Link Targets to $type directories\n";
505 <            print $fh "$dirname: make_$dirname\n";
506 <            print $fh "\t\@cd $here; \\\n";
507 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
508 <                        " workdir=$here ".
509 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
510 <
511 <            # -- write target to make makefile for each directory
512 <            print $fh "# -- Build target directories\n";
513 <            print $fh "make_$dirname:\n";
514 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
515 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
516 <            print $fh "\t  mkdir $here; \\\n";
517 <            print $fh "\t fi;\\\n";
518 <            print $fh "\t cd $dirname; \\\n";
519 <            print $fh "\t echo include ".$self->{currentenv}." > ".
520 <                                                        "$makefile; \\\n";
521 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
522 <                                        " >> $makefile; \\\n";
523 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
524 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
525 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
526 <             foreach $f ( @file ) {
527 <              print $fh "\t echo -include $f >> $makefile; \\\n";
528 <             }
314 > sub allflags()
315 >   {
316 >   my $self=shift;
317 >   # Return hash data for flags:
318 >   return $self->{content}->{FLAGS};
319 >   }
320 >
321 > sub archspecific()
322 >   {
323 >   my $self=shift;
324 >  
325 >   # Check to see if there is arch-dependent data. If so, return it:
326 >   if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
327 >      {
328 >      while (my ($k,$v) = each %{$self->{content}->{ARCH}})
329 >         {
330 >         if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
331 >            {
332 >            return $self->{content}->{ARCH}->{$k};
333              }
530            print $fh "\tfi\n";
531            print $fh "\n";
532 #           print $typefile "$name :\n";
533 #           print $typefile "\t\$(_quietbuild_)";
534 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
535 #           print $typefile "\t\$(_quietstamp_)";
536 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
537
538            # -- cleaning targets
539            push @targets, "clean_$dirname";
540            print $fh "# -- cleaning targets\n";
541            print $fh "clean::clean_$dirname\n";
542            print $fh "clean_".$dirname."::\n";
543            print $fh "\t\@echo cleaning $dirname\n";
544            print $fh "\t\@if [ -d $here ]; then \\\n";
545            print $fh "\tcd $here; \\\n";
546            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
547                        $here." _BuildLink_=1 -f ".
548                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
549            print $fh "\tfi\n\n";
550
551
552          }
553          # -- help targets
554          print $fh "helpheader::\n";
555          print $fh "\t\@echo Targets available:\n";
556          print $fh "\t\@echo ------------------\n\n";
557          print $fh "help::helpheader\n";
558          foreach $target ( @targets ) {
559            print $fh "help::\n";
560            print $fh "\t\@echo $target\n"
561          }
562          print $fh "endif\n";
563         } # end else
564        }
565 }
566
567 sub Bin_start {
568        my $self=shift;
569        my $name=shift;
570        my $hashref=shift;
571
572        my $fileclass;
573        my @tools;
574        my $tool;
575        my $filename;
576        my $objectname;
577        
578        $self->{switch}->checktag($name,$hashref,'file');
579        if ( $self->{Arch} ) {
580        if ( ! defined $$hashref{name} ) {
581                ($$hashref{name}=$$hashref{file})=~s/\..*//;
582        }
583        ($filename=$$hashref{file})=~s/\..*//;
584
585        # Create a new directory for each binary target
586        my $dirname="bin_".$$hashref{name};
587        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
588        open (binGNUmakefile,
589           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
590           "BuildFile.mk $!\n";
591
592        # Create the link targets
593        $numbins++;
594        my $fh=$self->{filehandlestack}[0];
595        print $fh <<ENDTEXT;
596
597 # Link Targets to binary directories
598 ifdef BINMODE
599 # We dont want to build a library here
600 override files:=
601 endif
602 ifndef BINMODE
603
604 define stepdown_$$hashref{'name'}
605 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
606 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
607 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
608 fi
609 endef
610
611 define stepdown2_$$hashref{'name'}
612 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
613 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
614 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
615 fi
616
617 endef
618
619 bin_$$hashref{'name'}_%:: dummy
620        \@\$(stepdown2_$$hashref{'name'})
621
622 $$hashref{'name'}_%:: dummy
623        \@\$(stepdown_$$hashref{'name'})
624
625 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
626        \@\$(stepdown_$$hashref{'name'})
627
628 binfiles+=$$hashref{'file'}
629 locbinfiles+=$dirname/$$hashref{'file'}
630 endif
631
632
633 ENDTEXT
634
635
636 # the binary specifics makefile
637        print binGNUmakefile "include ".$self->{currentenv}."\n";
638        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
639
640 # alias for bin_Insure
641        print binGNUmakefile <<ENDTEXT;
642
643 bin_insure:bin_Insure
644 ifdef MAKETARGET_bin_insure
645 MAKETARGET_$$hashref{name}_Insure=1
646 endif
647
648 # debuggging target
649 $$hashref{'name'}_echo_% :: echo_%
650
651 # help targets
652 help::
653 \t\@echo Targets For $$hashref{'name'}
654 \t\@echo -------------------------------------
655 \t\@echo $$hashref{'name'}  - default build
656 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
657 ENDTEXT
658
659 # Make generic rules for each type
660        $targettypes={
661                "bin" => 'o',
662                "bin_debug" => 'd',
663                "bin_debug_local" => 'l_d',
664                "bin_Insure" => 'Insure'
665        };
666        #
667        foreach $target ( keys %$targettypes ) {
668          print binGNUmakefile <<ENDTEXT;
669
670 # Type $target specifics
671 ifdef MAKETARGET_$target
672 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
673 endif
674 $target ::$$hashref{name}_$$targettypes{$target}
675
676 bintargets+=$$hashref{name}_$$targettypes{$target}
677 help::
678 \t\@echo $$hashref{name}_$$targettypes{$target}
679 clean::
680 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
681 \techo Removing \$(binarystore)/$$hashref{name}; \\
682 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
683 \tfi
684
685 ENDTEXT
686          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
687          ${"objectname_$$targettypes{$target}"}=$objectname;
688          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
689        } # end loop
690
691        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
692        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
693        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
694        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
695        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
696        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
697        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
698        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
699        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
700        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
701        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
702        print binGNUmakefile "\t\$(CClinkCmd)\n";
703        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
704        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
705        print binGNUmakefile "-include $$hashref{name}.dep\n";
706 print binGNUmakefile <<ENDTEXT;
707 clean::
708 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
709 \techo Removing \$(binarystore)/$$hashref{name}; \\
710 \trm \$(binarystore)/$$hashref{name}; \\
711 \tfi
712
713 $$hashref{name}_d.exe:\$(libslocal_d)
714 $$hashref{name}_o.exe:\$(libslocal)
715 ifdef MCCABE_DATA_DIR
716 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
717 endif
718 $$hashref{name}_Insure.exe:\$(libslocal_I)
719 $$hashref{name}_d:$$hashref{name}_d.exe
720        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
721 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
722        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
723 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
724        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
725 $$hashref{name}:$$hashref{name}_d.exe
726        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
727 $$hashref{name}_o:$$hashref{name}_o.exe
728        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
729 binfiles+=$$hashref{file}
730 ENDTEXT
731        }
732        close binGNUmakefile;
733 }
734
735 sub External_StartTag {
736        my $self=shift;
737        my $name=shift;
738        my $hashref=shift;
739        
740        my $tool;
741        if ( $self->{Arch} ) {
742        $self->{switch}->checktag($name,$hashref,'ref');
743
744        # -- oo toolbox stuff
745        # - get the appropriate tool object
746        $$hashref{'ref'}=~tr[A-Z][a-z];
747        if ( ! exists $$hashref{'version'} ) {
748         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
749        }
750        else {
751         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
752        }
753        if ( ! defined $tool ) {
754          $self->{switch}->parseerror("Unknown Tool Specified ("
755                                                        .$$hashref{'ref'}.")");
756        }
757
758        # -- old fashioned GNUmakefile stuff
759        print GNUmakefile $$hashref{'ref'};
760        if ( defined $$hashref{'version'} ) {
761                print GNUmakefile "_V_".$$hashref{'version'};
762        }
763        print GNUmakefile "=true\n";
764        
765        # -- Sub system also specified?
766        if ( exists $$hashref{'use'} ) {
767           # -- look for a buildfile
768           my @paths=$tool->getfeature("INCLUDE");
769           my $file="";
770           my ($path,$testfile);
771           foreach $path ( @paths ) {
772             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
773             if ( -f $testfile ) {
774                $file=$testfile;
775                $self->_pushremoteproject($path);
776             }
777           }
778           if ( $file eq "" ) {
779             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
780           }
781           $self->ParseBuildFile_Export($file);
782           $self->_popremoteproject();
334           }
335 <        }
336 < }      
337 <
338 < sub Group_start {
339 <        my $self=shift;
340 <        my $name=shift;
341 <        my $hashref=shift;
342 <        
343 <        $self->{switch}->checktag($name, $hashref, 'name');
344 <        if ( $self->{Arch} ) {
345 <        print GNUmakefile "GROUP_".$$hashref{'name'};
346 <        if ( defined $$hashref{'version'} ) {
347 <                print GNUmakefile "_V_".$$hashref{'version'};
348 <        }
349 <        print GNUmakefile "=true\n";
350 <        }
351 < }      
352 <
353 < sub Use_start {
354 <        my $self=shift;
355 <        my $name=shift;
356 <        my $hashref=shift;
357 <        my $filename;
358 <        use Utilities::SCRAMUtils;
359 <        
360 <        $self->{switch}->checktag($name, $hashref, "name");
361 <        if ( $self->{Arch} ) {
362 <        if ( exists $$hashref{'group'} ) {
363 <          print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
364 <        }
365 <        if ( ! defined $self->{remoteproject} ) {
366 <          $filename=SCRAMUtils::checkfile(
367 <                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
368 <          # -- force a dependency check if local
369 <          if ( $filename=~/^$self->{localtop}/ ) {
370 <            $self->{Builder}->BuildDir($ENV{INTsrc}."/".$$hashref{'name'});
371 <          }
372 <        }
373 <        else {
374 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
375 <        print "trying $filename\n";
376 <          if ( ! -f $filename ) { $filename=""; };
377 <        }
378 <        if ( $filename ne "" ) {
379 <          $self->ParseBuildFile_Export( $filename );
380 <        }
381 <        else {
382 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
383 <                "decription file for <$name name=".$$hashref{name}.">");
384 <        }
385 <        }
386 < }
387 <
388 < # List association groups between <AssociateGroup> tags
389 < # seperated by newlines or spaces
390 < sub AssociateGroup {
391 <        my $self=shift;
392 <        my $name=shift;
393 <        my $string=shift;
394 <        my $word;
395 <
396 <        if ( $self->{Arch} ) {
397 <        foreach $word ( (split /\s/, $string) ){
398 <                chomp $word;
399 <                next if /^#/;
400 <                if ( $word=~/none/ ) {
401 <                        $self->{ignore}=1;
402 <                }
403 <        }
404 <        }
405 < }
406 <
407 < sub Arch_Start {
408 <        my $self=shift;
409 <        my $name=shift;
410 <        my $hashref=shift;
411 <
412 <        $self->{switch}->checktag($name, $hashref,'name');
413 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
414 <                                                : ($self->{Arch}=0);
415 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
416 < }
417 <
418 < sub Arch_End {
419 <        my $self=shift;
420 <        my $name=shift;
421 <
422 <        pop @{$self->{ARCHBLOCK}};
423 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
424 < }
425 <
426 < # Split up the Class Block String into a useable array
427 < sub _CutBlock {
428 <    my $self=shift;
429 <    my $string= shift @_;
430 <    @BlockClassA = split /\//, $string;
431 < }
432 <
433 < sub OutToMakefile {
434 <        my $self=shift;
435 <        my $name=shift;
436 <        my @vars=@_;
437 <
438 <        if ( $self->{Arch} ) {
439 <          print GNUmakefile @vars;
440 <        }
441 < }
442 <
443 < sub OutToScreen {
444 <        my $name=shift;
445 <        my @vars=@_;
446 <
447 <        if ( $self->{Arch} ) {
448 <          print @vars;
449 <        }
450 < }
451 < sub setBlockClassPath {
452 <        my $self=shift;
453 <        my $name=shift;
454 <        my $hashref=shift;
455 <
456 <        $self->{switch}->checktag($name, $hashref, 'path');
457 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
458 <        $self->_CutBlock($$hashref{path});
459 < }
460 <
461 < sub BlockClassPath {
462 <        my $self=shift;
463 <        return $self->{BlockClassPath};
464 < }
465 <
466 < sub export_start_export {
467 <        my $self=shift;
468 <        my $name=shift;
469 <        my $hashref=shift;
470 <
471 <        $self->{switch}->opengroup("__export");
472 < }
473 <
474 < sub export_start {
475 <        my $self=shift;
476 <        my $name=shift;
477 <        my $hashref=shift;
478 <
479 <        $self->{switch}->opengroup("__export");
480 <        if ( exists $$hashref{autoexport} ) {
481 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
482 <          if ( $$hashref{autoexport}=~/true/ ) {
483 <           $self->{switch}->allowgroup("__export","makebuild");
484 <          }
485 <          else {
486 <           $self->{switch}->disallowgroup("__export","makebuild");
487 <          }
488 <        }
489 <        # -- allow default setting from other makefiles
490 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
491 < }
492 <
493 < sub export_end_export {
494 <        my $self=shift;
495 <        $self->{switch}->closegroup("__export");
496 < }
497 <
498 < sub export_end {
499 <        my $self=shift;
500 <        $self->{switch}->closegroup("__export");
501 <        print GNUmakefile "endif\n";
502 < }
503 <
504 < #
505 < # Standard lib tag
506 < #
507 < sub lib_start {
508 <        my $self=shift;
509 <        my $name=shift;
510 <        my $hashref=shift;
511 <
512 <        $self->{switch}->checktag($name, $hashref, 'name');
513 <        if ( $self->{Arch} ) {
514 <           print GNUmakefile "lib+=$$hashref{name}\n";
515 <        }
516 < }
517 <
518 < #
519 < # libtype specification
520 < #
521 < sub LibType_Start {
522 <        my $self=shift;
523 <        my $name=shift;
524 <        my $hashref=shift;
525 <
526 <        if ( $self->{Arch} ) {
527 <        if ( defined $self->{libtype_conext} ) {
528 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
529 <                " without a </$name> tag to close previous context");
530 <        }
531 <        else {
532 <        $self->{libtype_conext}=1;
533 <        $self->{switch}->checktag($name, $hashref, 'type');
534 <        
535 <        print GNUmakefile "# Specify Library Type\n";
536 <        print GNUmakefile "DefaultLibsOff=yes\n";
537 <        if ( $$hashref{'type'}=~/^archive/i ) {
538 <          print GNUmakefile "LibArchive=true\n";
539 <        }
540 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
541 <          print GNUmakefile "LibDebugArchive=true\n";
542 <        }
543 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
544 <          print GNUmakefile "LibDebugShared=true\n";
545 <        }
546 <        elsif ($$hashref{'type'}=~/shared/i ) {
547 <          print GNUmakefile 'LibShared=true'."\n";
548 <        }
549 <        print GNUmakefile "\n";
550 <        }
551 <        }
552 < }
553 <
554 < sub LibType_text {
555 <        my $self=shift;
556 <        my $name=shift;
557 <        my $string=shift;
558 <
559 <        if ( $self->{Arch} ) {
560 <          $string=~s/\n/ /g;
561 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
562 <          print GNUmakefile $string;
563 <          print GNUmakefile "\n";
564 <        }
565 < }
566 <
567 < sub LibType_end {
568 <        my $self=shift;
569 <        my $name=shift;
570 <
571 <        undef $self->{libtype_conext};
572 < }
573 <
574 < sub Environment_start {
575 <        my $self=shift;
576 <        my $name=shift;
577 <        my $hashref=shift;
578 <
579 <        if ( $self->{Arch} ) {
580 <          $self->{envnum}++;
581 <
582 <          # open a new Environment File
583 <          my $envfile=$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
584 <                $self->{envnum}.".mk";
585 <          use FileHandle;
586 <          my $fh=FileHandle->new();
587 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
588 <          push @{$self->{filehandlestack}}, $fh;
589 <          *GNUmakefile=$fh;
590 <
591 <          # include the approprate environment file
592 <          if ( $self->{envlevel} == 0 ) {
593 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
594 <                $self->{path}."/BuildFile.mk\n";
595 <          }
596 <          else {
597 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
598 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
599 <          }
600 <          $self->{envlevel}++;
601 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
602 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
603 <        }
604 < }
605 <
606 < sub Environment_end {
607 <        my $self=shift;
608 <        my $fd;
609 <
610 <        if ( $self->{Arch} ) {
611 <          $self->{envlevel}--;
612 <          if ( $self->{envlevel} < 0 ) {
613 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
614 <            exit 1;
615 <          }
616 <          close GNUmakefile;
617 <          # restore the last filehandle
618 <          $fd=pop @{$self->{filehandlestack}};
619 <          close $fd;
620 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
621 <          if ( $self->{envlevel} < 1 ) {
622 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
623 <                        "BuildFile.mk";
624 <          }
625 <          else {
626 <            $self->{currentenv}=
627 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
628 <                $self->{Envlevels}[$self->{envlevel}];
629 <          }
630 <        }
631 < }
632 <
633 < sub Store_start {
634 <        my $self=shift;
635 <        my $name=shift;
636 <        my $hashref=shift;
637 <
638 <        if ( $self->{Arch} ) {
639 <          $self->{switch}->checktag( $name, $hashref, 'name' );
640 <
641 <          # -- store creation
642 <          my $dir=$$hashref{'name'};
643 <          AddDir::adddir($self->{localtop}."/".$dir);
644 <          if ( exists $$hashref{'type'} ) {
645 <            # -- architecture specific store
646 <            if ( $$hashref{'type'}=~/^arch/i ) {
647 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
648 <                AddDir::adddir($self->{localtop}."/".$dir);
649 <            }
650 <            else {
651 <                $self->parseerror("Unknown type in <$name> tag");
652 <            }
653 <          }
654 <
655 <          # -- set make variables for the store
656 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
657 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
658 <                                        $self->{localtop}."/".$dir."\n";
659 <          print GNUmakefile "VPATH+=".$self->{localtop}
660 <                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
1110 <        }
1111 < }
335 >      }
336 >   return "";
337 >   }
338 >
339 > sub bin()
340 >   {
341 >   my ($object,$name,%attributes) = @_;
342 >   $self->pushlevel(\%attributes);# Set nested to 1;
343 >   }
344 >
345 > sub bin_()
346 >   {
347 >   # Need unique name for the binary (always use name of product). Either use "name"
348 >   # given, or use "file" value minus the ending:
349 >   if (exists ($self->{id}->{'name'}))
350 >      {
351 >      $name = $self->{id}->{'name'};
352 >      }
353 >   else
354 >      {
355 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
356 >      }
357 >
358 >   # Store the data:
359 >   $self->productcollector($name,'bin','BIN');
360 >   $self->poplevel();
361 >   }
362 >
363 > sub module()
364 >   {
365 >   my ($object,$name,%attributes) = @_;
366 >   $self->pushlevel(\%attributes);# Set nested to 1;
367 >   }
368 >
369 > sub module_()
370 >   {
371 >   # Need unique name for the module (always use name of product). Either use "name"
372 >   # given, or use "file" value minus the ending:
373 >   if (exists ($self->{id}->{'name'}))
374 >      {
375 >      $name = $self->{id}->{'name'};
376 >      }
377 >   else
378 >      {
379 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
380 >      }
381 >
382 >   # Store the data:
383 >   $self->productcollector($name,'mod','MODULE');
384 >   $self->poplevel();
385 >   }
386 >
387 > sub application()
388 >   {
389 >   my ($object,$name,%attributes) = @_;
390 >   $self->pushlevel(\%attributes);# Set nested to 1;
391 >   }
392 >
393 > sub application_()
394 >   {
395 >   # Need unique name for the application (always use name of product). Either use "name"
396 >   # given, or use "file" value minus the ending:
397 >   if (exists ($self->{id}->{'name'}))
398 >      {
399 >      $name = $self->{id}->{'name'};
400 >      }
401 >   else
402 >      {
403 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
404 >      }
405 >
406 >   # Store the data:
407 >   $self->productcollector($name,'app','APPLICATION');
408 >   $self->poplevel();
409 >   }
410 >
411 > sub library()
412 >   {
413 >   my ($object,$name,%attributes) = @_;
414 >   $self->pushlevel(\%attributes);# Set nested to 1;
415 >   }
416 >
417 > sub library_()
418 >   {
419 >   # Need unique name for the library (always use name of product). Either use "name"
420 >   # given, or use "file" value minus the ending:
421 >   if (exists ($self->{id}->{'name'}))
422 >      {
423 >      $name = $self->{id}->{'name'};
424 >      }
425 >   else
426 >      {
427 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
428 >      }
429 >
430 >   # Store the data:
431 >   $self->productcollector($name,'lib','LIBRARY');
432 >   $self->poplevel();
433 >   }
434 >
435 > sub plugin()
436 >   {
437 >   my ($object,$name,%attributes) = @_;
438 >   $self->pushlevel(\%attributes);# Set nested to 1;
439 >   }
440 >
441 > sub plugin_()
442 >   {
443 >   # Need unique name for the plugin (always use name of product). Either use "name"
444 >   # given, or use "file" value minus the ending:
445 >   if (exists ($self->{id}->{'name'}))
446 >      {
447 >      $name = $self->{id}->{'name'};
448 >      }
449 >   else
450 >      {
451 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
452 >      }
453 >
454 >   # Store the data:
455 >   $self->productcollector($name,'plugin','PLUGIN');
456 >   $self->poplevel();
457 >   }
458 >
459 > sub unittest()
460 >   {
461 >   my ($object,$name,%attributes) = @_;
462 >   $self->pushlevel(\%attributes);# Set nested to 1;
463 >   }
464 >
465 > sub unittest_()
466 >   {
467 >   # Need unique name for the unittest (always use name of product). Either use "name"
468 >   # given, or use "file" value minus the ending:
469 >   if (exists ($self->{id}->{'name'}))
470 >      {
471 >      $name = $self->{id}->{'name'};
472 >      }
473 >   else
474 >      {
475 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
476 >      }
477 >
478 >   # Store the data:
479 >   $self->productcollector($name,'unittest','unittest');
480 >   $self->poplevel();
481 >   }
482 >
483 > sub productcollector()
484 >   {
485 >   my $self=shift;
486 >   my ($name,$typeshort,$typefull)=@_;
487 >   # Create a new Product object for storage of data:
488 >   use BuildSystem::Product;
489 >   my $product = BuildSystem::Product->new();
490 >   # Store the name:
491 >   $product->name($name);
492 >   $product->type($typeshort);
493 >   # Store the files. Take the BuildFile path as the initial path for
494 >   # expanding source file globs:
495 >   $product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]);
496 >   # Store the data content:
497 >   $product->_data($self->{tagcontent});
498 >   # And store in a hash (all build products in same place):
499 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
500 >   }
501 >
502 > sub pushlevel
503 >   {
504 >   my $self = shift;
505 >   my ($info)=@_;
506 >  
507 >   $self->{id} = $info if (defined $info);
508 >   $self->{nested} = 1;
509 >   $self->{tagcontent}={};
510 >   }
511 >
512 > sub poplevel
513 >   {
514 >   my $self = shift;
515 >   delete $self->{id};
516 >   delete $self->{nested};
517 >   delete $self->{tagcontent};
518 >   }
519 >
520 > sub dependencies()
521 >   {
522 >   my $self=shift;
523 >   # Make a copy of the variable so that
524 >   # we don't have a DEPENDENCIES entry in RAWDATA:
525 >   my %DEPS=%{$self->{DEPENDENCIES}};
526 >   delete $self->{DEPENDENCIES};
527 >   return \%DEPS;
528 >   }
529 >
530 > sub skippeddirs()
531 >   {
532 >   my $self=shift;
533 >   my ($here)=@_;
534 >   my $skipped;
535 >
536 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
537 >      {
538 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
539 >      delete $self->{content}->{SKIPPEDDIRS};
540 >      }
541 >  
542 >   delete $self->{content}->{SKIPPEDDIRS};
543 >   return $skipped;
544 >   }
545 >
546 > sub hasexport()
547 >   {
548 >   my $self=shift;
549 >   # Check to see if there is a valid export block:
550 >   my $nkeys = $self->exporteddatatypes();
551 >   $nkeys > 0 ? return 1 : return 0;
552 >   }
553 >
554 > sub has()
555 >   {
556 >   my $self=shift;
557 >   my ($datatype)=@_;  
558 >   (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
559 >   }
560 >
561 > sub exported()
562 >   {
563 >   my $self=shift;
564 >   # Return a hash. Keys are type of data provided:
565 >   return ($self->{content}->{EXPORT});
566 >   }
567 >
568 > sub exporteddatatypes()
569 >   {
570 >   my $self=shift;
571 >   # Return exported data types:
572 >   return keys %{$self->{content}->{EXPORT}};
573 >   }
574 >
575 > sub defined_group()
576 >   {
577 >   my $self=shift;
578 >
579 >   if (exists($self->{content}->{DEFINED_GROUP}))
580 >      {  
581 >      # Return a list of keys (group names) for defined groups:
582 >      return [ keys %{$self->{content}->{DEFINED_GROUP}} ];
583 >      }
584 >   else
585 >      {
586 >      return 0;
587 >      }
588 >   }
589 >
590 > sub dataforgroup()
591 >   {
592 >   my $self=shift;
593 >   my ($groupname)=@_;
594 >   # Return hash containing data for defined group
595 >   # $groupname or return undef:
596 >   return $self->{content}->{DEFINED_GROUP}->{$groupname};
597 >   }
598 >
599 > sub buildproducts()
600 >   {
601 >   my $self=shift;
602 >   # Returns hash of build products and their data:
603 >   return $self->{content}->{BUILDPRODUCTS};
604 >   }
605 >
606 > sub values()
607 >   {
608 >   my $self=shift;
609 >   my ($type)=@_;
610 >   # Get a list of values from known types
611 >   return $self->{content}->{BUILDPRODUCTS}->{$type};
612 >   }
613 >
614 > sub basic_tags()
615 >   {
616 >   my $self=shift;
617 >   my $datatags=[];
618 >   my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE PLUGIN BUILDPRODUCTS) ];
619 >   my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
620 >   my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
621 >   my @all_skip_tags;
622 >  
623 >   push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
624 >
625 >   foreach my $t (keys %{$self->{content}})
626 >      {
627 >      push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
628 >      }
629 >   return @{$datatags};
630 >   }
631 >
632 > sub clean()
633 >   {
634 >   my $self=shift;
635 >   my (@tags) = @_;
636 >
637 >   # Delete some useless entries:
638 >   delete $self->{makefilecontent};
639 >   delete $self->{simpledoc};
640 >   delete $self->{id};
641 >   delete $self->{tagcontent};
642 >   delete $self->{nested};
643 >
644 >   delete $self->{DEPENDENCIES};
645 >  
646 >   map
647 >      {
648 >      delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
649 >      } @tags;
650 >  
651 >   return $self;
652 >   }
653 >
654 > sub AUTOLOAD()
655 >   {
656 >   my ($xmlparser,$name,%attributes)=@_;
657 >   return if $AUTOLOAD =~ /::DESTROY$/;
658 >   my $name=$AUTOLOAD;
659 >   $name =~ s/.*://;
660 >   }
661  
662 + 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines