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.13 by williamc, Wed Nov 15 14:49:22 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(toolbox)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockClassPath() : Return the class path
9 < # ignore()      : return 1 if directory should be ignored 0 otherwise
10 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
12 use ActiveDoc::SimpleDoc;
13 use BuildSystem::ToolBox;
13   require 5.004;
14 + use Exporter;
15 + use ActiveDoc::SimpleDoc;
16  
17 < BEGIN {
18 < $buildfile="BuildFile";
19 < }
20 <
21 < sub new {
22 <        my $class=shift;
23 <        my $self={};
24 <        bless $self, $class;
25 <        $self->{toolbox}=shift;
26 <        $self->{Arch}=1;
27 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
28 <        return $self;
29 < }
30 <
31 < sub ignore {
32 <        my $self=shift;
33 <        return (defined $self->{ignore})?$self->{ignore}:0;
34 < }
35 <
36 < sub _initswitcher {
37 <        my $self=shift;
38 <        my $switch=ActiveDoc::SimpleDoc->new();
39 <        my $parse="makebuild";
40 <        $switch->newparse($parse);
41 <        $switch->addignoretags($parse);
42 <        $self->_commontags($switch,$parse);
43 <        $switch->addtag($parse,"Build", \&Build_start, $self);
44 <        $switch->addtag($parse,"none",
45 <                                        \&OutToMakefile,$self,
46 <                                        \&OutToMakefile, $self,
47 <                                        "", $self);
48 <        $switch->addtag($parse,"Bin",
49 <                                        \&Bin_start,$self,
50 <                                        \&OutToScreen, $self,
51 <                                        "", $self);
52 <         $switch->addtag($parse,"ProductStore",
53 <                                        \&Store_start,$self,
54 <                                        "", $self,
55 <                                        "", $self);
56 <        $switch->addtag($parse,"LibType",
57 <                                        \&LibType_Start,$self,
58 <                                        \&LibType_text, $self,
59 <                                        \&LibType_end,$self);
60 <        $switch->addtag($parse,"ConfigurationClass",
61 <                                        \&Class_StartTag,$self,
62 <                                        \&OutToMakefile, $self,
63 <                                        "", $self);
64 <        $switch->addtag($parse,"ClassPath",
65 <                                        \&setBlockClassPath,$self,
66 <                                        \&OutToMakefile, $self,
67 <                                        "", $self);
68 <        $switch->addtag($parse,"AssociateGroup",
69 <                                        "",$self,
70 <                                        \&AssociateGroup,$self,
71 <                                        "", $self);
72 <        $switch->addtag($parse,"Environment",
73 <                                        \&Environment_start,$self,
74 <                                        \&OutToMakefile, $self,
75 <                                        \&Environment_end,$self);
76 <        $switch->addtag($parse,"Export",
77 <                                        \&export_start,$self,
78 <                                        \&OutToMakefile, $self,
79 <                                        \&export_end,$self);
80 <        return $switch;
81 < }
82 <
83 < sub _commontags {
84 <        my $self=shift;
85 <        my $switch=shift;
86 <        my $parse=shift;
87 <
88 <        $switch->grouptag("Export",$parse);
89 <        $switch->addtag($parse,"Use",\&Use_start,$self,
90 <                                               \&OutToMakefile, $self,
91 <                                                "", $self);
92 <        $switch->addtag($parse,"Group",\&Group_start,$self,
93 <                                               \&OutToMakefile, $self,
94 <                                                "", $self);
95 <        $switch->grouptag("Group",$parse);
96 <        $switch->addtag($parse,"External",
97 <                                        \&External_StartTag,$self,
98 <                                        \&OutToMakefile, $self,
99 <                                        "", $self);
100 <        $switch->addtag($parse,"lib",
101 <                                        \&lib_start,$self,
102 <                                        \&OutToMakefile, $self,
103 <                                        "", $self);
104 <        $switch->addtag($parse,"Architecture",
105 <                                        \&Arch_Start,$self,
106 <                                        \&OutToMakefile, $self,
107 <                                        \&Arch_End,$self);
108 <        $switch->addtag($parse,"INCLUDE_PATH",
109 <                                        \&IncludePath_Start,$self,
110 <                                        \&OutToMakefile, $self,
111 <                                        "",$self);
112 <        return $switch;
113 < }
114 <
115 < sub ParseBuildFile {
116 <        my $self=shift;
117 <        my $base=shift;
118 <        my $path=shift;
119 <        my $filename=shift @_;
120 <        my $fullfilename;
121 <        if ( $filename!~/^\// ) {
122 <         $fullfilename="$base/$path/$filename";
123 <        }
124 <        else {
125 <         $fullfilename=$filename;
126 <        }
127 <        $self->{path}=$path;
128 <        #print "Processing $fullfilename\n";
129 <        $numbins=0;
130 <        $self->{envnum}=0;
131 <        $self->{envlevel}=0;
132 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
133 <                                                                "BuildFile.mk";
134 <        $self->{switch}=$self->_initswitcher();
135 <        $self->{switch}->filetoparse($fullfilename);
136 <
137 < #       $self->{switch}->{Strict_no_cr}='no';
138 <        #open a temporary gnumakefile to store output.
139 <        use Utilities::AddDir;
140 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
141 <        my $fh=FileHandle->new();
142 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
143 <          ) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
144 <        @{$self->{filehandlestack}}=($fh);
145 <        # make an alias
146 <        *GNUmakefile=$fh;
147 <        if ( -e $ENV{LatestBuildFile} ) {
148 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
149 <        }
150 < #       print "writing to :\n".
151 < #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
152 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
153 <        $self->{switch}->parse("makebuild"); # sort out supported tags
154 <        if ( $numbins > 0 ) {
155 <         print GNUmakefile <<ENDTEXT;
156 < ifndef BINMODE
157 < help::
158 < \t\@echo Generic Binary targets
159 < \t\@echo ----------------------
160 < endif
161 < ENDTEXT
162 <         foreach $target ( keys %$targettypes ) {
163 <         print GNUmakefile <<ENDTEXT;
164 < ifndef BINMODE
165 < help::
166 < \t\@echo $target
167 < endif
168 < ENDTEXT
17 > @ISA=qw(Exporter);
18 > @EXPORT_OK=qw( );
19 > #
20 > sub new()
21 >   ###############################################################
22 >   # new                                                         #
23 >   ###############################################################
24 >   # modified : Wed Dec  3 19:03:22 2003 / SFA                   #
25 >   # params   :                                                  #
26 >   #          :                                                  #
27 >   # function :                                                  #
28 >   #          :                                                  #
29 >   ###############################################################
30 >   {
31 >   my $proto=shift;
32 >   my $class=ref($proto) || $proto;
33 >   $self={};
34 >   bless $self,$class;
35 >   $self->{DEPENDENCIES} = {};
36 >   $self->{content} = {};
37 >   $self->{scramdoc}=ActiveDoc::SimpleDoc->new();
38 >   $self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs');
39 >   return $self;
40 >   }
41 >
42 > sub parse()
43 >   {
44 >   my $self=shift;
45 >   my ($filename)=@_;
46 >   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 <        }
308 <        close GNUmakefile;
309 < }
172 <
173 < sub ParseBuildFile_Export {
174 <        my $self=shift;
175 <        my $filename=shift;
176 <        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
177 <        if ( defined $self->{remoteproject} ) {
178 <           $bf->{remoteproject}=$self->{remoteproject};
179 <        }
180 <        $bf->_parseexport($filename);
181 <        undef $bf;
182 < }
183 <
184 < sub _location {
185 <        my $self=shift;
186 <        use File::Basename;
187 <
188 <        return dirname($self->{switch}->filetoparse());
189 < }
190 <
191 < sub _parseexport {
192 <        my $self=shift;
193 <        my $filename=shift;
194 <
195 <        my $switchex=ActiveDoc::SimpleDoc->new();
196 <        $switchex->filetoparse($filename);
197 <        $switchex->newparse("export");
198 <        $switchex->addignoretags("export");
199 <        $switchex->addtag("export","Export",
200 <                                        \&export_start_export,$self,
201 <                                        \&OutToMakefile, $self,
202 <                                        \&export_end_export,$self);
203 <        $self->_commontags($switchex,"export");
204 <        $switchex->allowgroup("__export","export");
205 < #       $switchex->{Strict_no_cr}='no';
206 <        $self->{switch}=$switchex;
207 <        $switchex->parse("export"); # sort out supported tags
208 < }
209 <
210 < sub _pushremoteproject {
211 <        my $self=shift;
212 <        my $path=shift;
213 <        
214 <        if ( defined $self->{remoteproject} ) {
215 <          push @{$self->{rpstack}}, $self->{remoteproject};
216 <        }
217 <        $self->{remoteproject}=$path;
218 < }
219 <
220 < sub _popremoteproject {
221 <        my $self=shift;
222 <        if ( $#{$self->{rpstack}} >=0 ) {
223 <          $self->{remoteproject}=pop @{$self->{rpstack}};
224 <        }
225 <        else {
226 <          undef $self->{remoteproject};
227 <        }
228 < }
229 <
230 < sub _toolmapper {
231 <        my $self=shift;
232 <        if ( ! defined $self->{mapper} ) {
233 <           require BuildSystem::ToolMapper;
234 <           $self->{mapper}=BuildSystem::ToolMapper->new();
235 <        }
236 <        return $self->{mapper};
237 < }
238 <
239 <
240 < # ---- Tag routines
241 <
242 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
243 < #   the type tag will pick up a pre-defined class type from project space.
244 <
245 < sub Class_StartTag {
246 <        my $self=shift;
247 <        my $name=shift;
248 <        my $hashref=shift;
249 <        
250 <        if ( $self->{Arch} ) {
251 <         if ( defined $$hashref{'type'} ) {
252 <                $ClassName=$$hashref{'type'};
307 >      else
308 >         {
309 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
310           }
311 <        }
312 < }
256 <
257 < sub IncludePath_Start {
258 <        my $self=shift;
259 <        my $name=shift;
260 <        my $hashref=shift;
261 <
262 <        $self->{switch}->checktag( $name, $hashref, 'path');
263 <        if ( $self->{Arch} ) {
264 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
265 <                                                $$hashref{'path'}."\n";
266 <        }
267 < }
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 <        if ( $self->{Arch} ) {
324 <
325 <          # -- determine the build products name
326 <          my $name;
327 <          if ( exists $$hashref{'name'} ) {
328 <            $name=$$hashref{'name'};
329 <          }
330 <          else {
331 <            $self->{switch}->parseerror("No name specified for build product");
332 <            #$name="\$(buildname)";
288 <          }
289 <
290 <          # -- check we have a lookup for the class type
291 <          my $mapper=$self->_toolmapper();
292 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
293 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
294 <          }
295 <          else {
296 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
297 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
298 <
299 <           my $fh=$self->{filehandlestack}[0];
300 <           my @targets=();
301 <
302 <           # -- generate generic targets
303 <           print $fh "ifndef _BuildLink_\n";
304 <           print $fh "# -- Generic targets\n";
305 <           push @targets, $$hashref{'class'};
306 <           foreach $dtype ( @deftypes ) {
307 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
308 <                                                                $dtype."\n";
309 <           }
310 <           print $fh "\n";
311 <
312 <           # -- generate targets for each type
313 <           foreach $type ( @types ) {
314 <
315 <            # -- generic name for each type
316 <            my $pattern=$$hashref{'class'}."_".$type;
317 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
318 <            print $fh "# ------ $pattern rules ---------------\n";
319 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
320 <                                                        "_".$type."_$name\n\n";
321 <
322 <            # -- create a new directory for each type
323 <            push @targets, $pattern;
324 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
325 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
326 <            my $makefile=$here."/BuildFile.mk";
327 < #           AddDir::adddir($here);
328 <
329 <            # -- create link targets to the directory
330 <            push @targets, $dirname;
331 <            print $fh "# -- Link Targets to $type directories\n";
332 <            print $fh "$dirname: make_$dirname\n";
333 <            print $fh "\t\@cd $here; \\\n";
334 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
335 <                        " workdir=$here ".
336 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
337 <
338 <            # -- write target to make makefile for each directory
339 <            print $fh "# -- Build target directories\n";
340 <            print $fh "make_$dirname:\n";
341 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
342 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
343 <            print $fh "\t  mkdir $here; \\\n";
344 <            print $fh "\t fi;\\\n";
345 <            print $fh "\t cd $dirname; \\\n";
346 <            print $fh "\t echo include ".$self->{currentenv}." > ".
347 <                                                        "$makefile; \\\n";
348 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
349 <                                        " >> $makefile; \\\n";
350 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
351 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
352 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
353 <             foreach $f ( @file ) {
354 <              print $fh "\t echo -include $f >> $makefile; \\\n";
355 <             }
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              }
357            print $fh "\tfi\n";
358            print $fh "\n";
359 #           print $typefile "$name :\n";
360 #           print $typefile "\t\$(_quietbuild_)";
361 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
362 #           print $typefile "\t\$(_quietstamp_)";
363 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
364
365            # -- cleaning targets
366            push @targets, "clean_$dirname";
367            print $fh "# -- cleaning targets\n";
368            print $fh "clean::clean_$dirname\n";
369            print $fh "clean_".$dirname."::\n";
370            print $fh "\t\@echo cleaning $dirname\n";
371            print $fh "\t\@if [ -d $here ]; then \\\n";
372            print $fh "\tcd $here; \\\n";
373            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
374                        $here." _BuildLink_=1 -f ".
375                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
376            print $fh "\tfi\n\n";
377
378
379          }
380          # -- help targets
381          print $fh "helpheader::\n";
382          print $fh "\t\@echo Targets available:\n";
383          print $fh "\t\@echo ------------------\n\n";
384          print $fh "help::helpheader\n";
385          foreach $target ( @targets ) {
386            print $fh "help::\n";
387            print $fh "\t\@echo $target\n"
388          }
389          print $fh "endif\n";
390         } # end else
391        }
392 }
393
394 sub Bin_start {
395        my $self=shift;
396        my $name=shift;
397        my $hashref=shift;
398
399        my $fileclass;
400        my @tools;
401        my $tool;
402        my $filename;
403        my $objectname;
404        
405        $self->{switch}->checktag($name,$hashref,'file');
406        if ( $self->{Arch} ) {
407        if ( ! defined $$hashref{name} ) {
408                ($$hashref{name}=$$hashref{file})=~s/\..*//;
409        }
410        ($filename=$$hashref{file})=~s/\..*//;
411
412        # Create a new directory for each binary target
413        my $dirname="bin_".$$hashref{name};
414        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
415        open (binGNUmakefile,
416           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
417           "BuildFile.mk $!\n";
418
419        # Create the link targets
420        $numbins++;
421        my $fh=$self->{filehandlestack}[0];
422        print $fh <<ENDTEXT;
423
424 # Link Targets to binary directories
425 ifdef BINMODE
426 # We dont want to build a library here
427 override files:=
428 endif
429 ifndef BINMODE
430
431 define stepdown_$$hashref{'name'}
432 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
433 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
434 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
435 fi
436 endef
437
438 define stepdown2_$$hashref{'name'}
439 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
440 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
441 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
442 fi
443
444 endef
445
446 bin_$$hashref{'name'}_%:: dummy
447        \@\$(stepdown2_$$hashref{'name'})
448
449 $$hashref{'name'}_%:: dummy
450        \@\$(stepdown_$$hashref{'name'})
451
452 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
453        \@\$(stepdown_$$hashref{'name'})
454
455 binfiles+=$$hashref{'file'}
456 locbinfiles+=$dirname/$$hashref{'file'}
457 endif
458
459
460 ENDTEXT
461
462
463 # the binary specifics makefile
464        print binGNUmakefile "include ".$self->{currentenv}."\n";
465        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
466
467 # alias for bin_Insure
468        print binGNUmakefile <<ENDTEXT;
469
470 bin_insure:bin_Insure
471 ifdef MAKETARGET_bin_insure
472 MAKETARGET_$$hashref{name}_Insure=1
473 endif
474
475 # debuggging target
476 $$hashref{'name'}_echo_% :: echo_%
477
478 # help targets
479 help::
480 \t\@echo Targets For $$hashref{'name'}
481 \t\@echo -------------------------------------
482 \t\@echo $$hashref{'name'}  - default build
483 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
484 ENDTEXT
485
486 # Make generic rules for each type
487        $targettypes={
488                "bin" => 'o',
489                "bin_debug" => 'd',
490                "bin_debug_local" => 'l_d',
491                "bin_Insure" => 'Insure'
492        };
493        #
494        foreach $target ( keys %$targettypes ) {
495          print binGNUmakefile <<ENDTEXT;
496
497 # Type $target specifics
498 ifdef MAKETARGET_$target
499 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
500 endif
501 $target ::$$hashref{name}_$$targettypes{$target}
502
503 bintargets+=$$hashref{name}_$$targettypes{$target}
504 help::
505 \t\@echo $$hashref{name}_$$targettypes{$target}
506 clean::
507 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
508 \techo Removing \$(binarystore)/$$hashref{name}; \\
509 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
510 \tfi
511
512 ENDTEXT
513          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
514          ${"objectname_$$targettypes{$target}"}=$objectname;
515          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
516        } # end loop
517
518        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
519        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
520        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
521        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
522        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
523        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
524        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
525        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
526        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
527        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
528        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
529        print binGNUmakefile "\t\$(CClinkCmd)\n";
530        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
531        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
532        print binGNUmakefile "-include $$hashref{name}.dep\n";
533 print binGNUmakefile <<ENDTEXT;
534 clean::
535 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
536 \techo Removing \$(binarystore)/$$hashref{name}; \\
537 \trm \$(binarystore)/$$hashref{name}; \\
538 \tfi
539
540 $$hashref{name}_d.exe:\$(libslocal_d)
541 $$hashref{name}_o.exe:\$(libslocal)
542 ifdef MCCABE_DATA_DIR
543 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
544 endif
545 $$hashref{name}_Insure.exe:\$(libslocal_I)
546 $$hashref{name}_d:$$hashref{name}_d.exe
547        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
548 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
549        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
550 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
551        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
552 $$hashref{name}:$$hashref{name}_d.exe
553        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
554 $$hashref{name}_o:$$hashref{name}_o.exe
555        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
556 binfiles+=$$hashref{file}
557 ENDTEXT
558        }
559        close binGNUmakefile;
560 }
561
562 sub External_StartTag {
563        my $self=shift;
564        my $name=shift;
565        my $hashref=shift;
566        
567        my $tool;
568        if ( $self->{Arch} ) {
569        $self->{switch}->checktag($name,$hashref,'ref');
570
571        # -- oo toolbox stuff
572        # - get the appropriate tool object
573        $$hashref{'ref'}=~tr[A-Z][a-z];
574        if ( ! exists $$hashref{'version'} ) {
575         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
576        }
577        else {
578         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
579        }
580        if ( ! defined $tool ) {
581          $self->{switch}->parseerror("Unknown Tool Specified ("
582                                                        .$$hashref{'ref'}.")");
583        }
584
585        # -- old fashioned GNUmakefile stuff
586        print GNUmakefile $$hashref{'ref'};
587        if ( defined $$hashref{'version'} ) {
588                print GNUmakefile "_V_".$$hashref{'version'};
589        }
590        print GNUmakefile "=true\n";
591        
592        # -- Sub system also specified?
593        if ( exists $$hashref{'use'} ) {
594           # -- look for a buildfile
595           my @paths=$tool->getfeature("INCLUDE");
596           my $file="";
597           my ($path,$testfile);
598           foreach $path ( @paths ) {
599             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
600             if ( -f $testfile ) {
601                $file=$testfile;
602                $self->_pushremoteproject($path);
603             }
604           }
605           if ( $file eq "" ) {
606             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
607           }
608           $self->ParseBuildFile_Export($file);
609           $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 < sub CheckBuildFile {
385 <         my $self=shift;
386 <         my $classdir=shift;
387 <         my $ClassName="";
388 <         my $thisfile="$classdir/$buildfile";
389 <
390 <         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
391 <            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
392 <            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
393 <         }
394 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
395 <            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
396 <            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
397 <         }
398 <         return $ClassName;
399 < }
400 <
401 < # List association groups between <AssociateGroup> tags
402 < # seperated by newlines or spaces
403 < sub AssociateGroup {
404 <        my $self=shift;
405 <        my $name=shift;
406 <        my $string=shift;
407 <        my $word;
408 <
409 <        if ( $self->{Arch} ) {
410 <        foreach $word ( (split /\s/, $string) ){
411 <                chomp $word;
412 <                next if /^#/;
413 <                if ( $word=~/none/ ) {
414 <                        $self->{ignore}=1;
415 <                }
416 <        }
417 <        }
418 < }
419 <
420 < sub Arch_Start {
421 <        my $self=shift;
422 <        my $name=shift;
423 <        my $hashref=shift;
424 <
425 <        $self->{switch}->checktag($name, $hashref,'name');
426 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
427 <                                                : ($self->{Arch}=0);
428 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
429 < }
430 <
431 < sub Arch_End {
432 <        my $self=shift;
433 <        my $name=shift;
434 <
435 <        pop @{$self->{ARCHBLOCK}};
436 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
437 < }
438 <
439 < # Split up the Class Block String into a useable array
440 < sub _CutBlock {
441 <    my $self=shift;
442 <    my $string= shift @_;
443 <    @BlockClassA = split /\//, $string;
444 < }
445 <
446 < sub OutToMakefile {
447 <        my $self=shift;
448 <        my $name=shift;
449 <        my @vars=@_;
450 <
451 <        if ( $self->{Arch} ) {
452 <          print GNUmakefile @vars;
453 <        }
454 < }
455 <
456 < sub OutToScreen {
457 <        my $name=shift;
458 <        my @vars=@_;
459 <
460 <        if ( $self->{Arch} ) {
461 <          print @vars;
462 <        }
463 < }
464 < sub setBlockClassPath {
465 <        my $self=shift;
466 <        my $name=shift;
467 <        my $hashref=shift;
468 <
469 <        $self->{switch}->checktag($name, $hashref, 'path');
470 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
471 <        $self->_CutBlock($$hashref{path});
472 < }
473 <
474 < sub BlockClassPath {
475 <        my $self=shift;
476 <        return $self->{BlockClassPath};
477 < }
478 <
479 < sub export_start_export {
480 <        my $self=shift;
481 <        my $name=shift;
482 <        my $hashref=shift;
483 <
484 <        $self->{switch}->opengroup("__export");
485 < }
486 <
487 < sub export_start {
488 <        my $self=shift;
489 <        my $name=shift;
490 <        my $hashref=shift;
491 <
492 <        $self->{switch}->opengroup("__export");
493 <        if ( exists $$hashref{autoexport} ) {
494 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
495 <          if ( $$hashref{autoexport}=~/true/ ) {
496 <           $self->{switch}->allowgroup("__export","makebuild");
497 <          }
498 <          else {
499 <           $self->{switch}->disallowgroup("__export","makebuild");
500 <          }
501 <        }
502 <        # -- allow default setting from other makefiles
503 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
504 < }
505 <
506 < sub export_end_export {
507 <        my $self=shift;
508 <        $self->{switch}->closegroup("__export");
509 < }
510 <
511 < sub export_end {
512 <        my $self=shift;
513 <        $self->{switch}->closegroup("__export");
514 <        print GNUmakefile "endif\n";
515 < }
516 <
517 < #
518 < # Standard lib tag
519 < #
520 < sub lib_start {
521 <        my $self=shift;
522 <        my $name=shift;
523 <        my $hashref=shift;
524 <
525 <        $self->{switch}->checktag($name, $hashref, 'name');
526 <        if ( $self->{Arch} ) {
527 <           print GNUmakefile "lib+=$$hashref{name}\n";
528 <        }
529 < }
530 <
531 < #
532 < # libtype specification
533 < #
534 < sub LibType_Start {
535 <        my $self=shift;
536 <        my $name=shift;
537 <        my $hashref=shift;
538 <
539 <        if ( $self->{Arch} ) {
540 <        if ( defined $self->{libtype_conext} ) {
541 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
542 <                " without a </$name> tag to close previous context");
543 <        }
544 <        else {
545 <        $self->{libtype_conext}=1;
546 <        $self->{switch}->checktag($name, $hashref, 'type');
547 <        
548 <        print GNUmakefile "# Specify Library Type\n";
549 <        print GNUmakefile "DefaultLibsOff=yes\n";
550 <        if ( $$hashref{'type'}=~/^archive/i ) {
551 <          print GNUmakefile "LibArchive=true\n";
552 <        }
553 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
554 <          print GNUmakefile "LibDebugArchive=true\n";
555 <        }
556 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
557 <          print GNUmakefile "LibDebugShared=true\n";
558 <        }
559 <        elsif ($$hashref{'type'}=~/shared/i ) {
560 <          print GNUmakefile 'LibShared=true'."\n";
561 <        }
562 <        print GNUmakefile "\n";
563 <        }
564 <        }
565 < }
566 <
567 < sub LibType_text {
568 <        my $self=shift;
569 <        my $name=shift;
570 <        my $string=shift;
571 <
572 <        if ( $self->{Arch} ) {
573 <          $string=~s/\n/ /g;
574 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
575 <          print GNUmakefile $string;
576 <          print GNUmakefile "\n";
577 <        }
578 < }
579 <
580 < sub LibType_end {
581 <        my $self=shift;
582 <        my $name=shift;
583 <
584 <        undef $self->{libtype_conext};
585 < }
586 <
587 < sub Environment_start {
588 <        my $self=shift;
589 <        my $name=shift;
590 <        my $hashref=shift;
591 <
592 <        if ( $self->{Arch} ) {
593 <          $self->{envnum}++;
594 <
595 <          # open a new Environment File
596 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
597 <                $self->{envnum}.".mk";
598 <          use FileHandle;
599 <          my $fh=FileHandle->new();
600 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
601 <          push @{$self->{filehandlestack}}, $fh;
602 <          *GNUmakefile=$fh;
603 <
604 <          # include the approprate environment file
605 <          if ( $self->{envlevel} == 0 ) {
606 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
607 <                $self->{path}."/BuildFile.mk\n";
608 <          }
609 <          else {
610 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
611 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
612 <          }
613 <          $self->{envlevel}++;
614 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
615 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
616 <        }
617 < }
618 <
619 < sub Environment_end {
620 <        my $self=shift;
621 <        my $fd;
622 <
623 <        if ( $self->{Arch} ) {
624 <          $self->{envlevel}--;
625 <          if ( $self->{envlevel} < 0 ) {
626 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
627 <            exit 1;
628 <          }
629 <          close GNUmakefile;
630 <          # restore the last filehandle
631 <          $fd=pop @{$self->{filehandlestack}};
632 <          close $fd;
633 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
634 <          if ( $self->{envlevel} < 1 ) {
635 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
636 <                        "BuildFile.mk";
637 <          }
638 <          else {
639 <            $self->{currentenv}=
640 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
641 <                $self->{Envlevels}[$self->{envlevel}];
642 <          }
643 <        }
644 < }
645 <
646 < sub Store_start {
647 <        my $self=shift;
648 <        my $name=shift;
649 <        my $hashref=shift;
650 <
651 <        if ( $self->{Arch} ) {
652 <          $self->{switch}->checktag( $name, $hashref, 'name' );
653 <
654 <          # -- store creation
655 <          my $dir=$$hashref{'name'};
656 <          AddDir::adddir($ENV{LOCALTOP}."/".$dir);
657 <          if ( exists $$hashref{'type'} ) {
658 <            # -- architecture specific store
659 <            if ( $$hashref{'type'}=~/^arch/i ) {
660 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
937 <                AddDir::adddir($ENV{LOCALTOP}."/".$dir);
938 <            }
939 <            else {
940 <                $self->parseerror("Unknown type in <$name> tag");
941 <            }
942 <          }
943 <
944 <          # -- set make variables for the store
945 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
946 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
947 <                                        $ENV{LOCALTOP}."/".$dir."\n";
948 <          print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
949 <                        ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
950 <        }
951 < }
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