ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
Revision: 1.1.2.30
Committed: Tue Aug 1 12:03:28 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_13_3
Changes since 1.1.2.29: +7 -1 lines
Log Message:
datestamp config added and seperate into seperate processes

File Contents

# User Rev Content
1 williamc 1.1.2.1 # BuildFile
2 williamc 1.1 #
3     # Interface
4     # ---------
5 williamc 1.1.2.26 # new(ConfigArea)
6 williamc 1.1.2.1 # 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 williamc 1.1.2.12 # CheckBuildFile(dir) : return the BuildFile if it exists
11 williamc 1.1
12     package BuildSystem::BuildFile;
13 williamc 1.1.2.1 use ActiveDoc::SimpleDoc;
14     use BuildSystem::ToolBox;
15     require 5.004;
16    
17     BEGIN {
18     $buildfile="BuildFile";
19     }
20 williamc 1.1
21 williamc 1.1.2.1 sub new {
22     my $class=shift;
23     my $self={};
24     bless $self, $class;
25 williamc 1.1.2.26 $self->{area}=shift;
26     $self->{toolbox}=$self->{area}->toolbox();
27 williamc 1.1.2.1 $self->{Arch}=1;
28 williamc 1.1.2.7 push @{$self->{ARCHBLOCK}}, $self->{Arch};
29 williamc 1.1.2.1 return $self;
30     }
31    
32     sub ignore {
33 williamc 1.1 my $self=shift;
34 williamc 1.1.2.1 return (defined $self->{ignore})?$self->{ignore}:0;
35     }
36 williamc 1.1
37 williamc 1.1.2.1 sub _initswitcher {
38     my $self=shift;
39     my $switch=ActiveDoc::SimpleDoc->new();
40     my $parse="makebuild";
41     $switch->newparse($parse);
42     $switch->addignoretags($parse);
43     $self->_commontags($switch,$parse);
44 williamc 1.1.2.11 $switch->addtag($parse,"Build", \&Build_start, $self);
45 williamc 1.1.2.1 $switch->addtag($parse,"none",
46     \&OutToMakefile,$self,
47     \&OutToMakefile, $self,
48     "", $self);
49     $switch->addtag($parse,"Bin",
50     \&Bin_start,$self,
51     \&OutToScreen, $self,
52     "", $self);
53     $switch->addtag($parse,"LibType",
54     \&LibType_Start,$self,
55     \&LibType_text, $self,
56 williamc 1.1.2.3 \&LibType_end,$self);
57 williamc 1.1.2.1 $switch->addtag($parse,"ConfigurationClass",
58     \&Class_StartTag,$self,
59     \&OutToMakefile, $self,
60     "", $self);
61     $switch->addtag($parse,"ClassPath",
62     \&setBlockClassPath,$self,
63     \&OutToMakefile, $self,
64     "", $self);
65     $switch->addtag($parse,"AssociateGroup",
66     "",$self,
67     \&AssociateGroup,$self,
68     "", $self);
69     $switch->addtag($parse,"Environment",
70     \&Environment_start,$self,
71     \&OutToMakefile, $self,
72     \&Environment_end,$self);
73     $switch->addtag($parse,"Export",
74     \&export_start,$self,
75     \&OutToMakefile, $self,
76     \&export_end,$self);
77     return $switch;
78     }
79 williamc 1.1
80 williamc 1.1.2.1 sub _commontags {
81     my $self=shift;
82     my $switch=shift;
83     my $parse=shift;
84    
85     $switch->grouptag("Export",$parse);
86     $switch->addtag($parse,"Use",\&Use_start,$self,
87     \&OutToMakefile, $self,
88     "", $self);
89     $switch->addtag($parse,"Group",\&Group_start,$self,
90     \&OutToMakefile, $self,
91     "", $self);
92     $switch->grouptag("Group",$parse);
93     $switch->addtag($parse,"External",
94     \&External_StartTag,$self,
95     \&OutToMakefile, $self,
96     "", $self);
97     $switch->addtag($parse,"lib",
98     \&lib_start,$self,
99 williamc 1.1.2.5 \&OutToMakefile, $self,
100 williamc 1.1.2.1 "", $self);
101     $switch->addtag($parse,"Architecture",
102     \&Arch_Start,$self,
103     \&OutToMakefile, $self,
104     \&Arch_End,$self);
105 williamc 1.1.2.6 $switch->addtag($parse,"INCLUDE_PATH",
106     \&IncludePath_Start,$self,
107     \&OutToMakefile, $self,
108     "",$self);
109 williamc 1.1.2.1 return $switch;
110 williamc 1.1 }
111    
112 williamc 1.1.2.12 sub GenerateMakefile {
113     my $self=shift;
114     my $infile=shift;
115     my $outfile=shift;
116    
117     $self->{switch}=$self->_initswitcher();
118     $self->{switch}->filetoparse($infile);
119    
120     # open a temporary gnumakefile to store output.
121     my $fh=FileHandle->new();
122     open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
123     "$!\n";
124     @{$self->{filehandlestack}}=($fh);
125    
126     # -- make an alias
127     *GNUmakefile=$fh;
128     if ( -e $ENV{LatestBuildFile} ) {
129     print GNUmakefile "include $ENV{LatestBuildFile}\n";
130     }
131     $ENV{LatestBuildFile}=$outfile;
132     $self->{switch}->parse("makebuild"); # sort out supported tags
133     close GNUmakefile;
134     }
135    
136 williamc 1.1.2.1 sub ParseBuildFile {
137 williamc 1.1 my $self=shift;
138 williamc 1.1.2.1 my $base=shift;
139     my $path=shift;
140     my $filename=shift @_;
141 williamc 1.1.2.11 my $fullfilename;
142     if ( $filename!~/^\// ) {
143     $fullfilename="$base/$path/$filename";
144     }
145     else {
146     $fullfilename=$filename;
147     }
148 williamc 1.1.2.1 $self->{path}=$path;
149     #print "Processing $fullfilename\n";
150     $numbins=0;
151     $self->{envnum}=0;
152     $self->{envlevel}=0;
153 williamc 1.1.2.11 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
154     "BuildFile.mk";
155 williamc 1.1.2.15 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
156 williamc 1.1.2.1
157 williamc 1.1.2.21 # open a temporary gnumakefile to store output.
158 williamc 1.1.2.1 use Utilities::AddDir;
159     AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
160 williamc 1.1.2.12 $self->GenerateMakefile($fullfilename,
161     $ENV{LOCALTOP}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
162 williamc 1.1.2.1 }
163    
164     sub ParseBuildFile_Export {
165     my $self=shift;
166     my $filename=shift;
167 williamc 1.1.2.26 my $bf=BuildSystem::BuildFile->new($self->{area});
168 williamc 1.1.2.1 if ( defined $self->{remoteproject} ) {
169     $bf->{remoteproject}=$self->{remoteproject};
170     }
171     $bf->_parseexport($filename);
172     undef $bf;
173     }
174 williamc 1.1
175 williamc 1.1.2.6 sub _location {
176     my $self=shift;
177     use File::Basename;
178    
179     return dirname($self->{switch}->filetoparse());
180     }
181    
182 williamc 1.1.2.1 sub _parseexport {
183     my $self=shift;
184     my $filename=shift;
185    
186     my $switchex=ActiveDoc::SimpleDoc->new();
187     $switchex->filetoparse($filename);
188     $switchex->newparse("export");
189     $switchex->addignoretags("export");
190     $switchex->addtag("export","Export",
191     \&export_start_export,$self,
192     \&OutToMakefile, $self,
193     \&export_end_export,$self);
194     $self->_commontags($switchex,"export");
195     $switchex->allowgroup("__export","export");
196     # $switchex->{Strict_no_cr}='no';
197     $self->{switch}=$switchex;
198     $switchex->parse("export"); # sort out supported tags
199     }
200    
201     sub _pushremoteproject {
202     my $self=shift;
203     my $path=shift;
204 williamc 1.1
205 williamc 1.1.2.1 if ( defined $self->{remoteproject} ) {
206     push @{$self->{rpstack}}, $self->{remoteproject};
207     }
208     $self->{remoteproject}=$path;
209     }
210    
211     sub _popremoteproject {
212     my $self=shift;
213     if ( $#{$self->{rpstack}} >=0 ) {
214     $self->{remoteproject}=pop @{$self->{rpstack}};
215     }
216     else {
217     undef $self->{remoteproject};
218     }
219 williamc 1.1 }
220    
221 williamc 1.1.2.11 sub _toolmapper {
222     my $self=shift;
223     if ( ! defined $self->{mapper} ) {
224     require BuildSystem::ToolMapper;
225     $self->{mapper}=BuildSystem::ToolMapper->new();
226     }
227 williamc 1.1.2.16 if ( @_ ) { #if a class is supplied then supply the map directly
228     my $class=shift;
229     return $self->{mapper}->getmap($class);
230     }
231 williamc 1.1.2.11 return $self->{mapper};
232     }
233    
234    
235 williamc 1.1.2.1 # ---- Tag routines
236 williamc 1.1
237 williamc 1.1.2.12 # -- Override a class type with the <ConfigurationClass type=xxx> tag
238     # the type tag will pick up a pre-defined class type from project space.
239 williamc 1.1.2.1
240     sub Class_StartTag {
241     my $self=shift;
242     my $name=shift;
243     my $hashref=shift;
244    
245     if ( $self->{Arch} ) {
246 williamc 1.1.2.11 if ( defined $$hashref{'type'} ) {
247 williamc 1.1.2.1 $ClassName=$$hashref{'type'};
248 williamc 1.1.2.11 }
249 williamc 1.1.2.1 }
250     }
251    
252 williamc 1.1.2.6 sub IncludePath_Start {
253     my $self=shift;
254     my $name=shift;
255     my $hashref=shift;
256    
257     $self->{switch}->checktag( $name, $hashref, 'path');
258     if ( $self->{Arch} ) {
259     print GNUmakefile "INCLUDE+=".$self->_location()."/".
260     $$hashref{'path'}."\n";
261     }
262     }
263    
264 williamc 1.1.2.11 #
265     # generic build tag
266     #
267     sub Build_start {
268     my $self=shift;
269     my $name=shift;
270     my $hashref=shift;
271    
272 williamc 1.1.2.21
273 williamc 1.1.2.11 $self->{switch}->checktag($name,$hashref,'class');
274     if ( $self->{Arch} ) {
275 williamc 1.1.2.21 my $fh=$self->{filehandlestack}[0];
276     # -- get the mapper object
277 williamc 1.1.2.16 my $mapper=$self->_toolmapper($$hashref{'class'});
278     if ( ! defined $mapper ) {
279 williamc 1.1.2.11 $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
280     }
281     else {
282 williamc 1.1.2.21 # -- get default types
283     my @deftypes;
284     if ( ! exists $$hashref{'default'} ) {
285     @deftypes=$mapper->defaulttypes();
286     }
287     else {
288     @deftypes=split /,/, $$hashref{'default'};
289 williamc 1.1.2.23 print $fh "# -- default override\n";
290     print $fh "Sorigdefault_".$$hashref{'class'}.":=".
291     "\$(Sdefault_".$$hashref{'class'}.")\n";
292     print $fh "Sdefault_".$$hashref{'class'}.":=\n\n";
293 williamc 1.1.2.21 }
294    
295     # -- no src parameter so it must be a default setting tag
296     if ( ! exists $$hashref{src} ) {
297     # -- general default setting
298     $self->{switch}->checktag($name,$hashref,'default');
299     $mapper->defaulttypes(@deftypes);
300     $self->_makegenerictargets($fh, $$hashref{'class'},@deftypes);
301     }
302     else {
303     $self->{switch}->checktag($name,$hashref,'src');
304     $self->{switch}->checktag($name,$hashref,'name');
305     my $name=$$hashref{'name'};
306     my @types=$mapper->types();
307 williamc 1.1.2.16
308 williamc 1.1.2.11
309     my @targets=();
310    
311 williamc 1.1.2.28 # -- set some variables
312 williamc 1.1.2.11 print $fh "ifndef _BuildLink_\n";
313 williamc 1.1.2.28 print $fh $$hashref{'class'}."_buildsrcfiles+=".$$hashref{'src'};
314    
315     # -- generate generic targets
316 williamc 1.1.2.21 push @targets, ($self->_makegenerictargets($fh,$$hashref{'class'},
317     @deftypes));
318 williamc 1.1.2.23 print $fh $$hashref{'class'}."::\$(Sdefault_".$$hashref{'class'}
319     .")\n";
320 williamc 1.1.2.21 print $fh "Sdefault_".$$hashref{'class'}."_".$$hashref{'name'}.
321     "=\$(addsuffix _".$$hashref{'name'}.",\$(Sdefault_".
322     $$hashref{'class'}."))\n";
323     print $fh $$hashref{'class'}."_".$$hashref{'name'}."::\$(".
324     "Sdefault_".$$hashref{'class'}."_".$$hashref{'name'}.")\n";
325 williamc 1.1.2.19 push @targets, $$hashref{'class'}."_".$$hashref{'name'};
326 williamc 1.1.2.11
327     # -- generate targets for each type
328     foreach $type ( @types ) {
329    
330     # -- generic name for each type
331     my $pattern=$$hashref{'class'}."_".$type;
332     my $dirname=$$hashref{'class'}."_".$type."_".$name;
333     print $fh "# ------ $pattern rules ---------------\n";
334     print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
335     "_".$type."_$name\n\n";
336    
337 williamc 1.1.2.12 # -- create a new directory rule for each type
338 williamc 1.1.2.11 push @targets, $pattern;
339 williamc 1.1.2.13 my $here="$ENV{LOCALTOP}/$ENV{INTwork}/\$(THISDIR)/".$dirname;
340 williamc 1.1.2.20 my $work=$ENV{INTwork}."/\$(THISDIR)/".$dirname;
341 williamc 1.1.2.11 my $makefile=$here."/BuildFile.mk";
342    
343     # -- create link targets to the directory
344     push @targets, $dirname;
345     print $fh "# -- Link Targets to $type directories\n";
346     print $fh "$dirname: make_$dirname\n";
347     print $fh "\t\@cd $here; \\\n";
348     print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
349 williamc 1.1.2.20 " workdir=$work ".
350 williamc 1.1.2.30 " -f \$(TOOL_HOME)/basics.mk datestamp_config; \\\n".
351     print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
352     " workdir=$work ".
353     " -f \$(TOOL_HOME)/basics.mk datestamp; \\\n".
354     print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
355     " workdir=$work ".
356     " -f \$(TOOL_HOME)/basics.mk \$\@; \n\n";
357 williamc 1.1.2.11
358     # -- write target to make makefile for each directory
359     print $fh "# -- Build target directories\n";
360     print $fh "make_$dirname:\n";
361 williamc 1.1.2.14 print $fh "\t\@if [ ! -f \"$makefile\" ]; then \\\n";
362 williamc 1.1.2.11 print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
363     print $fh "\t mkdir $here; \\\n";
364     print $fh "\t fi;\\\n";
365 williamc 1.1.2.15 #print $fh "\t echo include ".$self->{currentenv}." > ".
366     print $fh "\t echo include \$(SCRAM_CURRENTENV) > ".
367 williamc 1.1.2.11 "$makefile; \\\n";
368 williamc 1.1.2.15 print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".${THISPATH}.
369 williamc 1.1.2.11 " >> $makefile; \\\n";
370 williamc 1.1.2.18 print $fh "\t echo buildsrcfiles:=".$$hashref{'src'}.
371     " >> $makefile; \\\n";
372 williamc 1.1.2.11 print $fh "\t echo buildname=$name >> $makefile;\\\n";
373     print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
374 williamc 1.1.2.15 print $fh "\t echo ifdef DefaultBuildFile >> $makefile; \\\n";
375     print $fh "\t echo include \$(DefaultBuildFile) >> $makefile; \\\n";
376     print $fh "\t echo DefaultBuildFileIn=true >> $makefile; \\\n";
377     print $fh "\t echo endif >> $makefile; \\\n";
378 williamc 1.1.2.11 if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
379     foreach $f ( @file ) {
380     print $fh "\t echo -include $f >> $makefile; \\\n";
381     }
382     }
383     print $fh "\tfi\n";
384     print $fh "\n";
385     # print $typefile "$name :\n";
386     # print $typefile "\t\$(_quietbuild_)";
387     # print $typefile $mapper->template($$hashref{'class'},$type)."\n";
388     # print $typefile "\t\$(_quietstamp_)";
389     # print $typefile "$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
390    
391 williamc 1.1.2.15 # -- debug targets
392     print $fh "# -- debug targets\n";
393     print $fh $dirname."_echo_% : make_$dirname\n";
394     print $fh "\t\@cd $here; \n";
395     print $fh "\t\@\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
396 williamc 1.1.2.20 " workdir=$work ".
397 williamc 1.1.2.15 " -f \$(TOOL_HOME)/basics.mk ".
398     "echo_\$(subst ".$dirname."_echo_,,\$\@) ; \n\n";
399     push @targets, $dirname."_echo_VAR";
400    
401 williamc 1.1.2.11 # -- cleaning targets
402     push @targets, "clean_$dirname";
403     print $fh "# -- cleaning targets\n";
404     print $fh "clean::clean_$dirname\n";
405     print $fh "clean_".$dirname."::\n";
406     print $fh "\t\@if [ -d $here ]; then \\\n";
407 williamc 1.1.2.17 print $fh "\techo cleaning $dirname; \\\n";
408 williamc 1.1.2.11 print $fh "\tcd $here; \\\n";
409     print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
410 williamc 1.1.2.20 $work." _BuildLink_=1 -f ".
411 williamc 1.1.2.11 "\$(TOOL_HOME)/basics.mk clean; \\\n";
412     print $fh "\tfi\n\n";
413    
414    
415     }
416 williamc 1.1.2.23 # -- cleanup
417     print $fh "Sdefault_".$$hashref{'class'}.
418     ":=\$(Sorigdefault_".$$hashref{'class'}.")\n";
419 williamc 1.1.2.11 # -- help targets
420     print $fh "helpheader::\n";
421     print $fh "\t\@echo Targets available:\n";
422     print $fh "\t\@echo ------------------\n\n";
423     print $fh "help::helpheader\n";
424     foreach $target ( @targets ) {
425     print $fh "help::\n";
426     print $fh "\t\@echo $target\n"
427     }
428     print $fh "endif\n";
429     } # end else
430     }
431 williamc 1.1.2.21 }
432     }
433    
434     sub _makegenerictargets {
435     my $self=shift;
436     my $fh=shift;
437     my $class=shift;
438     my @deftypes=@_;
439    
440     my @targets=();
441     # -- generate generic targets
442     print $fh "# -- Generic targets\n";
443     push @targets, $class;
444     foreach $dtype ( @deftypes ) {
445     print $fh "Sdefault_".$class."+=".$class."_".$dtype."\n";
446     }
447 williamc 1.1.2.23 #print $fh $class."::\$(Sdefault_".$class.")\n";
448     print $fh "\n\n";
449 williamc 1.1.2.21 return @targets;
450 williamc 1.1.2.11 }
451    
452 williamc 1.1.2.1 sub Bin_start {
453 williamc 1.1 my $self=shift;
454     my $name=shift;
455     my $hashref=shift;
456    
457 williamc 1.1.2.1 my $fileclass;
458     my @tools;
459     my $tool;
460     my $filename;
461     my $objectname;
462 williamc 1.1
463 williamc 1.1.2.1 $self->{switch}->checktag($name,$hashref,'file');
464     if ( $self->{Arch} ) {
465 williamc 1.1.2.18 if ( ! defined $$hashref{name} ) {
466 williamc 1.1.2.1 ($$hashref{name}=$$hashref{file})=~s/\..*//;
467 williamc 1.1.2.18 }
468 williamc 1.1.2.19 ($filename=$$hashref{file})=~s/^\///; # make sure full paths dont work
469 williamc 1.1.2.22 my $arghash={ "class" => "bin",
470     "src" => $filename,
471     "name" => $$hashref{'name'}};
472     if ( exists $$hashref{'default'} ) {
473     $arghash->{'default'}=$$hashref{'default'};
474     }
475     $self->Build_start($name, $arghash);
476 williamc 1.1.2.1 }
477 williamc 1.1 }
478    
479 williamc 1.1.2.1 sub External_StartTag {
480     my $self=shift;
481     my $name=shift;
482     my $hashref=shift;
483    
484     my $tool;
485     if ( $self->{Arch} ) {
486     $self->{switch}->checktag($name,$hashref,'ref');
487    
488     # -- oo toolbox stuff
489     # - get the appropriate tool object
490     $$hashref{'ref'}=~tr[A-Z][a-z];
491     if ( ! exists $$hashref{'version'} ) {
492     $tool=$self->{toolbox}->gettool($$hashref{'ref'});
493     }
494     else {
495     $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
496     }
497     if ( ! defined $tool ) {
498     $self->{switch}->parseerror("Unknown Tool Specified ("
499     .$$hashref{'ref'}.")");
500     }
501    
502     # -- old fashioned GNUmakefile stuff
503     print GNUmakefile $$hashref{'ref'};
504     if ( defined $$hashref{'version'} ) {
505     print GNUmakefile "_V_".$$hashref{'version'};
506     }
507     print GNUmakefile "=true\n";
508    
509     # -- Sub system also specified?
510     if ( exists $$hashref{'use'} ) {
511     # -- look for a buildfile
512     my @paths=$tool->getfeature("INCLUDE");
513     my $file="";
514     my ($path,$testfile);
515     foreach $path ( @paths ) {
516     $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
517     if ( -f $testfile ) {
518     $file=$testfile;
519     $self->_pushremoteproject($path);
520     }
521     }
522     if ( $file eq "" ) {
523     $self->{switch}->parseerror("Unable to find SubSystem $testfile");
524     }
525     $self->ParseBuildFile_Export($file);
526     $self->_popremoteproject();
527     }
528     }
529     }
530    
531 williamc 1.1.2.25 sub Test_start {
532     my $self=shift;
533     my $name=shift;
534     my $hashref=shift;
535    
536     # -- make sure we have the test binary
537     $self->{switch}->checktag($name, $hashref, 'exe');
538     system($ENV{SCRAM_HOME}."/src/scram","build",$$hashref{'exe'});
539    
540     # -- a name for the test
541     $self->{switch}->checktag($name, $hashref, 'name');
542    
543     # -- set up a tester object
544     push @{$self->{testcontext}}, $$hashref{'name'};
545 williamc 1.1.2.27 my $tester=BuildSystem::Tester->new($self->{area});
546 williamc 1.1.2.25 if ( ! exists $self->{testers}{$$hashref{'name'}} ) {
547     $self->{testers}{$$hashref{'name'}}=$tester;
548     }
549     else {
550     $self->{switch}->parseerror("Second definition of $name "
551     .$$hashref{'name'});
552     }
553     }
554    
555     sub Test_end {
556     my $self=shift;
557     my $name=shift;
558     my $hashref=shift;
559    
560     my $tester=$self->{testers}{pop @{$self->{testcontext}}};
561     $tester->run();
562     }
563    
564 williamc 1.1.2.1 sub Group_start {
565     my $self=shift;
566     my $name=shift;
567     my $hashref=shift;
568    
569     $self->{switch}->checktag($name, $hashref, 'name');
570     if ( $self->{Arch} ) {
571     print GNUmakefile "GROUP_".$$hashref{'name'};
572     if ( defined $$hashref{'version'} ) {
573     print GNUmakefile "_V_".$$hashref{'version'};
574     }
575     print GNUmakefile "=true\n";
576     }
577     }
578    
579     sub Use_start {
580     my $self=shift;
581     my $name=shift;
582     my $hashref=shift;
583     my $filename;
584     use Utilities::SCRAMUtils;
585    
586     $self->{switch}->checktag($name, $hashref, "name");
587     if ( $self->{Arch} ) {
588 williamc 1.1.2.9 if ( exists $$hashref{'group'} ) {
589     print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
590     }
591 williamc 1.1.2.1 if ( ! defined $self->{remoteproject} ) {
592     $filename=SCRAMUtils::checkfile(
593     "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
594     }
595     else {
596     $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
597     print "trying $filename\n";
598     if ( ! -f $filename ) { $filename=""; };
599     }
600     if ( $filename ne "" ) {
601     $self->ParseBuildFile_Export( $filename );
602     }
603     else {
604     $self->{switch}->parseerror("Unable to detect Appropriate ".
605     "decription file for <$name name=".$$hashref{name}.">");
606     }
607     }
608     }
609    
610     sub CheckBuildFile {
611     my $self=shift;
612     my $classdir=shift;
613     my $ClassName="";
614     my $thisfile="$classdir/$buildfile";
615    
616     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
617     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
618     $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
619     }
620     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
621     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
622     $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
623     }
624     return $ClassName;
625     }
626    
627     # List association groups between <AssociateGroup> tags
628     # seperated by newlines or spaces
629     sub AssociateGroup {
630     my $self=shift;
631     my $name=shift;
632     my $string=shift;
633     my $word;
634    
635 williamc 1.1.2.29 if ( $self->{Arch} ) {
636 williamc 1.1.2.1 foreach $word ( (split /\s/, $string) ){
637     chomp $word;
638     next if /^#/;
639     if ( $word=~/none/ ) {
640     $self->{ignore}=1;
641     }
642 williamc 1.1.2.29 }
643 williamc 1.1.2.1 }
644     }
645    
646     sub Arch_Start {
647     my $self=shift;
648 williamc 1.1 my $name=shift;
649     my $hashref=shift;
650    
651 williamc 1.1.2.10 $self->{switch}->checktag($name, $hashref,'name');
652 williamc 1.1.2.1 ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
653     : ($self->{Arch}=0);
654     push @{$self->{ARCHBLOCK}}, $self->{Arch};
655 williamc 1.1 }
656    
657 williamc 1.1.2.1 sub Arch_End {
658 williamc 1.1 my $self=shift;
659     my $name=shift;
660    
661 williamc 1.1.2.1 pop @{$self->{ARCHBLOCK}};
662     $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
663     }
664 williamc 1.1
665 williamc 1.1.2.1 # Split up the Class Block String into a useable array
666     sub _CutBlock {
667     my $self=shift;
668     my $string= shift @_;
669     @BlockClassA = split /\//, $string;
670 williamc 1.1 }
671    
672 williamc 1.1.2.1 sub OutToMakefile {
673     my $self=shift;
674 williamc 1.1 my $name=shift;
675 williamc 1.1.2.1 my @vars=@_;
676 williamc 1.1
677 williamc 1.1.2.1 if ( $self->{Arch} ) {
678     print GNUmakefile @vars;
679 williamc 1.1 }
680 williamc 1.1.2.1 }
681    
682     sub OutToScreen {
683     my $name=shift;
684     my @vars=@_;
685    
686     if ( $self->{Arch} ) {
687     print @vars;
688 williamc 1.1 }
689 williamc 1.1.2.1 }
690     sub setBlockClassPath {
691     my $self=shift;
692     my $name=shift;
693     my $hashref=shift;
694    
695     $self->{switch}->checktag($name, $hashref, 'path');
696     $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
697     $self->_CutBlock($$hashref{path});
698     }
699 williamc 1.1
700 williamc 1.1.2.1 sub BlockClassPath {
701 williamc 1.1 my $self=shift;
702 williamc 1.1.2.1 return $self->{BlockClassPath};
703     }
704 williamc 1.1
705 williamc 1.1.2.1 sub export_start_export {
706     my $self=shift;
707     my $name=shift;
708     my $hashref=shift;
709    
710     $self->{switch}->opengroup("__export");
711 williamc 1.1 }
712    
713 williamc 1.1.2.1 sub export_start {
714 williamc 1.1 my $self=shift;
715 williamc 1.1.2.1 my $name=shift;
716     my $hashref=shift;
717 williamc 1.1
718 williamc 1.1.2.1 $self->{switch}->opengroup("__export");
719     if ( exists $$hashref{autoexport} ) {
720     print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
721     if ( $$hashref{autoexport}=~/true/ ) {
722     $self->{switch}->allowgroup("__export","makebuild");
723     }
724     else {
725     $self->{switch}->disallowgroup("__export","makebuild");
726     }
727     }
728     # -- allow default setting from other makefiles
729     print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
730     }
731    
732     sub export_end_export {
733     my $self=shift;
734     $self->{switch}->closegroup("__export");
735     }
736    
737     sub export_end {
738     my $self=shift;
739     $self->{switch}->closegroup("__export");
740     print GNUmakefile "endif\n";
741 williamc 1.1 }
742    
743 williamc 1.1.2.1 #
744     # Standard lib tag
745     #
746 williamc 1.1 sub lib_start {
747     my $self=shift;
748     my $name=shift;
749     my $hashref=shift;
750 williamc 1.1.2.1
751     $self->{switch}->checktag($name, $hashref, 'name');
752     if ( $self->{Arch} ) {
753     print GNUmakefile "lib+=$$hashref{name}\n";
754     }
755 williamc 1.1 }
756    
757 williamc 1.1.2.1 #
758     # libtype specification
759     #
760     sub LibType_Start {
761 williamc 1.1 my $self=shift;
762     my $name=shift;
763     my $hashref=shift;
764 williamc 1.1.2.1
765     if ( $self->{Arch} ) {
766 williamc 1.1.2.3 if ( defined $self->{libtype_conext} ) {
767     $self->{switch}->parseerror("<$name> tag cannot be specified".
768     " without a </$name> tag to close previous context");
769     }
770     else {
771     $self->{libtype_conext}=1;
772 williamc 1.1.2.1 $self->{switch}->checktag($name, $hashref, 'type');
773    
774 williamc 1.1.2.24 my $string=$$hashref{'type'};
775     # -- do some translation for backwards compatability
776     if ($$hashref{'type'}=~/debug_archive/i ) {
777     $string="archive_debug";
778 williamc 1.1.2.1 }
779     elsif ($$hashref{'type'}=~/debug_shared/i ) {
780 williamc 1.1.2.24 $string="shared_debug";
781 williamc 1.1.2.1 }
782 williamc 1.1.2.24 # -- call the Build defaults method
783     $self->Build_start($name, {"class" => "lib", "default" => $string });
784 williamc 1.1.2.1 }
785 williamc 1.1.2.3 }
786 williamc 1.1.2.1 }
787 williamc 1.1.2.3
788 williamc 1.1.2.1 sub LibType_text {
789     my $self=shift;
790     my $name=shift;
791     my $string=shift;
792    
793     if ( $self->{Arch} ) {
794 williamc 1.1.2.2 $string=~s/\n/ /g;
795 williamc 1.1.2.1 print GNUmakefile "libmsg::\n\t\@echo Library info: ";
796     print GNUmakefile $string;
797     print GNUmakefile "\n";
798     }
799 williamc 1.1.2.3 }
800    
801     sub LibType_end {
802     my $self=shift;
803     my $name=shift;
804    
805     undef $self->{libtype_conext};
806 williamc 1.1.2.1 }
807    
808     sub Environment_start {
809     my $self=shift;
810     my $name=shift;
811     my $hashref=shift;
812    
813     if ( $self->{Arch} ) {
814     $self->{envnum}++;
815    
816     # open a new Environment File
817     my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
818     $self->{envnum}.".mk";
819     use FileHandle;
820     my $fh=FileHandle->new();
821     open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
822     push @{$self->{filehandlestack}}, $fh;
823     *GNUmakefile=$fh;
824    
825     # include the approprate environment file
826     if ( $self->{envlevel} == 0 ) {
827     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
828     $self->{path}."/BuildFile.mk\n";
829     }
830     else {
831     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
832     $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
833     }
834     $self->{envlevel}++;
835     $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
836 williamc 1.1.2.11 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
837 williamc 1.1.2.1 }
838 williamc 1.1.2.15 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
839 williamc 1.1.2.1 }
840    
841     sub Environment_end {
842     my $self=shift;
843     my $fd;
844    
845     if ( $self->{Arch} ) {
846     $self->{envlevel}--;
847     if ( $self->{envlevel} < 0 ) {
848     print "Too many </Environent> Tags on $self->{switch}->line()\n";
849     exit 1;
850     }
851     close GNUmakefile;
852     # restore the last filehandle
853     $fd=pop @{$self->{filehandlestack}};
854     close $fd;
855     *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
856     if ( $self->{envlevel} < 1 ) {
857 williamc 1.1.2.11 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
858     "BuildFile.mk";
859 williamc 1.1.2.1 }
860     else {
861 williamc 1.1.2.11 $self->{currentenv}=
862 williamc 1.1.2.1 "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
863     $self->{Envlevels}[$self->{envlevel}];
864     }
865 williamc 1.1.2.15 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
866 williamc 1.1.2.1 }
867 williamc 1.1 }