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.7 by williamc, Tue Sep 19 10:09:29 2000 UTC vs.
Revision 1.12 by williamc, Tue Nov 14 15:18:41 2000 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(ConfigArea)
5 > # new(ConfigArea,Builder)
6   # ParseBuildFile($base,$path,$file)
7   # ParseBuildFileExport(filename)
8 + # BlockParse(Block) : perform a parse to modify the block
9   # BlockClassPath() : Return the class path
10   # ignore()      : return 1 if directory should be ignored 0 otherwise
11 < # classname()   : get/set the associated class
12 < # buildfile()   : get/set BuildFile location
13 < # makefile()    : get the generated makefile
11 > # classname()   : get/set the associated class
12 > # buildfile()   : get/set BuildFile location
13 > # makefile()    : get the generated makefile
14  
15   package BuildSystem::BuildFile;
16   use ActiveDoc::SimpleDoc;
# Line 25 | Line 26 | sub new {
26          my $self={};
27          bless $self, $class;
28          $self->{area}=shift;
29 <        $self->{toolbox}=$self->{area}->toolbox();
30 <        $self->{localtop}=$self->{area}->location();
29 >        $self->{Builder}=shift;
30 >        $self->{toolbox}=$self->{area}->toolbox();
31 >        $self->{localtop}=$self->{area}->location();
32 >        # -- set RELEASTOP
33 >        my $rarea=$self->{area}->linkarea();
34 >        if ( ! defined $rarea ) {
35 >          $self->{releasetop}=$self->{localtop};
36 >        }
37 >        else {
38 >          $self->{releasetop}=$rarea->location();
39 >        }
40 >        $self->{releasetop}=$self->{area}->location();
41          $self->{Arch}=1;
42          push @{$self->{ARCHBLOCK}}, $self->{Arch};
43          return $self;
44   }
45  
46   sub buildfile {
47 <        my $self=shift;
48 <        if ( @_ ) {
49 <          $self->{buildfile}=shift;
50 <        }
51 <        return $self->{buildfile};
47 >        my $self=shift;
48 >        if ( @_ ) {
49 >          $self->{buildfile}=shift;
50 >        }
51 >        return $self->{buildfile};
52   }
53  
54   sub makefile {
55 <        my $self=shift;
56 <        if ( @_ ) {
57 <          $self->{makefile}=shift;
58 <        }
59 <        return $self->{makefile};
55 >        my $self=shift;
56 >        if ( @_ ) {
57 >          $self->{makefile}=shift;
58 >        }
59 >        return $self->{makefile};
60 > }
61 >
62 > sub BlockParse {
63 >        my $self=shift;
64 >        $self->{block}=shift;
65 >
66 >        # -- set up the block parse
67 >        my $switch=$self->_initswitcher();
68 >        my $parse="block";
69 >        $switch->newparse($parse);
70 >        $switch->addignoretags($parse);
71 >        $switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self);
72 >        $switch->filetoparse($self->buildfile());
73 >
74 >        # -- parse away
75 >        $self->{switch}=$switch;
76 >        $switch->parse("block");
77 > }
78 >
79 > sub Parsetofh {
80 >        my $self=shift;
81 >        my $fh=shift;
82 >        $self->{buildblock}=shift;
83 >
84 >        # -- set up for parse
85 >        @{$self->{filehandlestack}}=($fh);
86 >        $self->{switch}->filetoparse($self->buildfile());
87 >        *GNUmakefile=$fh;
88 >
89 >        # -- generate makefile
90 >        $self->{switch}->parse("makebuild"); # sort out supported tags
91 >
92 >        # -- Clean up
93 >        close GNUmakefile;
94   }
95  
96   sub ignore {
# Line 60 | Line 105 | sub _initswitcher {
105          $switch->newparse($parse);
106          $switch->addignoretags($parse);
107          $self->_commontags($switch,$parse);
108 <        $switch->addtag($parse,"Build", \&Build_start, $self);
108 >        #$switch->addtag($parse,"Build", \&Build_start, $self);
109          $switch->addtag($parse,"none",
110                                          \&OutToMakefile,$self,
111                                          \&OutToMakefile, $self,
# Line 69 | Line 114 | sub _initswitcher {
114                                          \&Bin_start,$self,
115                                          \&OutToScreen, $self,
116                                          "", $self);
117 +         $switch->addtag($parse,"ProductStore",
118 +                                        \&Store_start,$self,
119 +                                        "", $self,
120 +                                        "", $self);
121          $switch->addtag($parse,"LibType",
122                                          \&LibType_Start,$self,
123                                          \&LibType_text, $self,
# Line 147 | Line 196 | sub GenerateMakefile {
196          if ( -e $ENV{LatestBuildFile} ) {
197            print GNUmakefile "include $ENV{LatestBuildFile}\n";
198          }
150        $ENV{LatestBuildFile}=$outfile;
199          $self->{switch}->parse("makebuild"); # sort out supported tags
200          close GNUmakefile;
201 +        return $outfile;
202   }
203  
204   sub ParseBuildFile {
# Line 170 | Line 219 | sub ParseBuildFile {
219          $self->{envnum}=0;
220          $self->{envlevel}=0;
221          $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
222 <                                                                "BuildFile.mk";
223 <        $self->{currentenv}=$self->{makefile};
222 >                                                                "BuildFile.mk";
223 >        $self->{currentenv}=$self->{makefile};
224          $self->{switch}=$self->_initswitcher();
225          $self->{switch}->filetoparse($fullfilename);
226  
227   #       $self->{switch}->{Strict_no_cr}='no';
228          #open a temporary gnumakefile to store output.
229          use Utilities::AddDir;
230 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
231 <        $self->GenerateMakefile($fullfilename,
232 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
230 >        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
231 >        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
232 >        $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
233   }
234  
235   sub classname {
236 <        my $self=shift;
237 <        if ( @_ ) {
238 <          $self->{classname}=shift;
239 <        }
240 <        return $self->{classname};
236 >        my $self=shift;
237 >        if ( @_ ) {
238 >          $self->{classname}=shift;
239 >        }
240 >        return $self->{classname};
241   }
242  
243   sub ParseBuildFile_Export {
244          my $self=shift;
245          my $filename=shift;
246 <        my $bf=BuildSystem::BuildFile->new($self->{area});
246 >        my $bf=BuildSystem::BuildFile->new($self->{area},$self->{Builder});
247          if ( defined $self->{remoteproject} ) {
248             $bf->{remoteproject}=$self->{remoteproject};
249          }
# Line 270 | Line 319 | sub Class_StartTag {
319          
320          if ( $self->{Arch} ) {
321           if ( defined $$hashref{'type'} ) {
322 <                $self->classname($$hashref{'type'});
322 >                 $self->classname($$hashref{'type'});
323           }
324          }
325   }
# Line 288 | Line 337 | sub IncludePath_Start {
337   }
338  
339   #
340 < # generic build tag
340 > # --- <Build class=> tag
341   #
342 +
343 + #
344 + # Parameter collection
345 + #
346 + sub BuildBlock_start {
347 +        my $self=shift;
348 +        my $name=shift;
349 +        my $hashref=shift;
350 +
351 +
352 +        my $blockobjid=$self->__blockobjid($hashref);
353 +
354 +        if ( $self->{Arch} ) {
355 +
356 +           # -- get any objects that match
357 +           my $inheritobj=$self->{block}->getobj($blockobjid);
358 +
359 +           # -- create an object with inherited properties
360 +           my $obj;
361 +           if ( ! defined $inheritobj ) {
362 +               # -- check we have a lookup for the class type
363 +               my $mapper=$self->_toolmapper();
364 +               if ( ! $mapper->exists($$hashref{'class'}) ) {
365 +                 $self->{switch}->parseerror("Unknown class : ".
366 +                                                        $$hashref{'class'});
367 +               }
368 +               $obj=BuildSystem::BuildClass->new();
369 +           }
370 +           else {
371 +               # -- inherit the properties from class with the same id class
372 +               $obj=$inheritobj->child();
373 +           }
374 +
375 +           # -- add changes from our tag
376 +           $obj->paramupdate($hashref);
377 +
378 +           # -- store the new object in the block
379 +           $self->{block}->setobj($obj,$blockobjid);
380 +        }
381 + }
382 +
383 + sub BuilderClass_buildmakefile {
384 +        my $self=shift;
385 +        my $name=shift;
386 +        my $hashref=shift;
387 +
388 +        my $blockobjid=$self->__blockobjid($hashref);
389 +
390 +        if ( $self->{Arch} ) {
391 +           # -- get the matching block object
392 +           my $blockobj=$self->{buildblock}->getobj($blockobjid);
393 +
394 +           # -- top level buildfile
395 +           my $fh=$self->{filehandlestack}[0];
396 +
397 +           # -- var initialisation
398 +           my @deftypes=();
399 +           my $buildname="";
400 +           my @types=$self->_toolmapper()->types($$hashref{'class'});
401 +
402 +           # -- error checking
403 +           if ( ! defined $blockobj->param("default") ) {
404 +             $self->error("No default build parameter defined for ".
405 +                $$hashref{'class'}." ".$$hashref{'id'});
406 +           }
407 +           if ( ! defined $blockobj->param("name") ) {
408 +             $self->error("\"name\" parameter defined for ".
409 +                $$hashref{'class'}." ".$$hashref{'id'});
410 +           }
411 +
412 +
413 +           foreach $param ( $blockobj->paramlist() ) {
414 +             # -- check for params that need special handling
415 +             if ( $param eq "default" ) {
416 +                @deftypes=split /,/, $param;
417 +             }
418 +             elsif ( $param eq "name" ) {
419 +                $buildname=$blockobj->param($param);
420 +             }
421 +             else {
422 +                # -- simple transfer of block object parameters to makefile
423 +                print $fh $param.":=".$blockobj->param($param)."\n";
424 +             }
425 +           }
426 +
427 +           # -- construct the targets in the top makefile
428 +           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
429 +           $self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types);
430 +        }
431 + }
432 +
433 + sub _blockobjid {
434 +        my $self=shift;
435 +        my $hashref=shift;
436 +
437 +        $self->{switch}->checktag($name,$hashref,'class');
438 +        $self->{switch}->checktag($name,$hashref,'id');
439 +        my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'};
440 +
441 +        return $blockobjid;
442 + }
443 +
444   sub Build_start {
445          my $self=shift;
446          my $name=shift;
447          my $hashref=shift;
448  
449          $self->{switch}->checktag($name,$hashref,'class');
450 +        $self->{switch}->checktag($name,$hashref,'id');
451          if ( $self->{Arch} ) {
452  
453            # -- determine the build products name
# Line 343 | Line 495 | sub Build_start {
495              # -- create a new directory for each type
496              push @targets, $pattern;
497              my $dirname=$$hashref{'class'}."_".$type."_".$name;
498 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
498 >            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
499              my $makefile=$here."/BuildFile.mk";
500   #           AddDir::adddir($here);
501  
# Line 366 | Line 518 | sub Build_start {
518              print $fh "\t cd $dirname; \\\n";
519              print $fh "\t echo include ".$self->{currentenv}." > ".
520                                                          "$makefile; \\\n";
521 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
521 >            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
522                                          " >> $makefile; \\\n";
523              print $fh "\t echo buildname=$name >> $makefile;\\\n";
524              print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
# Line 432 | Line 584 | sub Bin_start {
584  
585          # Create a new directory for each binary target
586          my $dirname="bin_".$$hashref{name};
587 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
587 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
588          open (binGNUmakefile,
589 <           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
589 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
590             "BuildFile.mk $!\n";
591  
592          # Create the link targets
# Line 450 | Line 602 | endif
602   ifndef BINMODE
603  
604   define stepdown_$$hashref{'name'}
605 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
606 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
607 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
605 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
606 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
607 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
608   fi
609   endef
610  
611   define stepdown2_$$hashref{'name'}
612 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
613 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
614 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
612 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
613 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
614 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
615   fi
616  
617   endef
# Line 483 | Line 635 | ENDTEXT
635  
636   # the binary specifics makefile
637          print binGNUmakefile "include ".$self->{currentenv}."\n";
638 <        print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n";
638 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
639  
640   # alias for bin_Insure
641          print binGNUmakefile <<ENDTEXT;
# Line 662 | Line 814 | sub Use_start {
814          if ( ! defined $self->{remoteproject} ) {
815            $filename=SCRAMUtils::checkfile(
816                  "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
817 +          # -- force a dependency check if local
818 +          if ( $filename=~/^$self->{localtop}/ ) {
819 +            $self->{Builder}->BuildDir($ENV{INTsrc}."/".$$hashref{'name'});
820 +          }
821          }
822          else {
823            $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
# Line 873 | Line 1029 | sub Environment_start {
1029            $self->{envnum}++;
1030  
1031            # open a new Environment File
1032 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
1032 >          my $envfile=$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
1033                  $self->{envnum}.".mk";
1034            use FileHandle;
1035            my $fh=FileHandle->new();
# Line 922 | Line 1078 | sub Environment_end {
1078            }
1079          }
1080   }
1081 +
1082 + sub Store_start {
1083 +        my $self=shift;
1084 +        my $name=shift;
1085 +        my $hashref=shift;
1086 +
1087 +        if ( $self->{Arch} ) {
1088 +          $self->{switch}->checktag( $name, $hashref, 'name' );
1089 +
1090 +          # -- store creation
1091 +          my $dir=$$hashref{'name'};
1092 +          AddDir::adddir($self->{localtop}."/".$dir);
1093 +          if ( exists $$hashref{'type'} ) {
1094 +            # -- architecture specific store
1095 +            if ( $$hashref{'type'}=~/^arch/i ) {
1096 +                $dir=$dir."/".$ENV{SCRAM_ARCH};
1097 +                AddDir::adddir($self->{localtop}."/".$dir);
1098 +            }
1099 +            else {
1100 +                $self->parseerror("Unknown type in <$name> tag");
1101 +            }
1102 +          }
1103 +
1104 +          # -- set make variables for the store
1105 +          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
1106 +          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
1107 +                                        $self->{localtop}."/".$dir."\n";
1108 +          print GNUmakefile "VPATH+=".$self->{localtop}
1109 +                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
1110 +        }
1111 + }
1112 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines