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.9 by williamc, Fri Sep 29 10:32:18 2000 UTC vs.
Revision 1.32 by muzaffar, Fri Dec 14 09:03:46 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 < # 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";
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->{localtop}=$self->{area}->location();
28 <        # -- set RELEASTOP
29 <        my $rarea=$self->{area}->linkarea();
30 <        if ( ! defined $rarea ) {
31 <          $self->{releasetop}=$self->{localtop};
32 <        }
33 <        else {
34 <          $self->{releasetop}=$rarea->location();
35 <        }
36 <        $self->{releasetop}=$self->{area}->location();
37 <        $self->{Arch}=1;
38 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
39 <        return $self;
40 < }
41 <
42 < sub buildfile {
43 <        my $self=shift;
44 <        if ( @_ ) {
45 <          $self->{buildfile}=shift;
46 <        }
47 <        return $self->{buildfile};
48 < }
49 <
50 < sub makefile {
51 <        my $self=shift;
52 <        if ( @_ ) {
53 <          $self->{makefile}=shift;
54 <        }
55 <        return $self->{makefile};
56 < }
57 <
58 < sub blockparse {
59 <        my $self=shift;
60 <        $self->{block}=shift;
61 <
62 <        $self->{switch}=$self->_initswitcher();
63 <        $self->_initblockparse($self->{switch});
64 < }
65 <
66 < sub ignore {
67 <        my $self=shift;
68 <        return (defined $self->{ignore})?$self->{ignore}:0;
69 < }
70 <
71 < sub _initswitcher {
72 <        my $self=shift;
73 <        my $switch=ActiveDoc::SimpleDoc->new();
74 <        my $parse="makebuild";
75 <        $switch->newparse($parse);
76 <        $switch->addignoretags($parse);
77 <        $self->_commontags($switch,$parse);
78 <        #$switch->addtag($parse,"Build", \&Build_start, $self);
79 <        $switch->addtag($parse,"none",
80 <                                        \&OutToMakefile,$self,
81 <                                        \&OutToMakefile, $self,
82 <                                        "", $self);
83 <        $switch->addtag($parse,"Bin",
84 <                                        \&Bin_start,$self,
85 <                                        \&OutToScreen, $self,
86 <                                        "", $self);
87 <        $switch->addtag($parse,"ProductStore",
88 <                                        \&Store_start,$self,
89 <                                        "", $self,
90 <                                        "", $self);
91 <        $switch->addtag($parse,"LibType",
92 <                                        \&LibType_Start,$self,
93 <                                        \&LibType_text, $self,
94 <                                        \&LibType_end,$self);
95 <        $switch->addtag($parse,"ConfigurationClass",
96 <                                        \&Class_StartTag,$self,
97 <                                        \&OutToMakefile, $self,
98 <                                        "", $self);
99 <        $switch->addtag($parse,"ClassPath",
100 <                                        \&setBlockClassPath,$self,
101 <                                        \&OutToMakefile, $self,
102 <                                        "", $self);
103 <        $switch->addtag($parse,"AssociateGroup",
104 <                                        "",$self,
105 <                                        \&AssociateGroup,$self,
106 <                                        "", $self);
107 <        $switch->addtag($parse,"Environment",
108 <                                        \&Environment_start,$self,
109 <                                        \&OutToMakefile, $self,
110 <                                        \&Environment_end,$self);
111 <        $switch->addtag($parse,"Export",
112 <                                        \&export_start,$self,
113 <                                        \&OutToMakefile, $self,
114 <                                        \&export_end,$self);
115 <        return $switch;
116 < }
117 <
118 < sub _initblockparse {
119 <        my $self=shift;
120 <        my $switch=shift;
121 <
122 <        my $parse="block";
123 <        $switch->newparse($parse);
124 <        $switch->addignoretags($parse);
125 <        $switch->addtag($parse,"DropDown",
126 <                                        \&DropDown_start,$self,
127 <                                        "", $self,
128 <                                        "", $self);
129 <        $switch->addtag($parse,"Build", \&Build_start, $self);
130 < }
131 <
132 < sub _commontags {
133 <        my $self=shift;
134 <        my $switch=shift;
135 <        my $parse=shift;
136 <
137 <        $switch->grouptag("Export",$parse);
138 <        $switch->addtag($parse,"Use",\&Use_start,$self,
139 <                                               \&OutToMakefile, $self,
140 <                                                "", $self);
141 <        $switch->addtag($parse,"Group",\&Group_start,$self,
142 <                                               \&OutToMakefile, $self,
143 <                                                "", $self);
144 <        $switch->grouptag("Group",$parse);
145 <        $switch->addtag($parse,"External",
146 <                                        \&External_StartTag,$self,
147 <                                        \&OutToMakefile, $self,
148 <                                        "", $self);
149 <        $switch->addtag($parse,"lib",
150 <                                        \&lib_start,$self,
151 <                                        \&OutToMakefile, $self,
152 <                                        "", $self);
153 <        $switch->addtag($parse,"Architecture",
154 <                                        \&Arch_Start,$self,
155 <                                        \&OutToMakefile, $self,
156 <                                        \&Arch_End,$self);
157 <        $switch->addtag($parse,"INCLUDE_PATH",
158 <                                        \&IncludePath_Start,$self,
159 <                                        \&OutToMakefile, $self,
160 <                                        "",$self);
161 <        return $switch;
162 < }
163 <
164 < sub GenerateMakefile {
165 <        my $self=shift;
166 <        my $infile=shift;
167 <        my $outfile=shift;
168 <
169 <        $self->{switch}=$self->_initswitcher();
170 <        $self->{switch}->filetoparse($infile);
171 <
172 <        # open a temporary gnumakefile to store output.
173 <        my $fh=FileHandle->new();
174 <        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
175 <                                                                "$!\n";
176 <        @{$self->{filehandlestack}}=($fh);
177 <
178 <        #  -- make an alias
179 <        *GNUmakefile=$fh;
180 <        if ( -e $ENV{LatestBuildFile} ) {
181 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
182 <        }
183 <        $self->{switch}->parse("makebuild"); # sort out supported tags
184 <        close GNUmakefile;
185 <        return $outfile;
186 < }
187 <
188 < sub ParseBuildFile {
189 <        my $self=shift;
190 <        my $base=shift;
191 <        my $path=shift;
192 <        my $filename=shift @_;
193 <        my $fullfilename;
194 <        if ( $filename!~/^\// ) {
195 <         $fullfilename="$base/$path/$filename";
196 <        }
197 <        else {
198 <         $fullfilename=$filename;
199 <        }
200 <        $self->{path}=$path;
201 <        #print "Processing $fullfilename\n";
202 <        $numbins=0;
203 <        $self->{envnum}=0;
204 <        $self->{envlevel}=0;
205 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
206 <                                                                "BuildFile.mk";
207 <        $self->{currentenv}=$self->{makefile};
208 <        $self->{switch}=$self->_initswitcher();
209 <        $self->{switch}->filetoparse($fullfilename);
210 <
211 < #       $self->{switch}->{Strict_no_cr}='no';
212 <        #open a temporary gnumakefile to store output.
213 <        use Utilities::AddDir;
214 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
215 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
216 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
217 < }
218 <
219 < sub classname {
220 <        my $self=shift;
221 <        if ( @_ ) {
222 <          $self->{classname}=shift;
223 <        }
224 <        return $self->{classname};
225 < }
226 <
227 < sub ParseBuildFile_Export {
228 <        my $self=shift;
229 <        my $filename=shift;
230 <        my $bf=BuildSystem::BuildFile->new($self->{area});
231 <        if ( defined $self->{remoteproject} ) {
232 <           $bf->{remoteproject}=$self->{remoteproject};
233 <        }
234 <        $bf->_parseexport($filename);
235 <        undef $bf;
236 < }
237 <
238 < sub _location {
239 <        my $self=shift;
240 <        use File::Basename;
241 <
242 <        return dirname($self->{switch}->filetoparse());
243 < }
244 <
245 < sub _parseexport {
246 <        my $self=shift;
247 <        my $filename=shift;
248 <
249 <        my $switchex=ActiveDoc::SimpleDoc->new();
250 <        $switchex->filetoparse($filename);
251 <        $switchex->newparse("export");
252 <        $switchex->addignoretags("export");
253 <        $switchex->addtag("export","Export",
254 <                                        \&export_start_export,$self,
255 <                                        \&OutToMakefile, $self,
256 <                                        \&export_end_export,$self);
257 <        $self->_commontags($switchex,"export");
258 <        $switchex->allowgroup("__export","export");
259 < #       $switchex->{Strict_no_cr}='no';
260 <        $self->{switch}=$switchex;
261 <        $switchex->parse("export"); # sort out supported tags
262 < }
263 <
264 < sub _pushremoteproject {
265 <        my $self=shift;
266 <        my $path=shift;
267 <        
268 <        if ( defined $self->{remoteproject} ) {
269 <          push @{$self->{rpstack}}, $self->{remoteproject};
270 <        }
271 <        $self->{remoteproject}=$path;
272 < }
273 <
274 < sub _popremoteproject {
275 <        my $self=shift;
276 <        if ( $#{$self->{rpstack}} >=0 ) {
277 <          $self->{remoteproject}=pop @{$self->{rpstack}};
278 <        }
279 <        else {
280 <          undef $self->{remoteproject};
281 <        }
282 < }
283 <
284 < sub _toolmapper {
285 <        my $self=shift;
286 <        if ( ! defined $self->{mapper} ) {
287 <           require BuildSystem::ToolMapper;
288 <           $self->{mapper}=BuildSystem::ToolMapper->new();
289 <        }
290 <        return $self->{mapper};
291 < }
292 <
293 <
294 < # ---- Tag routines
295 <
296 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
297 < #   the type tag will pick up a pre-defined class type from project space.
298 <
299 < sub Class_StartTag {
300 <        my $self=shift;
301 <        my $name=shift;
302 <        my $hashref=shift;
303 <        
304 <        if ( $self->{Arch} ) {
305 <         if ( defined $$hashref{'type'} ) {
306 <                $self->classname($$hashref{'type'});
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 < sub IncludePath_Start {
315 <        my $self=shift;
316 <        my $name=shift;
317 <        my $hashref=shift;
318 <
319 <        $self->{switch}->checktag( $name, $hashref, 'path');
320 <        if ( $self->{Arch} ) {
321 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
322 <                                                $$hashref{'path'}."\n";
323 <        }
324 < }
311 >      }
312 >   }
313  
314 < #
315 < # generic build tag
316 < #
317 < sub Build_start {
318 <        my $self=shift;
319 <        my $name=shift;
320 <        my $hashref=shift;
321 <
322 <        $self->{switch}->checktag($name,$hashref,'class');
323 <        $self->{switch}->checktag($name,$hashref,'id');
324 <        if ( $self->{Arch} ) {
325 <
326 <          # -- determine the build products name
327 <          my $name;
328 <          if ( exists $$hashref{'name'} ) {
329 <            $name=$$hashref{'name'};
330 <          }
331 <          else {
332 <            $self->{switch}->parseerror("No name specified for build product");
345 <            #$name="\$(buildname)";
346 <          }
347 <
348 <          # -- check we have a lookup for the class type
349 <          my $mapper=$self->_toolmapper();
350 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
351 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
352 <          }
353 <          else {
354 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
355 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
356 <
357 <           my $fh=$self->{filehandlestack}[0];
358 <           my @targets=();
359 <
360 <           # -- generate generic targets
361 <           print $fh "ifndef _BuildLink_\n";
362 <           print $fh "# -- Generic targets\n";
363 <           push @targets, $$hashref{'class'};
364 <           foreach $dtype ( @deftypes ) {
365 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
366 <                                                                $dtype."\n";
367 <           }
368 <           print $fh "\n";
369 <
370 <           # -- generate targets for each type
371 <           foreach $type ( @types ) {
372 <
373 <            # -- generic name for each type
374 <            my $pattern=$$hashref{'class'}."_".$type;
375 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
376 <            print $fh "# ------ $pattern rules ---------------\n";
377 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
378 <                                                        "_".$type."_$name\n\n";
379 <
380 <            # -- create a new directory for each type
381 <            push @targets, $pattern;
382 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
383 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
384 <            my $makefile=$here."/BuildFile.mk";
385 < #           AddDir::adddir($here);
386 <
387 <            # -- create link targets to the directory
388 <            push @targets, $dirname;
389 <            print $fh "# -- Link Targets to $type directories\n";
390 <            print $fh "$dirname: make_$dirname\n";
391 <            print $fh "\t\@cd $here; \\\n";
392 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
393 <                        " workdir=$here ".
394 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
395 <
396 <            # -- write target to make makefile for each directory
397 <            print $fh "# -- Build target directories\n";
398 <            print $fh "make_$dirname:\n";
399 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
400 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
401 <            print $fh "\t  mkdir $here; \\\n";
402 <            print $fh "\t fi;\\\n";
403 <            print $fh "\t cd $dirname; \\\n";
404 <            print $fh "\t echo include ".$self->{currentenv}." > ".
405 <                                                        "$makefile; \\\n";
406 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
407 <                                        " >> $makefile; \\\n";
408 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
409 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
410 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
411 <             foreach $f ( @file ) {
412 <              print $fh "\t echo -include $f >> $makefile; \\\n";
413 <             }
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              }
415            print $fh "\tfi\n";
416            print $fh "\n";
417 #           print $typefile "$name :\n";
418 #           print $typefile "\t\$(_quietbuild_)";
419 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
420 #           print $typefile "\t\$(_quietstamp_)";
421 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
422
423            # -- cleaning targets
424            push @targets, "clean_$dirname";
425            print $fh "# -- cleaning targets\n";
426            print $fh "clean::clean_$dirname\n";
427            print $fh "clean_".$dirname."::\n";
428            print $fh "\t\@echo cleaning $dirname\n";
429            print $fh "\t\@if [ -d $here ]; then \\\n";
430            print $fh "\tcd $here; \\\n";
431            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
432                        $here." _BuildLink_=1 -f ".
433                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
434            print $fh "\tfi\n\n";
435
436
437          }
438          # -- help targets
439          print $fh "helpheader::\n";
440          print $fh "\t\@echo Targets available:\n";
441          print $fh "\t\@echo ------------------\n\n";
442          print $fh "help::helpheader\n";
443          foreach $target ( @targets ) {
444            print $fh "help::\n";
445            print $fh "\t\@echo $target\n"
446          }
447          print $fh "endif\n";
448         } # end else
449        }
450 }
451
452 sub Bin_start {
453        my $self=shift;
454        my $name=shift;
455        my $hashref=shift;
456
457        my $fileclass;
458        my @tools;
459        my $tool;
460        my $filename;
461        my $objectname;
462        
463        $self->{switch}->checktag($name,$hashref,'file');
464        if ( $self->{Arch} ) {
465        if ( ! defined $$hashref{name} ) {
466                ($$hashref{name}=$$hashref{file})=~s/\..*//;
467        }
468        ($filename=$$hashref{file})=~s/\..*//;
469
470        # Create a new directory for each binary target
471        my $dirname="bin_".$$hashref{name};
472        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
473        open (binGNUmakefile,
474           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
475           "BuildFile.mk $!\n";
476
477        # Create the link targets
478        $numbins++;
479        my $fh=$self->{filehandlestack}[0];
480        print $fh <<ENDTEXT;
481
482 # Link Targets to binary directories
483 ifdef BINMODE
484 # We dont want to build a library here
485 override files:=
486 endif
487 ifndef BINMODE
488
489 define stepdown_$$hashref{'name'}
490 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
491 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
492 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
493 fi
494 endef
495
496 define stepdown2_$$hashref{'name'}
497 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
498 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
499 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
500 fi
501
502 endef
503
504 bin_$$hashref{'name'}_%:: dummy
505        \@\$(stepdown2_$$hashref{'name'})
506
507 $$hashref{'name'}_%:: dummy
508        \@\$(stepdown_$$hashref{'name'})
509
510 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
511        \@\$(stepdown_$$hashref{'name'})
512
513 binfiles+=$$hashref{'file'}
514 locbinfiles+=$dirname/$$hashref{'file'}
515 endif
516
517
518 ENDTEXT
519
520
521 # the binary specifics makefile
522        print binGNUmakefile "include ".$self->{currentenv}."\n";
523        print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n";
524
525 # alias for bin_Insure
526        print binGNUmakefile <<ENDTEXT;
527
528 bin_insure:bin_Insure
529 ifdef MAKETARGET_bin_insure
530 MAKETARGET_$$hashref{name}_Insure=1
531 endif
532
533 # debuggging target
534 $$hashref{'name'}_echo_% :: echo_%
535
536 # help targets
537 help::
538 \t\@echo Targets For $$hashref{'name'}
539 \t\@echo -------------------------------------
540 \t\@echo $$hashref{'name'}  - default build
541 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
542 ENDTEXT
543
544 # Make generic rules for each type
545        $targettypes={
546                "bin" => 'o',
547                "bin_debug" => 'd',
548                "bin_debug_local" => 'l_d',
549                "bin_Insure" => 'Insure'
550        };
551        #
552        foreach $target ( keys %$targettypes ) {
553          print binGNUmakefile <<ENDTEXT;
554
555 # Type $target specifics
556 ifdef MAKETARGET_$target
557 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
558 endif
559 $target ::$$hashref{name}_$$targettypes{$target}
560
561 bintargets+=$$hashref{name}_$$targettypes{$target}
562 help::
563 \t\@echo $$hashref{name}_$$targettypes{$target}
564 clean::
565 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
566 \techo Removing \$(binarystore)/$$hashref{name}; \\
567 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
568 \tfi
569
570 ENDTEXT
571          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
572          ${"objectname_$$targettypes{$target}"}=$objectname;
573          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
574        } # end loop
575
576        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
577        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
578        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
579        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
580        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
581        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
582        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
583        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
584        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
585        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
586        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
587        print binGNUmakefile "\t\$(CClinkCmd)\n";
588        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
589        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
590        print binGNUmakefile "-include $$hashref{name}.dep\n";
591 print binGNUmakefile <<ENDTEXT;
592 clean::
593 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
594 \techo Removing \$(binarystore)/$$hashref{name}; \\
595 \trm \$(binarystore)/$$hashref{name}; \\
596 \tfi
597
598 $$hashref{name}_d.exe:\$(libslocal_d)
599 $$hashref{name}_o.exe:\$(libslocal)
600 ifdef MCCABE_DATA_DIR
601 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
602 endif
603 $$hashref{name}_Insure.exe:\$(libslocal_I)
604 $$hashref{name}_d:$$hashref{name}_d.exe
605        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
606 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
607        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
608 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
609        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
610 $$hashref{name}:$$hashref{name}_d.exe
611        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
612 $$hashref{name}_o:$$hashref{name}_o.exe
613        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
614 binfiles+=$$hashref{file}
615 ENDTEXT
616        }
617        close binGNUmakefile;
618 }
619
620 sub External_StartTag {
621        my $self=shift;
622        my $name=shift;
623        my $hashref=shift;
624        
625        my $tool;
626        if ( $self->{Arch} ) {
627        $self->{switch}->checktag($name,$hashref,'ref');
628
629        # -- oo toolbox stuff
630        # - get the appropriate tool object
631        $$hashref{'ref'}=~tr[A-Z][a-z];
632        if ( ! exists $$hashref{'version'} ) {
633         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
634        }
635        else {
636         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
637        }
638        if ( ! defined $tool ) {
639          $self->{switch}->parseerror("Unknown Tool Specified ("
640                                                        .$$hashref{'ref'}.")");
641        }
642
643        # -- old fashioned GNUmakefile stuff
644        print GNUmakefile $$hashref{'ref'};
645        if ( defined $$hashref{'version'} ) {
646                print GNUmakefile "_V_".$$hashref{'version'};
647        }
648        print GNUmakefile "=true\n";
649        
650        # -- Sub system also specified?
651        if ( exists $$hashref{'use'} ) {
652           # -- look for a buildfile
653           my @paths=$tool->getfeature("INCLUDE");
654           my $file="";
655           my ($path,$testfile);
656           foreach $path ( @paths ) {
657             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
658             if ( -f $testfile ) {
659                $file=$testfile;
660                $self->_pushremoteproject($path);
661             }
662           }
663           if ( $file eq "" ) {
664             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
665           }
666           $self->ParseBuildFile_Export($file);
667           $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 <        }
369 <        else {
370 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
371 <        print "trying $filename\n";
372 <          if ( ! -f $filename ) { $filename=""; };
373 <        }
374 <        if ( $filename ne "" ) {
375 <          $self->ParseBuildFile_Export( $filename );
376 <        }
377 <        else {
378 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
379 <                "decription file for <$name name=".$$hashref{name}.">");
380 <        }
381 <        }
382 < }
383 <
384 < # List association groups between <AssociateGroup> tags
385 < # seperated by newlines or spaces
386 < sub AssociateGroup {
387 <        my $self=shift;
388 <        my $name=shift;
389 <        my $string=shift;
390 <        my $word;
391 <
392 <        if ( $self->{Arch} ) {
393 <        foreach $word ( (split /\s/, $string) ){
394 <                chomp $word;
395 <                next if /^#/;
396 <                if ( $word=~/none/ ) {
397 <                        $self->{ignore}=1;
398 <                }
399 <        }
400 <        }
401 < }
402 <
403 < sub Arch_Start {
404 <        my $self=shift;
405 <        my $name=shift;
406 <        my $hashref=shift;
407 <
408 <        $self->{switch}->checktag($name, $hashref,'name');
409 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
410 <                                                : ($self->{Arch}=0);
411 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
412 < }
413 <
414 < sub Arch_End {
415 <        my $self=shift;
416 <        my $name=shift;
417 <
418 <        pop @{$self->{ARCHBLOCK}};
419 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
420 < }
421 <
422 < # Split up the Class Block String into a useable array
423 < sub _CutBlock {
424 <    my $self=shift;
425 <    my $string= shift @_;
426 <    @BlockClassA = split /\//, $string;
427 < }
428 <
429 < sub OutToMakefile {
430 <        my $self=shift;
431 <        my $name=shift;
432 <        my @vars=@_;
433 <
434 <        if ( $self->{Arch} ) {
435 <          print GNUmakefile @vars;
436 <        }
437 < }
438 <
439 < sub OutToScreen {
440 <        my $name=shift;
441 <        my @vars=@_;
442 <
443 <        if ( $self->{Arch} ) {
444 <          print @vars;
445 <        }
446 < }
447 < sub setBlockClassPath {
448 <        my $self=shift;
449 <        my $name=shift;
450 <        my $hashref=shift;
451 <
452 <        $self->{switch}->checktag($name, $hashref, 'path');
453 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
454 <        $self->_CutBlock($$hashref{path});
455 < }
456 <
457 < sub BlockClassPath {
458 <        my $self=shift;
459 <        return $self->{BlockClassPath};
460 < }
461 <
462 < sub export_start_export {
463 <        my $self=shift;
464 <        my $name=shift;
465 <        my $hashref=shift;
466 <
467 <        $self->{switch}->opengroup("__export");
468 < }
469 <
470 < sub export_start {
471 <        my $self=shift;
472 <        my $name=shift;
473 <        my $hashref=shift;
474 <
475 <        $self->{switch}->opengroup("__export");
476 <        if ( exists $$hashref{autoexport} ) {
477 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
478 <          if ( $$hashref{autoexport}=~/true/ ) {
479 <           $self->{switch}->allowgroup("__export","makebuild");
480 <          }
481 <          else {
482 <           $self->{switch}->disallowgroup("__export","makebuild");
483 <          }
484 <        }
485 <        # -- allow default setting from other makefiles
486 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
487 < }
488 <
489 < sub export_end_export {
490 <        my $self=shift;
491 <        $self->{switch}->closegroup("__export");
492 < }
493 <
494 < sub export_end {
495 <        my $self=shift;
496 <        $self->{switch}->closegroup("__export");
497 <        print GNUmakefile "endif\n";
498 < }
499 <
500 < #
501 < # Standard lib tag
502 < #
503 < sub lib_start {
504 <        my $self=shift;
505 <        my $name=shift;
506 <        my $hashref=shift;
507 <
508 <        $self->{switch}->checktag($name, $hashref, 'name');
509 <        if ( $self->{Arch} ) {
510 <           print GNUmakefile "lib+=$$hashref{name}\n";
511 <        }
512 < }
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 < #
849 < # libtype specification
850 < #
851 < sub LibType_Start {
852 <        my $self=shift;
853 <        my $name=shift;
854 <        my $hashref=shift;
855 <
856 <        if ( $self->{Arch} ) {
857 <        if ( defined $self->{libtype_conext} ) {
858 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
859 <                " without a </$name> tag to close previous context");
860 <        }
861 <        else {
862 <        $self->{libtype_conext}=1;
863 <        $self->{switch}->checktag($name, $hashref, 'type');
864 <        
865 <        print GNUmakefile "# Specify Library Type\n";
866 <        print GNUmakefile "DefaultLibsOff=yes\n";
867 <        if ( $$hashref{'type'}=~/^archive/i ) {
868 <          print GNUmakefile "LibArchive=true\n";
869 <        }
870 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
871 <          print GNUmakefile "LibDebugArchive=true\n";
872 <        }
873 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
874 <          print GNUmakefile "LibDebugShared=true\n";
875 <        }
876 <        elsif ($$hashref{'type'}=~/shared/i ) {
877 <          print GNUmakefile 'LibShared=true'."\n";
878 <        }
879 <        print GNUmakefile "\n";
880 <        }
881 <        }
882 < }
883 <
884 < sub LibType_text {
885 <        my $self=shift;
886 <        my $name=shift;
887 <        my $string=shift;
888 <
889 <        if ( $self->{Arch} ) {
890 <          $string=~s/\n/ /g;
891 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
892 <          print GNUmakefile $string;
893 <          print GNUmakefile "\n";
894 <        }
895 < }
896 <
897 < sub LibType_end {
898 <        my $self=shift;
899 <        my $name=shift;
900 <
901 <        undef $self->{libtype_conext};
902 < }
903 <
904 < sub Environment_start {
905 <        my $self=shift;
906 <        my $name=shift;
907 <        my $hashref=shift;
908 <
909 <        if ( $self->{Arch} ) {
910 <          $self->{envnum}++;
911 <
912 <          # open a new Environment File
913 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
914 <                $self->{envnum}.".mk";
915 <          use FileHandle;
916 <          my $fh=FileHandle->new();
917 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
918 <          push @{$self->{filehandlestack}}, $fh;
919 <          *GNUmakefile=$fh;
920 <
921 <          # include the approprate environment file
922 <          if ( $self->{envlevel} == 0 ) {
923 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
924 <                $self->{path}."/BuildFile.mk\n";
925 <          }
926 <          else {
927 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
928 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
929 <          }
930 <          $self->{envlevel}++;
931 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
932 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
933 <        }
934 < }
935 <
936 < sub Environment_end {
937 <        my $self=shift;
938 <        my $fd;
939 <
940 <        if ( $self->{Arch} ) {
941 <          $self->{envlevel}--;
942 <          if ( $self->{envlevel} < 0 ) {
943 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
944 <            exit 1;
945 <          }
946 <          close GNUmakefile;
947 <          # restore the last filehandle
948 <          $fd=pop @{$self->{filehandlestack}};
949 <          close $fd;
950 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
951 <          if ( $self->{envlevel} < 1 ) {
952 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
953 <                        "BuildFile.mk";
954 <          }
955 <          else {
956 <            $self->{currentenv}=
957 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
958 <                $self->{Envlevels}[$self->{envlevel}];
959 <          }
960 <        }
961 < }
962 <
963 < sub Store_start {
964 <        my $self=shift;
965 <        my $name=shift;
966 <        my $hashref=shift;
967 <
968 <        if ( $self->{Arch} ) {
969 <          $self->{switch}->checktag( $name, $hashref, 'name' );
970 <
971 <          # -- store creation
972 <          my $dir=$$hashref{'name'};
973 <          AddDir::adddir($self->{area}->location()."/".$dir);
974 <          if ( exists $$hashref{'type'} ) {
975 <            # -- architecture specific store
976 <            if ( $$hashref{'type'}=~/^arch/i ) {
977 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
978 <                AddDir::adddir($self->{area}->location()."/".$dir);
979 <            }
980 <            else {
981 <                $self->parseerror("Unknown type in <$name> tag");
982 <            }
983 <          }
984 <        
985 <          # -- set make variables for the store
986 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
987 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
988 <                                        $self->{localtop}."/".$dir."\n";
989 <          print GNUmakefile "VPATH+=".$self->{localtop}
990 <                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
991 <        }
992 < }
993 <
994 < sub DropDown {
995 <        my $self=shift;
996 <        my $name=shift;
997 <        my $hashref=shift;
998 <
999 <        if ( $self->{Arch} ) {
1000 <          # - default values must always be specified
1001 <          $self->{switch}->checktag( $name, $hashref, 'defaults' );
1002 <          my @blockdirs=split /,/ , $$hashref{'defaults'};
1003 <          $self->{block}->defaultblocks(@blockdirs);
1004 <        }
1005 < }
662 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines