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.17 by sashby, Tue May 14 10:21:19 2002 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(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 Utilities::Verbose;
13 use ActiveDoc::SimpleDoc;
14 use BuildSystem::ToolBox;
13   require 5.004;
14 < @ISA=qw(Utilities::Verbose);
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 <        $self->verbose(">> ignore......<<");
34 <        
35 <        return (defined $self->{ignore})?$self->{ignore}:0;
36 < }
37 <
38 < sub _initswitcher {
39 <        my $self=shift;
40 <        my $switch=ActiveDoc::SimpleDoc->new();
41 <        my $parse="makebuild";
42 <        $self->verbose(">> _initswitcher: <<");
44 <        $switch->newparse($parse);
45 <        $switch->addignoretags($parse);
46 <        $self->_commontags($switch,$parse);
47 <        $switch->addtag($parse,"Build", \&Build_start, $self);
48 <        $switch->addtag($parse,"none",
49 <                                        \&OutToMakefile,$self,
50 <                                        \&OutToMakefile, $self,
51 <                                        "", $self);
52 <        $switch->addtag($parse,"Bin",
53 <                                        \&Bin_start,$self,
54 <                                        \&OutToScreen, $self,
55 <                                        "", $self);
56 <         $switch->addtag($parse,"ProductStore",
57 <                                        \&Store_start,$self,
58 <                                        "", $self,
59 <                                        "", $self);
60 <        $switch->addtag($parse,"LibType",
61 <                                        \&LibType_Start,$self,
62 <                                        \&LibType_text, $self,
63 <                                        \&LibType_end,$self);
64 <        $switch->addtag($parse,"ConfigurationClass",
65 <                                        \&Class_StartTag,$self,
66 <                                        \&OutToMakefile, $self,
67 <                                        "", $self);
68 <        $switch->addtag($parse,"ClassPath",
69 <                                        \&setBlockClassPath,$self,
70 <                                        \&OutToMakefile, $self,
71 <                                        "", $self);
72 <        $switch->addtag($parse,"AssociateGroup",
73 <                                        "",$self,
74 <                                        \&AssociateGroup,$self,
75 <                                        "", $self);
76 <        $switch->addtag($parse,"Environment",
77 <                                        \&Environment_start,$self,
78 <                                        \&OutToMakefile, $self,
79 <                                        \&Environment_end,$self);
80 <        $switch->addtag($parse,"Export",
81 <                                        \&export_start,$self,
82 <                                        \&OutToMakefile, $self,
83 <                                        \&export_end,$self);
84 <        return $switch;
85 < }
86 <
87 < sub _commontags {
88 <        my $self=shift;
89 <        my $switch=shift;
90 <        my $parse=shift;
91 <        
92 <        $self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<");
93 <        
94 <        $switch->grouptag("Export",$parse);
95 <        $switch->addtag($parse,"Use",\&Use_start,$self,
96 <                                               \&OutToMakefile, $self,
97 <                                                "", $self);
98 <        $switch->addtag($parse,"Group",\&Group_start,$self,
99 <                                               \&OutToMakefile, $self,
100 <                                                "", $self);
101 <        $switch->grouptag("Group",$parse);
102 <        $switch->addtag($parse,"External",
103 <                                        \&External_StartTag,$self,
104 <                                        \&OutToMakefile, $self,
105 <                                        "", $self);
106 <        $switch->addtag($parse,"lib",
107 <                                        \&lib_start,$self,
108 <                                        \&OutToMakefile, $self,
109 <                                        "", $self);
110 <        $switch->addtag($parse,"Architecture",
111 <                                        \&Arch_Start,$self,
112 <                                        \&OutToMakefile, $self,
113 <                                        \&Arch_End,$self);
114 <        $switch->addtag($parse,"INCLUDE_PATH",
115 <                                        \&IncludePath_Start,$self,
116 <                                        \&OutToMakefile, $self,
117 <                                        "",$self);
118 <        return $switch;
119 < }
120 <
121 < sub ParseBuildFile {
122 <        my $self=shift;
123 <        my $base=shift;
124 <        my $path=shift;
125 <        my $filename=shift @_;
126 <        my $fullfilename;
127 <        if ( $filename!~/^\// ) {
128 <         $fullfilename="$base/$path/$filename";
129 <        }
130 <        else {
131 <         $fullfilename=$filename;
132 <        }
133 <
134 <        $self->verbose(">> ParseBuildFile: FN ".$fullfilename." <<");
135 <        
136 <        $self->{path}=$path;
137 <        $numbins=0;
138 <        $self->{envnum}=0;
139 <        $self->{envlevel}=0;
140 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
141 <                                                                "BuildFile.mk";
142 <        $self->{switch}=$self->_initswitcher();
143 <        $self->{switch}->filetoparse($fullfilename);
144 <
145 <        # open a temporary gnumakefile to store output.
146 <        use Utilities::AddDir;
147 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
148 <        my $fh=FileHandle->new();
149 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
150 <          ) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
151 <        @{$self->{filehandlestack}}=($fh);
152 <        # make an alias
153 <        *GNUmakefile=$fh;
154 <        if ( -e $ENV{LatestBuildFile} ) {
155 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
156 <        }
157 <
158 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
159 <        $self->{switch}->parse("makebuild"); # sort out supported tags
160 <        if ( $numbins > 0 ) {
161 <         print GNUmakefile <<ENDTEXT;
162 < ifndef BINMODE
163 < help::
164 < \t\@echo Generic Binary targets
165 < \t\@echo ----------------------
166 < endif
167 < ENDTEXT
168 <         foreach $target ( keys %$targettypes ) {
169 <         print GNUmakefile <<ENDTEXT;
170 < ifndef BINMODE
171 < help::
172 < \t\@echo $target
173 < endif
174 < ENDTEXT
175 <         }
176 <        }
177 <        close GNUmakefile;
178 < }
179 <
180 < sub ParseBuildFile_Export {
181 <        my $self=shift;
182 <        my $filename=shift;
183 <
184 <        $self->verbose(">> ParseBuildFile_Export: FN ".$filename." <<");
185 <        
186 <        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
187 <        if ( defined $self->{remoteproject} ) {
188 <           $bf->{remoteproject}=$self->{remoteproject};
189 <        }
190 <        $bf->_parseexport($filename);
191 <        undef $bf;
192 < }
193 <
194 < sub _location {
195 <        my $self=shift;
196 <        use File::Basename;
197 <        $self->verbose(">> _location: <<");
198 <        return dirname($self->{switch}->filetoparse());
199 < }
200 <
201 < sub _parseexport {
202 <        my $self=shift;
203 <        my $filename=shift;
204 <        $self->verbose(">> _parseexport: FN ".$filename." <<");
205 <        
206 <        my $switchex=ActiveDoc::SimpleDoc->new();
207 <        $switchex->filetoparse($filename);
208 <        $switchex->newparse("export");
209 <        $switchex->addignoretags("export");
210 <        $switchex->addtag("export","Export",
211 <                                        \&export_start_export,$self,
212 <                                        \&OutToMakefile, $self,
213 <                                        \&export_end_export,$self);
214 <        $self->_commontags($switchex,"export");
215 <        $switchex->allowgroup("__export","export");
216 <        $self->{switch}=$switchex;
217 <        $switchex->parse("export"); # sort out supported tags
218 < }
219 <
220 < sub _pushremoteproject {
221 <        my $self=shift;
222 <        my $path=shift;
223 <
224 <        $self->verbose(">> _pushremoteproject: PATH ".$path." <<");
225 <        
226 <        if ( defined $self->{remoteproject} ) {
227 <          push @{$self->{rpstack}}, $self->{remoteproject};
228 <        }
229 <        $self->{remoteproject}=$path;
230 < }
231 <
232 < sub _popremoteproject {
233 <        my $self=shift;
234 <        $self->verbose(">> _popremoteproject:  <<");
235 <        
236 <        if ( $#{$self->{rpstack}} >=0 ) {
237 <          $self->{remoteproject}=pop @{$self->{rpstack}};
238 <        }
239 <        else {
240 <          undef $self->{remoteproject};
241 <        }
242 < }
243 <
244 < sub _toolmapper {
245 <        my $self=shift;
246 <
247 <        if ( ! defined $self->{mapper} ) {
248 <           require BuildSystem::ToolMapper;
249 <           $self->{mapper}=BuildSystem::ToolMapper->new();
250 <        }
251 <        $self->verbose(">> _toolmapper: TM ".$self->{mapper}."<<");
252 <        return $self->{mapper};
253 < }
254 <
255 <
256 < # ---- Tag routines
257 <
258 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
259 < #   the type tag will pick up a pre-defined class type from project space.
260 <
261 < sub Class_StartTag {
262 <        my $self=shift;
263 <        my $name=shift;
264 <        my $hashref=shift;
265 <
266 <        $self->verbose(">> Classs_StartTag: NM ".$name." <<");
267 <        
268 <        if ( $self->{Arch} ) {
269 <         if ( defined $$hashref{'type'} ) {
270 <                $ClassName=$$hashref{'type'};
271 <         }
272 <        }
273 < }
274 <
275 < sub IncludePath_Start
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 $name=shift;
46 <   my $hashref=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->verbose(">> IncludePath_Start: NM ".$name." <<");
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->{switch}->checktag( $name, $hashref, 'path');
78 <   if ( $self->{Arch} )
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 <      print GNUmakefile "INCLUDE:=\$(filter-out ".$self->_location()."/".$$hashref{'path'}.",\$(INCLUDE))","\n";
108 <      print GNUmakefile "INCLUDE+=".$self->_location()."/".$$hashref{'path'}."\n";
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 < #
115 < # generic build tag
116 < #
117 < sub Build_start {
118 <        my $self=shift;
296 <        my $name=shift;
297 <        my $hashref=shift;
298 <
299 <        $self->verbose(">> Build_start: NM ".$name." <<");
300 <        
301 <        $self->{switch}->checktag($name,$hashref,'class');
302 <        if ( $self->{Arch} ) {
303 <
304 <          # -- determine the build products name
305 <          my $name;
306 <          if ( exists $$hashref{'name'} ) {
307 <            $name=$$hashref{'name'};
308 <          }
309 <          else {
310 <            $self->{switch}->parseerror("No name specified for build product");
311 <          }
312 <
313 <          # -- check we have a lookup for the class type
314 <          my $mapper=$self->_toolmapper();
315 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
316 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
317 <          }
318 <          else {
319 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
320 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
321 <
322 <           my $fh=$self->{filehandlestack}[0];
323 <           my @targets=();
324 <
325 <           # -- generate generic targets
326 <           print $fh "ifndef _BuildLink_\n";
327 <           print $fh "# -- Generic targets\n";
328 <           push @targets, $$hashref{'class'};
329 <           foreach $dtype ( @deftypes ) {
330 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
331 <                                                                $dtype."\n";
332 <           }
333 <           print $fh "\n";
334 <
335 <           # -- generate targets for each type
336 <           foreach $type ( @types ) {
337 <
338 <            # -- generic name for each type
339 <            my $pattern=$$hashref{'class'}."_".$type;
340 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
341 <            print $fh "# ------ $pattern rules ---------------\n";
342 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
343 <                                                        "_".$type."_$name\n\n";
344 <
345 <            # -- create a new directory for each type
346 <            push @targets, $pattern;
347 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
348 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
349 <            my $makefile=$here."/BuildFile.mk";
350 <
351 <            # -- create link targets to the directory
352 <            push @targets, $dirname;
353 <            print $fh "# -- Link Targets to $type directories\n";
354 <            print $fh "$dirname: make_$dirname\n";
355 <            print $fh "\t\@cd $here; \\\n";
356 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
357 <                        " workdir=$here ".
358 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
359 <
360 <            # -- write target to make makefile for each directory
361 <            print $fh "# -- Build target directories\n";
362 <            print $fh "make_$dirname:\n";
363 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
364 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
365 <            print $fh "\t  mkdir $here; \\\n";
366 <            print $fh "\t fi;\\\n";
367 <            print $fh "\t cd $dirname; \\\n";
368 <            print $fh "\t echo include ".$self->{currentenv}." > ".
369 <                                                        "$makefile; \\\n";
370 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
371 <                                        " >> $makefile; \\\n";
372 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
373 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
374 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
375 <             foreach $f ( @file ) {
376 <              print $fh "\t echo -include $f >> $makefile; \\\n";
377 <             }
378 <            }
379 <            print $fh "\tfi\n";
380 <            print $fh "\n";
114 > sub architecture()
115 >   {
116 >   my ($object,$name,%attributes)=@_;
117 >   $self->pushlevel(\%attributes); # Set nested to 1;
118 >   }
119  
120 <            # -- cleaning targets
121 <            push @targets, "clean_$dirname";
122 <            print $fh "# -- cleaning targets\n";
123 <            print $fh "clean::clean_$dirname\n";
124 <            print $fh "clean_".$dirname."::\n";
387 <            print $fh "\t\@echo cleaning $dirname\n";
388 <            print $fh "\t\@if [ -d $here ]; then \\\n";
389 <            print $fh "\tcd $here; \\\n";
390 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
391 <                        $here." _BuildLink_=1 -f ".
392 <                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
393 <            print $fh "\tfi\n\n";
394 <
395 <
396 <          }
397 <          # -- help targets
398 <          print $fh "helpheader::\n";
399 <          print $fh "\t\@echo Targets available:\n";
400 <          print $fh "\t\@echo ------------------\n\n";
401 <          print $fh "help::helpheader\n";
402 <          foreach $target ( @targets ) {
403 <            print $fh "help::\n";
404 <            print $fh "\t\@echo $target\n"
405 <          }
406 <          print $fh "endif\n";
407 <         } # end else
408 <        }
409 < }
410 <
411 < sub Bin_start {
412 <        my $self=shift;
413 <        my $name=shift;
414 <        my $hashref=shift;
415 <
416 <        my $fileclass;
417 <        my @tools;
418 <        my $tool;
419 <        my $filename;
420 <        my $objectname;
421 <
422 <        $self->verbose(">>          <<");
423 <        
424 <        $self->{switch}->checktag($name,$hashref,'file');
425 <        if ( $self->{Arch} ) {
426 <        if ( ! defined $$hashref{name} ) {
427 <                ($$hashref{name}=$$hashref{file})=~s/\..*//;
428 <        }
429 <        ($filename=$$hashref{file})=~s/\..*//;
430 <
431 <        # Create a new directory for each binary target
432 <        my $dirname="bin_".$$hashref{name};
433 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
434 <        open (binGNUmakefile,
435 <           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
436 <           "BuildFile.mk $!\n";
437 <
438 <        # Create the link targets
439 <        $numbins++;
440 <        my $fh=$self->{filehandlestack}[0];
441 <        print $fh <<ENDTEXT;
442 <
443 < # Link Targets to binary directories
444 < ifdef BINMODE
445 < # We dont want to build a library here
446 < override files:=
447 < endif
448 < ifndef BINMODE
449 <
450 < define stepdown_$$hashref{'name'}
451 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
452 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
453 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
454 < fi
455 < endef
456 <
457 < define stepdown2_$$hashref{'name'}
458 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
459 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
460 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
461 < fi
462 <
463 < endef
464 <
465 < bin_$$hashref{'name'}_%:: dummy
466 <        \@\$(stepdown2_$$hashref{'name'})
467 <
468 < $$hashref{'name'}_%:: dummy
469 <        \@\$(stepdown_$$hashref{'name'})
470 <
471 < help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
472 <        \@\$(stepdown_$$hashref{'name'})
473 <
474 < binfiles+=$$hashref{'file'}
475 < locbinfiles+=$dirname/$$hashref{'file'}
476 < endif
477 <
478 <
479 < ENDTEXT
480 <
481 <
482 < # the binary specifics makefile
483 <        print binGNUmakefile "include ".$self->{currentenv}."\n";
484 <        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
485 <
486 < # alias for bin_Insure
487 <        print binGNUmakefile <<ENDTEXT;
488 <
489 < bin_insure:bin_Insure
490 < ifdef MAKETARGET_bin_insure
491 < MAKETARGET_$$hashref{name}_Insure=1
492 < endif
493 <
494 < # debuggging target
495 < $$hashref{'name'}_echo_% :: echo_%
496 <
497 < # help targets
498 < help::
499 < \t\@echo Targets For $$hashref{'name'}
500 < \t\@echo -------------------------------------
501 < \t\@echo $$hashref{'name'}  - default build
502 < \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
503 < ENDTEXT
504 <
505 < # Make generic rules for each type
506 <        $targettypes={
507 <                "bin" => 'o',
508 <                "bin_debug" => 'd',
509 <                "bin_debug_local" => 'l_d',
510 <                "bin_Insure" => 'Insure'
511 <        };
512 <        #
513 <        foreach $target ( keys %$targettypes ) {
514 <          print binGNUmakefile <<ENDTEXT;
515 <
516 < # Type $target specifics
517 < ifdef MAKETARGET_$target
518 < MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
519 < endif
520 < $target ::$$hashref{name}_$$targettypes{$target}
521 <
522 < bintargets+=$$hashref{name}_$$targettypes{$target}
523 < help::
524 < \t\@echo $$hashref{name}_$$targettypes{$target}
525 < clean::
526 < \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
527 < \techo Removing \$(binarystore)/$$hashref{name}; \\
528 < \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
529 < \tfi
530 <
531 < ENDTEXT
532 <          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
533 <          ${"objectname_$$targettypes{$target}"}=$objectname;
534 <          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
535 <        } # end loop
536 <
537 <        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
538 <        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
539 <        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
540 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
541 <        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
542 <        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
543 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
544 <        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
545 <        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
546 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
547 <        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
548 <        print binGNUmakefile "\t\$(CClinkCmd)\n";
549 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
550 <        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
551 <        print binGNUmakefile "-include $$hashref{name}.dep\n";
552 < print binGNUmakefile <<ENDTEXT;
553 < clean::
554 < \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
555 < \techo Removing \$(binarystore)/$$hashref{name}; \\
556 < \trm \$(binarystore)/$$hashref{name}; \\
557 < \tfi
558 <
559 < $$hashref{name}_d.exe:\$(libslocal_d)
560 < $$hashref{name}_o.exe:\$(libslocal)
561 < ifdef MCCABE_DATA_DIR
562 < $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
563 < endif
564 < $$hashref{name}_Insure.exe:\$(libslocal_I)
565 < $$hashref{name}_d:$$hashref{name}_d.exe
566 <        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
567 < $$hashref{name}_l_d:$$hashref{name}_l_d.exe
568 <        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
569 < $$hashref{name}_Insure:$$hashref{name}_Insure.exe
570 <        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
571 < $$hashref{name}:$$hashref{name}_d.exe
572 <        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
573 < $$hashref{name}_o:$$hashref{name}_o.exe
574 <        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
575 < binfiles+=$$hashref{file}
576 < ENDTEXT
577 <        }
578 <        close binGNUmakefile;
579 < }
580 <
581 < sub External_StartTag {
582 <        my $self=shift;
583 <        my $name=shift;
584 <        my $hashref=shift;
585 <
586 <        $self->verbose(">> External_StartTag: NM ".$name." <<");
587 <        
588 <        my $tool;
589 <        if ( $self->{Arch} ) {
590 <        $self->{switch}->checktag($name,$hashref,'ref');
591 <
592 <        # -- oo toolbox stuff
593 <        # - get the appropriate tool object
594 <        $$hashref{'ref'}=~tr[A-Z][a-z];
595 <        if ( ! exists $$hashref{'version'} ) {
596 <         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
597 <        }
598 <        else {
599 <         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
600 <        }
601 <        if ( ! defined $tool ) {
602 <          $self->{switch}->parseerror("Unknown Tool Specified ("
603 <                                                        .$$hashref{'ref'}.")");
604 <        }
605 <
606 <        # -- old fashioned GNUmakefile stuff
607 <        print GNUmakefile $$hashref{'ref'};
608 <        if ( defined $$hashref{'version'} ) {
609 <                print GNUmakefile "_V_".$$hashref{'version'};
610 <        }
611 <        print GNUmakefile "=true\n";
612 <        
613 <        # -- Sub system also specified?
614 <        if ( exists $$hashref{'use'} ) {
615 <           # -- look for a buildfile
616 <           my @paths=$tool->getfeature("INCLUDE");
617 <           my $file="";
618 <           my ($path,$testfile);
619 <           foreach $path ( @paths ) {
620 <             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
621 <             if ( -f $testfile ) {
622 <                $file=$testfile;
623 <                $self->_pushremoteproject($path);
624 <             }
625 <           }
626 <           if ( $file eq "" ) {
627 <             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
628 <           }
629 <           $self->ParseBuildFile_Export($file);
630 <           $self->_popremoteproject();
631 <         }
632 <        }
633 < }      
120 > sub architecture_()
121 >   {
122 >   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
123 >   $self->poplevel();
124 >   }
125  
126 < sub Group_start {
127 <        my $self=shift;
128 <        my $name=shift;
129 <        my $hashref=shift;
639 <        
640 <        $self->verbose(">> Group_start: NM ".$name." <<");
641 <        
642 <        $self->{switch}->checktag($name, $hashref, 'name');
643 <        if ( $self->{Arch} ) {
644 <        print GNUmakefile "GROUP_".$$hashref{'name'};
645 <        if ( defined $$hashref{'version'} ) {
646 <                print GNUmakefile "_V_".$$hashref{'version'};
647 <        }
648 <        print GNUmakefile "=true\n";
649 <        }
650 < }      
651 <
652 < sub Use_start
653 <   {
654 <   my $self=shift;
655 <   my $name=shift;
656 <   my $hashref=shift;
657 <   my $filename;
658 <   use Utilities::SCRAMUtils;
126 > sub export()
127 >   {
128 >   $self->pushlevel(); # Set nested to 1;
129 >   }
130  
131 <   $self->verbose(">> Use_start: NM ".$name." <<");
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 <   $self->{switch}->checktag($name, $hashref, "name");
148 <   if ( $self->{Arch} )
147 >   my $libname;
148 >  
149 >   if (exists($attributes{'position'}))
150        {
151 <      if ( exists $$hashref{'group'} )
151 >      if ($attributes{'position'} eq 'first')
152           {
153 <         print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
153 >         $libname = "F:".$attributes{'name'};
154           }
155 <      if ( ! defined $self->{remoteproject} )
155 >      else
156           {
157 <         $filename=SCRAMUtils::checkfile("/$ENV{INTsrc}/$$hashref{name}/BuildFile");
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 <         $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
676 <         print "Trying $filename\n";
677 <         if ( ! -f $filename ) { $filename=""; };
298 >         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
299           }
300 <      if ( $filename ne "" )
300 >      }
301 >   else
302 >      {
303 >      if (exists ($self->{content}->{FLAGS}->{$flagname}))
304           {
305 <         $self->ParseBuildFile_Export( $filename );
305 >         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
306           }
307        else
308           {
309 <         $self->{switch}->parseerror("Unable to detect Appropriate ".
686 <                                     "decription file for <$name name=".$$hashref{name}.">");
309 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
310           }
311        }
312     }
313  
314 < sub CheckBuildFile {
315 <         my $self=shift;
316 <         my $classdir=shift;
317 <         my $ClassName="";
318 <         my $thisfile="$classdir/$buildfile";
319 <        
697 <         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
698 <            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
699 <            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
700 <         }
701 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
702 <            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
703 <            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
704 <         }
705 <         $self->verbose(">> CheckBuildFile: FN ".$thisfile." CN ".$ClassName." <<");
706 <         return $ClassName;
707 < }
708 <
709 < # List association groups between <AssociateGroup> tags
710 < # seperated by newlines or spaces
711 < sub AssociateGroup {
712 <        my $self=shift;
713 <        my $name=shift;
714 <        my $string=shift;
715 <        my $word;
716 <
717 <        $self->verbose(">> AssociateGroup: NM ".$name." ST ".$string." <<");
718 <        
719 <        if ( $self->{Arch} ) {
720 <        foreach $word ( (split /\s/, $string) ){
721 <                chomp $word;
722 <                next if /^#/;
723 <                if ( $word=~/none/ ) {
724 <                        $self->{ignore}=1;
725 <                }
726 <        }
727 <        }
728 < }
729 <
730 < sub Arch_Start {
731 <        my $self=shift;
732 <        my $name=shift;
733 <        my $hashref=shift;
734 <
735 <        $self->verbose(">> Arch_Start: NM ".$name." <<");
736 <        
737 <        $self->{switch}->checktag($name, $hashref,'name');
738 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
739 <                                                : ($self->{Arch}=0);
740 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
741 < }
742 <
743 < sub Arch_End {
744 <        my $self=shift;
745 <        my $name=shift;
746 <        
747 <        $self->verbose(">> Arch_End: NM ".$name." <<");
748 <
749 <        pop @{$self->{ARCHBLOCK}};
750 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
751 < }
752 <
753 < # Split up the Class Block String into a useable array
754 < sub _CutBlock {
755 <    my $self=shift;
756 <    my $string= shift @_;
757 <
758 <    $self->verbose(">> _CutBlock: ST ".$string." <<");
759 <    
760 <    @BlockClassA = split /\//, $string;
761 < }
762 <
763 < sub OutToMakefile {
764 <        my $self=shift;
765 <        my $name=shift;
766 <        my @vars=@_;
767 <        
768 <        $self->verbose(">> OutToMakefile: <<");
769 <
770 <        if ( $self->{Arch} ) {
771 <          $self->verbose(">> CONT: ".$#vars." lines <<");
772 <          print GNUmakefile @vars;
773 <        }
774 < }
775 <
776 < sub OutToScreen {
777 <        my $name=shift;
778 <        my @vars=@_;
779 <        
780 <        if ( $self->{Arch} ) {
781 <          print @vars;
782 <        }
783 < }
784 < sub setBlockClassPath {
785 <        my $self=shift;
786 <        my $name=shift;
787 <        my $hashref=shift;
788 <
789 <        $self->verbose(">> setBlockClassPath: NM ".$name." <<");
790 <        
791 <        $self->{switch}->checktag($name, $hashref, 'path');
792 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
793 <        $self->_CutBlock($$hashref{path});
794 < }
795 <
796 < sub BlockClassPath {
797 <        my $self=shift;
798 <
799 <        $self->verbose(">> BlockClassPath: <<");
800 <
801 <        return $self->{BlockClassPath};
802 < }
803 <
804 < sub export_start_export {
805 <        my $self=shift;
806 <        my $name=shift;
807 <        my $hashref=shift;
808 <
809 <        $self->verbose(">> export_start_export: NM ".$name." <<");
810 <        
811 <        $self->{switch}->opengroup("__export");
812 < }
813 <
814 < sub export_start {
815 <        my $self=shift;
816 <        my $name=shift;
817 <        my $hashref=shift;
818 <
819 <        $self->verbose(">> export_start: NM ".$name." <<");
820 <        
821 <        $self->{switch}->opengroup("__export");
822 <        if ( exists $$hashref{autoexport} ) {
823 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
824 <          if ( $$hashref{autoexport}=~/true/ ) {
825 <           $self->{switch}->allowgroup("__export","makebuild");
826 <          }
827 <          else {
828 <           $self->{switch}->disallowgroup("__export","makebuild");
829 <          }
830 <        }
831 <        # -- allow default setting from other makefiles
832 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
833 < }
834 <
835 < sub export_end_export {
836 <        my $self=shift;
837 <        $self->verbose(">> export_end_export: <<");
838 <        $self->{switch}->closegroup("__export");
839 < }
840 <
841 < sub export_end {
842 <        my $self=shift;
843 <        $self->verbose(">> export_end: <<");
844 <        $self->{switch}->closegroup("__export");
845 <        print GNUmakefile "endif\n";
846 < }
314 > sub allflags()
315 >   {
316 >   my $self=shift;
317 >   # Return hash data for flags:
318 >   return $self->{content}->{FLAGS};
319 >   }
320  
321 < #
849 < # Standard lib tag
850 < #
851 < sub lib_start
321 > sub archspecific()
322     {
323     my $self=shift;
854   my $name=shift;
855   my $hashref=shift;
324    
325 <   $self->verbose(">> lib_start: NM ".$name." <<");
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 >            }
334 >         }
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 <   $self->{switch}->checktag($name, $hashref, 'name');
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 <   if ( $self->{Arch} )
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 <      print GNUmakefile "lib+=$$hashref{name}\n";
586 >      return 0;
587        }
588     }
589  
590 < #
591 < # libtype specification
592 < #
593 < sub LibType_Start {
594 <        my $self=shift;
595 <        my $name=shift;
596 <        my $hashref=shift;
597 <        
598 <        $self->verbose(">> LibType_Start: NM ".$name." <<");
599 <        
600 <        if ( $self->{Arch} ) {
601 <        if ( defined $self->{libtype_conext} ) {
602 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
603 <                " without a </$name> tag to close previous context");
604 <        }
605 <        else {
606 <        $self->{libtype_conext}=1;
607 <        $self->{switch}->checktag($name, $hashref, 'type');
608 <        
609 <        print GNUmakefile "# Specify Library Type\n";
610 <        print GNUmakefile "DefaultLibsOff=yes\n";
611 <        if ( $$hashref{'type'}=~/^archive/i ) {
612 <          print GNUmakefile "LibArchive=true\n";
613 <        }
614 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
615 <          print GNUmakefile "LibDebugArchive=true\n";
616 <        }
617 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
618 <          print GNUmakefile "LibDebugShared=true\n";
619 <        }
620 <        elsif ($$hashref{'type'}=~/shared/i ) {
621 <          print GNUmakefile 'LibShared=true'."\n";
622 <        }
623 <        print GNUmakefile "\n";
624 <        }
625 <        }
626 < }
627 <
628 < sub LibType_text {
629 <        my $self=shift;
630 <        my $name=shift;
631 <        my $string=shift;
632 <        $self->verbose(">> LibType_text: NM ".$name." <<");
633 <
634 <        if ( $self->{Arch} ) {
635 <          $string=~s/\n/ /g;
636 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
637 <          print GNUmakefile $string;
638 <          print GNUmakefile "\n";
639 <        }
640 < }
641 <
642 < sub LibType_end {
643 <        my $self=shift;
644 <        my $name=shift;
645 <
646 <        $self->verbose(">> LibType_end: NM ".$name." <<");
647 <
648 <        undef $self->{libtype_conext};
649 < }
650 <
651 < sub Environment_start {
652 <        my $self=shift;
653 <        my $name=shift;
654 <        my $hashref=shift;
655 <
656 <        $self->verbose(">> Environment_start: NM ".$name." <<");
657 <        
658 <        if ( $self->{Arch} ) {
659 <          $self->{envnum}++;
660 <
661 <          # open a new Environment File
662 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
940 <                $self->{envnum}.".mk";
941 <          use FileHandle;
942 <          my $fh=FileHandle->new();
943 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
944 <          push @{$self->{filehandlestack}}, $fh;
945 <          *GNUmakefile=$fh;
946 <
947 <          # include the approprate environment file
948 <          if ( $self->{envlevel} == 0 ) {
949 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
950 <                $self->{path}."/BuildFile.mk\n";
951 <          }
952 <          else {
953 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
954 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
955 <          }
956 <          $self->{envlevel}++;
957 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
958 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
959 <        }
960 < }
961 <
962 < sub Environment_end {
963 <        my $self=shift;
964 <        my $fd;
965 <
966 <        $self->verbose(">> Environment_end: NM ".$name." <<");
967 <
968 <        if ( $self->{Arch} ) {
969 <          $self->{envlevel}--;
970 <          if ( $self->{envlevel} < 0 ) {
971 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
972 <            exit 1;
973 <          }
974 <          close GNUmakefile;
975 <          # restore the last filehandle
976 <          $fd=pop @{$self->{filehandlestack}};
977 <          close $fd;
978 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
979 <          if ( $self->{envlevel} < 1 ) {
980 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
981 <                        "BuildFile.mk";
982 <          }
983 <          else {
984 <            $self->{currentenv}=
985 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
986 <                $self->{Envlevels}[$self->{envlevel}];
987 <          }
988 <        }
989 < }
990 <
991 < sub Store_start {
992 <        my $self=shift;
993 <        my $name=shift;
994 <        my $hashref=shift;
995 <
996 <        $self->verbose(">> Store_start: NM ".$name." <<");
997 <
998 <        if ( $self->{Arch} ) {
999 <          $self->{switch}->checktag( $name, $hashref, 'name' );
1000 <
1001 <          # -- store creation
1002 <          my $dir=$$hashref{'name'};
1003 <          AddDir::adddir($ENV{LOCALTOP}."/".$dir);
1004 <          if ( exists $$hashref{'type'} ) {
1005 <            # -- architecture specific store
1006 <            if ( $$hashref{'type'}=~/^arch/i ) {
1007 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
1008 <                AddDir::adddir($ENV{LOCALTOP}."/".$dir);
1009 <            }
1010 <            else {
1011 <                $self->parseerror("Unknown type in <$name> tag");
1012 <            }
1013 <          }
1014 <
1015 <          # -- set make variables for the store
1016 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
1017 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
1018 <                                        $ENV{LOCALTOP}."/".$dir."\n";
1019 <          print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
1020 <                        ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
1021 <        }
1022 < }
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