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.8 by williamc, Fri Sep 29 06:45:51 2000 UTC vs.
Revision 1.13 by williamc, Wed Nov 15 14:49:22 2000 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(ConfigArea)
5 > # new(toolbox)
6   # ParseBuildFile($base,$path,$file)
7   # ParseBuildFileExport(filename)
8 # blockparse(Block) : perform a parse to modify the block
8   # BlockClassPath() : Return the class path
9   # 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
10  
11   package BuildSystem::BuildFile;
12   use ActiveDoc::SimpleDoc;
# Line 25 | Line 21 | sub new {
21          my $class=shift;
22          my $self={};
23          bless $self, $class;
24 <        $self->{area}=shift;
29 <        $self->{toolbox}=$self->{area}->toolbox();
30 <        $self->{localtop}=$self->{area}->location();
24 >        $self->{toolbox}=shift;
25          $self->{Arch}=1;
26          push @{$self->{ARCHBLOCK}}, $self->{Arch};
27          return $self;
28   }
29  
36 sub buildfile {
37        my $self=shift;
38        if ( @_ ) {
39          $self->{buildfile}=shift;
40        }
41        return $self->{buildfile};
42 }
43
44 sub makefile {
45        my $self=shift;
46        if ( @_ ) {
47          $self->{makefile}=shift;
48        }
49        return $self->{makefile};
50 }
51
52 sub blockparse {
53        my $self=shift;
54        $self->{block}=shift;
55
56        $self->{switch}=$self->_initswitcher();
57        $self->_initblockparse($self->{switch});
58 }
59
30   sub ignore {
31          my $self=shift;
32          return (defined $self->{ignore})?$self->{ignore}:0;
# Line 69 | Line 39 | sub _initswitcher {
39          $switch->newparse($parse);
40          $switch->addignoretags($parse);
41          $self->_commontags($switch,$parse);
42 <        #$switch->addtag($parse,"Build", \&Build_start, $self);
42 >        $switch->addtag($parse,"Build", \&Build_start, $self);
43          $switch->addtag($parse,"none",
44                                          \&OutToMakefile,$self,
45                                          \&OutToMakefile, $self,
# Line 78 | Line 48 | sub _initswitcher {
48                                          \&Bin_start,$self,
49                                          \&OutToScreen, $self,
50                                          "", $self);
51 <        $switch->addtag($parse,"ProductStore",
52 <                                        \&Store_start,$self,
53 <                                        "", $self,
54 <                                        "", $self);
51 >         $switch->addtag($parse,"ProductStore",
52 >                                        \&Store_start,$self,
53 >                                        "", $self,
54 >                                        "", $self);
55          $switch->addtag($parse,"LibType",
56                                          \&LibType_Start,$self,
57                                          \&LibType_text, $self,
# Line 109 | Line 79 | sub _initswitcher {
79          return $switch;
80   }
81  
112 sub _initblockparse {
113        my $self=shift;
114        my $switch=shift;
115
116        my $parse="block";
117        $switch->newparse($parse);
118        $switch->addignoretags($parse);
119        $switch->addtag($parse,"DropDown",
120                                        \&DropDown_start,$self,
121                                        "", $self,
122                                        "", $self);
123        $switch->addtag($parse,"Build", \&Build_start, $self);
124 }
125
82   sub _commontags {
83          my $self=shift;
84          my $switch=shift;
# Line 155 | Line 111 | sub _commontags {
111          return $switch;
112   }
113  
158 sub GenerateMakefile {
159        my $self=shift;
160        my $infile=shift;
161        my $outfile=shift;
162
163        $self->{switch}=$self->_initswitcher();
164        $self->{switch}->filetoparse($infile);
165
166        # open a temporary gnumakefile to store output.
167        my $fh=FileHandle->new();
168        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
169                                                                "$!\n";
170        @{$self->{filehandlestack}}=($fh);
171
172        #  -- make an alias
173        *GNUmakefile=$fh;
174        if ( -e $ENV{LatestBuildFile} ) {
175          print GNUmakefile "include $ENV{LatestBuildFile}\n";
176        }
177        $self->{switch}->parse("makebuild"); # sort out supported tags
178        close GNUmakefile;
179        return $outfile;
180 }
181
114   sub ParseBuildFile {
115          my $self=shift;
116          my $base=shift;
# Line 196 | Line 128 | sub ParseBuildFile {
128          $numbins=0;
129          $self->{envnum}=0;
130          $self->{envlevel}=0;
131 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
131 >        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
132                                                                  "BuildFile.mk";
201        $self->{currentenv}=$self->{makefile};
133          $self->{switch}=$self->_initswitcher();
134          $self->{switch}->filetoparse($fullfilename);
135  
136   #       $self->{switch}->{Strict_no_cr}='no';
137          #open a temporary gnumakefile to store output.
138          use Utilities::AddDir;
139 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
140 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
141 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
142 < }
143 <
144 < sub classname {
145 <        my $self=shift;
146 <        if ( @_ ) {
147 <          $self->{classname}=shift;
139 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
140 >        my $fh=FileHandle->new();
141 >        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
142 >          ) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
143 >        @{$self->{filehandlestack}}=($fh);
144 >        # make an alias
145 >        *GNUmakefile=$fh;
146 >        if ( -e $ENV{LatestBuildFile} ) {
147 >          print GNUmakefile "include $ENV{LatestBuildFile}\n";
148 >        }
149 > #       print "writing to :\n".
150 > #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
151 >        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
152 >        $self->{switch}->parse("makebuild"); # sort out supported tags
153 >        if ( $numbins > 0 ) {
154 >         print GNUmakefile <<ENDTEXT;
155 > ifndef BINMODE
156 > help::
157 > \t\@echo Generic Binary targets
158 > \t\@echo ----------------------
159 > endif
160 > ENDTEXT
161 >         foreach $target ( keys %$targettypes ) {
162 >         print GNUmakefile <<ENDTEXT;
163 > ifndef BINMODE
164 > help::
165 > \t\@echo $target
166 > endif
167 > ENDTEXT
168 >         }
169          }
170 <        return $self->{classname};
170 >        close GNUmakefile;
171   }
172  
173   sub ParseBuildFile_Export {
174          my $self=shift;
175          my $filename=shift;
176 <        my $bf=BuildSystem::BuildFile->new($self->{area});
176 >        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
177          if ( defined $self->{remoteproject} ) {
178             $bf->{remoteproject}=$self->{remoteproject};
179          }
# Line 297 | Line 249 | sub Class_StartTag {
249          
250          if ( $self->{Arch} ) {
251           if ( defined $$hashref{'type'} ) {
252 <                $self->classname($$hashref{'type'});
252 >                $ClassName=$$hashref{'type'};
253           }
254          }
255   }
# Line 323 | Line 275 | sub Build_start {
275          my $hashref=shift;
276  
277          $self->{switch}->checktag($name,$hashref,'class');
326        $self->{switch}->checktag($name,$hashref,'id');
278          if ( $self->{Arch} ) {
279  
280            # -- determine the build products name
# Line 371 | Line 322 | sub Build_start {
322              # -- create a new directory for each type
323              push @targets, $pattern;
324              my $dirname=$$hashref{'class'}."_".$type."_".$name;
325 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
325 >            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
326              my $makefile=$here."/BuildFile.mk";
327   #           AddDir::adddir($here);
328  
# Line 394 | Line 345 | sub Build_start {
345              print $fh "\t cd $dirname; \\\n";
346              print $fh "\t echo include ".$self->{currentenv}." > ".
347                                                          "$makefile; \\\n";
348 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
348 >            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
349                                          " >> $makefile; \\\n";
350              print $fh "\t echo buildname=$name >> $makefile;\\\n";
351              print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
# Line 460 | Line 411 | sub Bin_start {
411  
412          # Create a new directory for each binary target
413          my $dirname="bin_".$$hashref{name};
414 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
414 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
415          open (binGNUmakefile,
416 <           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
416 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
417             "BuildFile.mk $!\n";
418  
419          # Create the link targets
# Line 478 | Line 429 | endif
429   ifndef BINMODE
430  
431   define stepdown_$$hashref{'name'}
432 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
433 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
434 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
432 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
433 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
434 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
435   fi
436   endef
437  
438   define stepdown2_$$hashref{'name'}
439 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
440 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
441 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
439 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
440 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
441 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
442   fi
443  
444   endef
# Line 511 | Line 462 | ENDTEXT
462  
463   # the binary specifics makefile
464          print binGNUmakefile "include ".$self->{currentenv}."\n";
465 <        print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n";
465 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
466  
467   # alias for bin_Insure
468          print binGNUmakefile <<ENDTEXT;
# Line 706 | Line 657 | sub Use_start {
657          }
658   }
659  
660 + sub CheckBuildFile {
661 +         my $self=shift;
662 +         my $classdir=shift;
663 +         my $ClassName="";
664 +         my $thisfile="$classdir/$buildfile";
665 +
666 +         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
667 +            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
668 +            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
669 +         }
670 +         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
671 +            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
672 +            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
673 +         }
674 +         return $ClassName;
675 + }
676 +
677   # List association groups between <AssociateGroup> tags
678   # seperated by newlines or spaces
679   sub AssociateGroup {
# Line 901 | Line 869 | sub Environment_start {
869            $self->{envnum}++;
870  
871            # open a new Environment File
872 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
872 >          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
873                  $self->{envnum}.".mk";
874            use FileHandle;
875            my $fh=FileHandle->new();
# Line 911 | Line 879 | sub Environment_start {
879  
880            # include the approprate environment file
881            if ( $self->{envlevel} == 0 ) {
882 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
882 >             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
883                  $self->{path}."/BuildFile.mk\n";
884            }
885            else {
886 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
886 >             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
887                  $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
888            }
889            $self->{envlevel}++;
890            $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
891 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
891 >          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
892          }
893   }
894  
# Line 940 | Line 908 | sub Environment_end {
908            close $fd;
909            *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
910            if ( $self->{envlevel} < 1 ) {
911 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
911 >            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
912                          "BuildFile.mk";
913            }
914            else {
915              $self->{currentenv}=
916 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
916 >             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
917                  $self->{Envlevels}[$self->{envlevel}];
918            }
919          }
920   }
921  
922   sub Store_start {
923 <        my $self=shift;
924 <        my $name=shift;
923 >        my $self=shift;
924 >        my $name=shift;
925          my $hashref=shift;
926  
927 <        if ( $self->{Arch} ) {
928 <          $self->{switch}->checktag( $name, $hashref, 'name' );
927 >        if ( $self->{Arch} ) {
928 >          $self->{switch}->checktag( $name, $hashref, 'name' );
929  
930 <          # -- store creation
931 <          my $dir=$$hashref{'name'};
932 <          AddDir::adddir($self->{area}->location()."/".$dir);
933 <          if ( exists $$hashref{'type'} ) {
934 <            # -- architecture specific store
935 <            if ( $$hashref{'type'}=~/^arch/i ) {
936 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
937 <                AddDir::adddir($self->{area}->location()."/".$dir);
938 <            }
939 <            else {
940 <                $self->parseerror("Unknown type in <$name> tag");
941 <            }
942 <          }
943 <        
944 <          # -- set make variables for the store
945 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
946 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
947 <                                        $self->{localtop}."/".$dir."\n";
948 <          print GNUmakefile "VPATH+=".$self->{localtop}
949 <                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
950 <        }
930 >          # -- store creation
931 >          my $dir=$$hashref{'name'};
932 >          AddDir::adddir($ENV{LOCALTOP}."/".$dir);
933 >          if ( exists $$hashref{'type'} ) {
934 >            # -- architecture specific store
935 >            if ( $$hashref{'type'}=~/^arch/i ) {
936 >                $dir=$dir."/".$ENV{SCRAM_ARCH};
937 >                AddDir::adddir($ENV{LOCALTOP}."/".$dir);
938 >            }
939 >            else {
940 >                $self->parseerror("Unknown type in <$name> tag");
941 >            }
942 >          }
943 >
944 >          # -- set make variables for the store
945 >          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
946 >          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
947 >                                        $ENV{LOCALTOP}."/".$dir."\n";
948 >          print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
949 >                        ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
950 >        }
951   }
952  
985 sub DropDown {
986        my $self=shift;
987        my $name=shift;
988        my $hashref=shift;
989
990        if ( $self->{Arch} ) {
991          # - default values must always be specified
992          $self->{switch}->checktag( $name, $hashref, 'defaults' );
993          my @blockdirs=split /,/ , $$hashref{'defaults'};
994          $self->{block}->defaultblocks(@blockdirs);
995        }
996 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines