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.1 by williamc, Fri Dec 17 11:02:27 1999 UTC vs.
Revision 1.1.2.5 by williamc, Fri Apr 14 12:37:41 2000 UTC

# Line 1 | Line 1
1 < #
2 < # BuildFile.pm - An Active Document
3 < #
4 < # Originally Written by Christopher Williams
5 < #
6 < # Description
7 < # -----------
8 < # Parse a BuildFile to figure out the required build rules
1 > # BuildFile
2   #
3   # Interface
4   # ---------
5 < # new()         : A new BuildFile object
5 > # 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  
11   package BuildSystem::BuildFile;
12 < require 5.001;
13 < @ISA=qw(ActiveDoc)
12 > use ActiveDoc::SimpleDoc;
13 > use BuildSystem::ToolBox;
14 > require 5.004;
15 >
16 > BEGIN {
17 > $buildfile="BuildFile";
18 > }
19 >
20 > sub new {
21 >        my $class=shift;
22 >        my $self={};
23 >        bless $self, $class;
24 >        $self->{toolbox}=shift;
25 >        $self->{Arch}=1;
26 >        push @{$self->{ARCHBLOCK}}, $Arch;
27 >        return $self;
28 > }
29 >
30 > sub ignore {
31 >        my $self=shift;
32 >        return (defined $self->{ignore})?$self->{ignore}:0;
33 > }
34 >
35 > sub _initswitcher {
36 >        my $self=shift;
37 >        my $switch=ActiveDoc::SimpleDoc->new();
38 >        my $parse="makebuild";
39 >        $switch->newparse($parse);
40 >        $switch->addignoretags($parse);
41 >        $self->_commontags($switch,$parse);
42 >        $switch->addtag($parse,"none",
43 >                                        \&OutToMakefile,$self,
44 >                                        \&OutToMakefile, $self,
45 >                                        "", $self);
46 >        $switch->addtag($parse,"Bin",
47 >                                        \&Bin_start,$self,
48 >                                        \&OutToScreen, $self,
49 >                                        "", $self);
50 >        $switch->addtag($parse,"LibType",
51 >                                        \&LibType_Start,$self,
52 >                                        \&LibType_text, $self,
53 >                                        \&LibType_end,$self);
54 >        $switch->addtag($parse,"ConfigurationClass",
55 >                                        \&Class_StartTag,$self,
56 >                                        \&OutToMakefile, $self,
57 >                                        "", $self);
58 >        $switch->addtag($parse,"ClassPath",
59 >                                        \&setBlockClassPath,$self,
60 >                                        \&OutToMakefile, $self,
61 >                                        "", $self);
62 >        $switch->addtag($parse,"AssociateGroup",
63 >                                        "",$self,
64 >                                        \&AssociateGroup,$self,
65 >                                        "", $self);
66 >        $switch->addtag($parse,"Environment",
67 >                                        \&Environment_start,$self,
68 >                                        \&OutToMakefile, $self,
69 >                                        \&Environment_end,$self);
70 >        $switch->addtag($parse,"Export",
71 >                                        \&export_start,$self,
72 >                                        \&OutToMakefile, $self,
73 >                                        \&export_end,$self);
74 >        return $switch;
75 > }
76 >
77 > sub _commontags {
78 >        my $self=shift;
79 >        my $switch=shift;
80 >        my $parse=shift;
81 >
82 >        $switch->grouptag("Export",$parse);
83 >        $switch->addtag($parse,"Use",\&Use_start,$self,
84 >                                               \&OutToMakefile, $self,
85 >                                                "", $self);
86 >        $switch->addtag($parse,"Group",\&Group_start,$self,
87 >                                               \&OutToMakefile, $self,
88 >                                                "", $self);
89 >        $switch->grouptag("Group",$parse);
90 >        $switch->addtag($parse,"External",
91 >                                        \&External_StartTag,$self,
92 >                                        \&OutToMakefile, $self,
93 >                                        "", $self);
94 >        $switch->addtag($parse,"lib",
95 >                                        \&lib_start,$self,
96 >                                        \&OutToMakefile, $self,
97 >                                        "", $self);
98 >        $switch->addtag($parse,"Architecture",
99 >                                        \&Arch_Start,$self,
100 >                                        \&OutToMakefile, $self,
101 >                                        \&Arch_End,$self);
102 >        return $switch;
103 > }
104 >
105 > sub ParseBuildFile {
106 >        my $self=shift;
107 >        my $base=shift;
108 >        my $path=shift;
109 >        my $filename=shift @_;
110 >        my $fullfilename="$base/$path/$filename";
111 >        $self->{path}=$path;
112 >        #print "Processing $fullfilename\n";
113 >        $numbins=0;
114 >        $self->{envnum}=0;
115 >        $self->{envlevel}=0;
116 >        $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk";
117 >        $self->{switch}=$self->_initswitcher();
118 >        $self->{switch}->filetoparse($fullfilename);
119 >
120 > #       $self->{switch}->{Strict_no_cr}='no';
121 >        #open a temporary gnumakefile to store output.
122 >        use Utilities::AddDir;
123 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
124 >        my $fh=FileHandle->new();
125 >        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk"
126 >          ) or die 'Unable to open /$ENV{INTwork}/$self->{path}/BuildFile.mk $!\n';
127 >        @{$self->{filehandlestack}}=($fh);
128 >        # make an alias
129 >        *GNUmakefile=$fh;
130 >        if ( -e $ENV{LatestBuildFile} ) {
131 >          print GNUmakefile "include $ENV{LatestBuildFile}\n";
132 >        }
133 > #       print "writing to :\n".
134 > #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
135 >        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk";
136 >        $self->{switch}->parse("makebuild"); # sort out supported tags
137 >        if ( $numbins > 0 ) {
138 >         print GNUmakefile <<ENDTEXT;
139 > ifndef BINMODE
140 > help::
141 > \t\@echo Generic Binary targets
142 > \t\@echo ----------------------
143 > endif
144 > ENDTEXT
145 >         foreach $target ( keys %$targettypes ) {
146 >         print GNUmakefile <<ENDTEXT;
147 > ifndef BINMODE
148 > help::
149 > \t\@echo $target
150 > endif
151 > ENDTEXT
152 >         }
153 >        }
154 >        close GNUmakefile;
155 > }
156  
157 < sub init {
157 > sub ParseBuildFile_Export {
158          my $self=shift;
159 +        my $filename=shift;
160 +        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
161 +        if ( defined $self->{remoteproject} ) {
162 +           $bf->{remoteproject}=$self->{remoteproject};
163 +        }
164 +        $bf->_parseexport($filename);
165 +        undef $bf;
166 + }
167  
168 <        # set up our data structures
169 <        $self->{Benv}=BuildEnvironment->new();
170 <        # Specific tags
24 <        # environment tags
25 <        $self->{tags}->addtag("Environment", \&Environment_Start, "",
26 <                        \&Environment_End);
27 <        # bin tags
28 <        $self->{bincontext}=0;
29 <        $self->{tags}->addtag("bin", \&bin_Start, \&bin_text, \&bin_End);
168 > sub _parseexport {
169 >        my $self=shift;
170 >        my $filename=shift;
171  
172 <        $self->_addignore();
172 >        my $switchex=ActiveDoc::SimpleDoc->new();
173 >        $switchex->filetoparse($filename);
174 >        $switchex->newparse("export");
175 >        $switchex->addignoretags("export");
176 >        $switchex->addtag("export","Export",
177 >                                        \&export_start_export,$self,
178 >                                        \&OutToMakefile, $self,
179 >                                        \&export_end_export,$self);
180 >        $self->_commontags($switchex,"export");
181 >        $switchex->allowgroup("__export","export");
182 > #       $switchex->{Strict_no_cr}='no';
183 >        $self->{switch}=$switchex;
184 >        $switchex->parse("export"); # sort out supported tags
185   }
186  
187 < # --------------------- Support Routines ----
188 < sub _expandvars {
187 > sub _pushremoteproject {
188 >        my $self=shift;
189 >        my $path=shift;
190 >        
191 >        if ( defined $self->{remoteproject} ) {
192 >          push @{$self->{rpstack}}, $self->{remoteproject};
193 >        }
194 >        $self->{remoteproject}=$path;
195 > }
196 >
197 > sub _popremoteproject {
198 >        my $self=shift;
199 >        if ( $#{$self->{rpstack}} >=0 ) {
200 >          $self->{remoteproject}=pop @{$self->{rpstack}};
201 >        }
202 >        else {
203 >          undef $self->{remoteproject};
204 >        }
205 > }
206 >
207 > # ---- Tag routines
208 >
209 > #-- Override a class type with the <ConfigurationClass type=xxx> tag
210 > #   the type tag will pick up a pre-defined class type from project space.
211 >
212 > sub Class_StartTag {
213          my $self=shift;
214 <        my $string=shift;
214 >        my $name=shift;
215 >        my $hashref=shift;
216 >        
217 >        if ( $self->{Arch} ) {
218 >        if ( defined $$hashref{'type'} ) {
219 >                $ClassName=$$hashref{'type'};
220 >        }
221 >        }
222 > }
223 >
224 > sub Bin_start {
225 >        my $self=shift;
226 >        my $name=shift;
227 >        my $hashref=shift;
228  
229 <        # Deal with Use in the environment
229 >        my $fileclass;
230 >        my @tools;
231 >        my $tool;
232 >        my $filename;
233 >        my $objectname;
234          
235 <        # expand directly from the local build Env
236 <        $self->{Benv}->expandvars($string);
235 >        $self->{switch}->checktag($name,$hashref,'file');
236 >        if ( $self->{Arch} ) {
237 >        if ( ! defined $$hashref{name} ) {
238 >                ($$hashref{name}=$$hashref{file})=~s/\..*//;
239 >        }
240 >        # This stuff for later
241 >        #$fileclass=$toolbox->getclass($file);
242 >        #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
243 >
244 >        ($filename=$$hashref{file})=~s/\..*//;
245 >
246 >        # Create a new directory for each binary target
247 >        my $dirname="bin_".$$hashref{name};
248 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
249 >        open (binGNUmakefile,
250 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
251 >           "BuildFile.mk $!\n";
252 >
253 >        # Create the link targets
254 >        $numbins++;
255 >        my $fh=$self->{filehandlestack}[0];
256 >        print $fh <<ENDTEXT;
257 >
258 > # Link Targets to binary directories
259 > ifdef BINMODE
260 > # We dont want to build a library here
261 > override files:=
262 > endif
263 > ifndef BINMODE
264 >
265 > define stepdown_$$hashref{'name'}
266 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
267 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
268 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
269 > fi
270 > endef
271 >
272 > define stepdown2_$$hashref{'name'}
273 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
274 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
275 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
276 > fi
277 >
278 > endef
279 >
280 > bin_$$hashref{'name'}_%:: dummy
281 >        \@\$(stepdown2_$$hashref{'name'})
282 >
283 > $$hashref{'name'}_%:: dummy
284 >        \@\$(stepdown_$$hashref{'name'})
285 >
286 > help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
287 >        \@\$(stepdown_$$hashref{'name'})
288 >
289 > binfiles+=$$hashref{'file'}
290 > locbinfiles+=$dirname/$$hashref{'file'}
291 > endif
292 >
293 >
294 > ENDTEXT
295 >
296 >
297 > # the binary specifics makefile
298 >        print binGNUmakefile "include $currentenv\n";
299 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
300 >
301 > # alias for bin_Insure
302 >        print binGNUmakefile <<ENDTEXT;
303 >
304 > bin_insure:bin_Insure
305 > ifdef MAKETARGET_bin_insure
306 > MAKETARGET_$$hashref{name}_Insure=1
307 > endif
308 >
309 > # debuggging target
310 > $$hashref{'name'}_echo_% :: echo_%
311 >
312 > # help targets
313 > help::
314 > \t\@echo Targets For $$hashref{'name'}
315 > \t\@echo -------------------------------------
316 > \t\@echo $$hashref{'name'}  - default build
317 > \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
318 > ENDTEXT
319 >
320 > # Make generic rules for each type
321 >        $targettypes={
322 >                "bin" => 'o',
323 >                "bin_debug" => 'd',
324 >                "bin_debug_local" => 'l_d',
325 >                "bin_Insure" => 'Insure'
326 >        };
327 >        #
328 >        foreach $target ( keys %$targettypes ) {
329 >          print binGNUmakefile <<ENDTEXT;
330 >
331 > # Type $target specifics
332 > ifdef MAKETARGET_$target
333 > MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
334 > endif
335 > $target ::$$hashref{name}_$$targettypes{$target}
336 >
337 > bintargets+=$$hashref{name}_$$targettypes{$target}
338 > help::
339 > \t\@echo $$hashref{name}_$$targettypes{$target}
340 > clean::
341 > \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
342 > \techo Removing \$(binarystore)/$$hashref{name}; \\
343 > \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
344 > \tfi
345 >
346 > ENDTEXT
347 >          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
348 >          ${"objectname_$$targettypes{$target}"}=$objectname;
349 >          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
350 >        } # end loop
351 >
352 >        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
353 >        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
354 >        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
355 >        print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
356 >        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
357 >        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
358 >        print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
359 >        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
360 >        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
361 >        print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
362 >        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
363 >        print binGNUmakefile "\t\$(CClinkCmd)\n";
364 >        print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
365 >        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
366 >        print binGNUmakefile "-include $$hashref{name}.dep\n";
367 > print binGNUmakefile <<ENDTEXT;
368 > clean::
369 > \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
370 > \techo Removing \$(binarystore)/$$hashref{name}; \\
371 > \trm \$(binarystore)/$$hashref{name}; \\
372 > \tfi
373 >
374 > $$hashref{name}_d.exe:\$(libslocal_d)
375 > $$hashref{name}_o.exe:\$(libslocal)
376 > ifdef MCCABE_DATA_DIR
377 > $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
378 > endif
379 > $$hashref{name}_Insure.exe:\$(libslocal_I)
380 > $$hashref{name}_d:$$hashref{name}_d.exe
381 >        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
382 > $$hashref{name}_l_d:$$hashref{name}_l_d.exe
383 >        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
384 > $$hashref{name}_Insure:$$hashref{name}_Insure.exe
385 >        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
386 > $$hashref{name}:$$hashref{name}_d.exe
387 >        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
388 > $$hashref{name}_o:$$hashref{name}_o.exe
389 >        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
390 > binfiles+=$$hashref{file}
391 > ENDTEXT
392 >        }
393 >        close binGNUmakefile;
394   }
395  
396 < # ------------------- Tag Routines ------------------------------
396 > sub External_StartTag {
397 >        my $self=shift;
398 >        my $name=shift;
399 >        my $hashref=shift;
400 >        
401 >        my $tool;
402 >        if ( $self->{Arch} ) {
403 >        $self->{switch}->checktag($name,$hashref,'ref');
404 >
405 >        # -- oo toolbox stuff
406 >        # - get the appropriate tool object
407 >        $$hashref{'ref'}=~tr[A-Z][a-z];
408 >        if ( ! exists $$hashref{'version'} ) {
409 >         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
410 >        }
411 >        else {
412 >         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
413 >        }
414 >        if ( ! defined $tool ) {
415 >          $self->{switch}->parseerror("Unknown Tool Specified ("
416 >                                                        .$$hashref{'ref'}.")");
417 >        }
418 >
419 >        # -- old fashioned GNUmakefile stuff
420 >        print GNUmakefile $$hashref{'ref'};
421 >        if ( defined $$hashref{'version'} ) {
422 >                print GNUmakefile "_V_".$$hashref{'version'};
423 >        }
424 >        print GNUmakefile "=true\n";
425 >        
426 >        # -- Sub system also specified?
427 >        if ( exists $$hashref{'use'} ) {
428 >           # -- look for a buildfile
429 >           my @paths=$tool->getfeature("INCLUDE");
430 >           my $file="";
431 >           my ($path,$testfile);
432 >           foreach $path ( @paths ) {
433 >             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
434 >             if ( -f $testfile ) {
435 >                $file=$testfile;
436 >                $self->_pushremoteproject($path);
437 >             }
438 >           }
439 >           if ( $file eq "" ) {
440 >             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
441 >           }
442 >           $self->ParseBuildFile_Export($file);
443 >           $self->_popremoteproject();
444 >         }
445 >        }
446 > }      
447  
448 < sub Environment_Start {
448 > sub Group_start {
449          my $self=shift;
450          my $name=shift;
451          my $hashref=shift;
452 +        
453 +        $self->{switch}->checktag($name, $hashref, 'name');
454 +        if ( $self->{Arch} ) {
455 +        print GNUmakefile "GROUP_".$$hashref{'name'};
456 +        if ( defined $$hashref{'version'} ) {
457 +                print GNUmakefile "_V_".$$hashref{'version'};
458 +        }
459 +        print GNUmakefile "=true\n";
460 +        }
461 + }      
462  
463 <        $self->{Benv}->newenv();
463 > sub Use_start {
464 >        my $self=shift;
465 >        my $name=shift;
466 >        my $hashref=shift;
467 >        my $filename;
468 >        use Utilities::SCRAMUtils;
469          
470 +        $self->{switch}->checktag($name, $hashref, "name");
471 +        if ( $self->{Arch} ) {
472 +        if ( ! defined $self->{remoteproject} ) {
473 +          $filename=SCRAMUtils::checkfile(
474 +                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
475 +        }
476 +        else {
477 +          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
478 +        print "trying $filename\n";
479 +          if ( ! -f $filename ) { $filename=""; };
480 +        }
481 +        if ( $filename ne "" ) {
482 +          $self->ParseBuildFile_Export( $filename );
483 +        }
484 +        else {
485 +           $self->{switch}->parseerror("Unable to detect Appropriate ".
486 +                "decription file for <$name name=".$$hashref{name}.">");
487 +        }
488 +        }
489   }
490  
491 < sub Environment_End {
492 <        my $self=shift;
491 > sub CheckBuildFile {
492 >         my $self=shift;
493 >         my $classdir=shift;
494 >         my $ClassName="";
495 >         my $thisfile="$classdir/$buildfile";
496 >
497 >         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
498 >            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
499 >            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
500 >         }
501 >         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
502 >            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
503 >            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
504 >         }
505 >         return $ClassName;
506 > }
507 >
508 > # List association groups between <AssociateGroup> tags
509 > # seperated by newlines or spaces
510 > sub AssociateGroup {
511 >        my $self=shift;
512 >        my $name=shift;
513 >        my $string=shift;
514 >        my $word;
515 >
516 >        foreach $word ( (split /\s/, $string) ){
517 >                chomp $word;
518 >                next if /^#/;
519 >                if ( $word=~/none/ ) {
520 >                        $self->{ignore}=1;
521 >                }
522 >        }
523 > }
524 >
525 > sub Arch_Start {
526 >        my $self=shift;
527          my $name=shift;
528          my $hashref=shift;
529  
530 <        $self->{Benv}->restoreenv();
530 >        $toolswitch->checktag($name, $hashref,'name');
531 >        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
532 >                                                : ($self->{Arch}=0);
533 >        push @{$self->{ARCHBLOCK}}, $self->{Arch};
534   }
535  
536 < sub Use_Start {
536 > sub Arch_End {
537          my $self=shift;
538          my $name=shift;
67        my $hashref=shift;
539  
540 <        # checks
541 <        $self->checktag($hashref, 'name' ,$name );
540 >        pop @{$self->{ARCHBLOCK}};
541 >        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
542 > }
543 >
544 > # Split up the Class Block String into a useable array
545 > sub _CutBlock {
546 >    my $self=shift;
547 >    my $string= shift @_;
548 >    @BlockClassA = split /\//, $string;
549 > }
550 >
551 > sub OutToMakefile {
552 >        my $self=shift;
553 >        my $name=shift;
554 >        my @vars=@_;
555 >
556 >        if ( $self->{Arch} ) {
557 >          print GNUmakefile @vars;
558 >        }
559 > }
560 >
561 > sub OutToScreen {
562 >        my $name=shift;
563 >        my @vars=@_;
564 >
565 >        if ( $self->{Arch} ) {
566 >          print @vars;
567 >        }
568 > }
569 > sub setBlockClassPath {
570 >        my $self=shift;
571 >        my $name=shift;
572 >        my $hashref=shift;
573  
574 <        $self->{Benv}->addparam('scram_use', $$hashref->{'name'});
575 <        $self->{Benv}->addparam('scram_use_group', $$hashref->{'group'});
574 >        $self->{switch}->checktag($name, $hashref, 'path');
575 >        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
576 >        $self->_CutBlock($$hashref{path});
577 > }
578 >
579 > sub BlockClassPath {
580 >        my $self=shift;
581 >        return $self->{BlockClassPath};
582   }
583  
584 < # ---- binary specific tags
585 < sub bin_Start {
584 > sub export_start_export {
585 >        my $self=shift;
586 >        my $name=shift;
587 >        my $hashref=shift;
588 >
589 >        $self->{switch}->opengroup("__export");
590 > }
591 >
592 > sub export_start {
593 >        my $self=shift;
594 >        my $name=shift;
595 >        my $hashref=shift;
596 >
597 >        $self->{switch}->opengroup("__export");
598 >        if ( exists $$hashref{autoexport} ) {
599 >          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
600 >          if ( $$hashref{autoexport}=~/true/ ) {
601 >           $self->{switch}->allowgroup("__export","makebuild");
602 >          }
603 >          else {
604 >           $self->{switch}->disallowgroup("__export","makebuild");
605 >          }
606 >        }
607 >        # -- allow default setting from other makefiles
608 >        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
609 > }
610 >
611 > sub export_end_export {
612 >        my $self=shift;
613 >        $self->{switch}->closegroup("__export");
614 > }
615 >
616 > sub export_end {
617 >        my $self=shift;
618 >        $self->{switch}->closegroup("__export");
619 >        print GNUmakefile "endif\n";
620 > }
621 >
622 > #
623 > # Standard lib tag
624 > #
625 > sub lib_start {
626          my $self=shift;
627          my $name=shift;
628          my $hashref=shift;
81        
82        my $extension;
629  
630 <        # checks
631 <        if ( $self->{bincontext} == 0 ) {
632 <          $self->{bincontext}=1;
633 <          $self->checktag($hashref, 'file' ,$name );
634 <          ($extension=$$hashref{file})=~s/.*\.//;
89 <          if ( ! defined $$hashref{name} ) {
90 <                ($$hashref{name}=$$hashref{file})=~s/\..*//;
91 <          }
630 >        $self->{switch}->checktag($name, $hashref, 'name');
631 >        if ( $self->{Arch} ) {
632 >           print GNUmakefile "lib+=$$hashref{name}\n";
633 >        }
634 > }
635  
636 <          push @{$self->{bins}}, $self->_expandvars(
637 <                $self->{Toolbox}->gettool($extension, "exe"));
636 > #
637 > # libtype specification
638 > #
639 > sub LibType_Start {
640 >        my $self=shift;
641 >        my $name=shift;
642 >        my $hashref=shift;
643 >
644 >        if ( $self->{Arch} ) {
645 >        if ( defined $self->{libtype_conext} ) {
646 >          $self->{switch}->parseerror("<$name> tag cannot be specified".
647 >                " without a </$name> tag to close previous context");
648          }
649          else {
650 <          $self->parseerror("Attempt to open a new <$name> before a </$name>");
650 >        $self->{libtype_conext}=1;
651 >        $self->{switch}->checktag($name, $hashref, 'type');
652 >        
653 >        print GNUmakefile "# Specify Library Type\n";
654 >        print GNUmakefile "DefaultLibsOff=yes\n";
655 >        if ( $$hashref{'type'}=~/^archive/i ) {
656 >          print GNUmakefile "LibArchive=true\n";
657 >        }
658 >        elsif ($$hashref{'type'}=~/debug_archive/i ) {
659 >          print GNUmakefile "LibDebugArchive=true\n";
660 >        }
661 >        elsif ($$hashref{'type'}=~/debug_shared/i ) {
662 >          print GNUmakefile "LibDebugShared=true\n";
663 >        }
664 >        elsif ($$hashref{'type'}=~/shared/i ) {
665 >          print GNUmakefile 'LibShared=true'."\n";
666 >        }
667 >        print GNUmakefile "\n";
668 >        }
669          }
670 < }
670 > }
671  
672 < sub bin_text {
672 > sub LibType_text {
673          my $self=shift;
674          my $name=shift;
675 <        my $string=shift;
675 >        my $string=shift;
676  
677 <        push @{$self->{binstext}}, $string;
677 >        if ( $self->{Arch} ) {
678 >          $string=~s/\n/ /g;
679 >          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
680 >          print GNUmakefile $string;
681 >          print GNUmakefile "\n";
682 >        }
683   }
684  
685 < sub bin_End {
685 > sub LibType_end {
686          my $self=shift;
687          my $name=shift;
688  
689 <        $self->{bincontext}=0;
689 >        undef $self->{libtype_conext};
690   }
691  
692 < sub lib_start {
692 > sub Environment_start {
693          my $self=shift;
694          my $name=shift;
695          my $hashref=shift;
696 +
697 +        if ( $self->{Arch} ) {
698 +          $self->{envnum}++;
699 +
700 +          # open a new Environment File
701 +          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
702 +                $self->{envnum}.".mk";
703 +          use FileHandle;
704 +          my $fh=FileHandle->new();
705 +          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
706 +          push @{$self->{filehandlestack}}, $fh;
707 +          *GNUmakefile=$fh;
708 +
709 +          # include the approprate environment file
710 +          if ( $self->{envlevel} == 0 ) {
711 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
712 +                $self->{path}."/BuildFile.mk\n";
713 +          }
714 +          else {
715 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
716 +                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
717 +          }
718 +          $self->{envlevel}++;
719 +          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
720 +          $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
721 +        }
722   }
723  
724 < # libray specific tags
123 < sub libtype {
724 > sub Environment_end {
725          my $self=shift;
726 <        my $name=shift;
727 <        my $hashref=shift;
726 >        my $fd;
727 >
728 >        if ( $self->{Arch} ) {
729 >          $self->{envlevel}--;
730 >          if ( $self->{envlevel} < 0 ) {
731 >            print "Too many </Environent> Tags on $self->{switch}->line()\n";
732 >            exit 1;
733 >          }
734 >          close GNUmakefile;
735 >          # restore the last filehandle
736 >          $fd=pop @{$self->{filehandlestack}};
737 >          close $fd;
738 >          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
739 >          if ( $self->{envlevel} < 1 ) {
740 >            $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk";
741 >          }
742 >          else {
743 >            $currentenv=
744 >             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
745 >                $self->{Envlevels}[$self->{envlevel}];
746 >          }
747 >        }
748   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines