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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines