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.9 by williamc, Fri Sep 29 10:32:18 2000 UTC vs.
Revision 1.14 by sashby, Wed Nov 7 19:49:37 2001 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();
31 <        # -- set RELEASTOP
32 <        my $rarea=$self->{area}->linkarea();
33 <        if ( ! defined $rarea ) {
34 <          $self->{releasetop}=$self->{localtop};
35 <        }
36 <        else {
37 <          $self->{releasetop}=$rarea->location();
38 <        }
39 <        $self->{releasetop}=$self->{area}->location();
24 >        $self->{toolbox}=shift;
25          $self->{Arch}=1;
26          push @{$self->{ARCHBLOCK}}, $self->{Arch};
27          return $self;
28   }
29  
45 sub buildfile {
46        my $self=shift;
47        if ( @_ ) {
48          $self->{buildfile}=shift;
49        }
50        return $self->{buildfile};
51 }
52
53 sub makefile {
54        my $self=shift;
55        if ( @_ ) {
56          $self->{makefile}=shift;
57        }
58        return $self->{makefile};
59 }
60
61 sub blockparse {
62        my $self=shift;
63        $self->{block}=shift;
64
65        $self->{switch}=$self->_initswitcher();
66        $self->_initblockparse($self->{switch});
67 }
68
30   sub ignore {
31          my $self=shift;
32          return (defined $self->{ignore})?$self->{ignore}:0;
# Line 78 | 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 87 | 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 118 | Line 79 | sub _initswitcher {
79          return $switch;
80   }
81  
121 sub _initblockparse {
122        my $self=shift;
123        my $switch=shift;
124
125        my $parse="block";
126        $switch->newparse($parse);
127        $switch->addignoretags($parse);
128        $switch->addtag($parse,"DropDown",
129                                        \&DropDown_start,$self,
130                                        "", $self,
131                                        "", $self);
132        $switch->addtag($parse,"Build", \&Build_start, $self);
133 }
134
82   sub _commontags {
83          my $self=shift;
84          my $switch=shift;
# Line 164 | Line 111 | sub _commontags {
111          return $switch;
112   }
113  
167 sub GenerateMakefile {
168        my $self=shift;
169        my $infile=shift;
170        my $outfile=shift;
171
172        $self->{switch}=$self->_initswitcher();
173        $self->{switch}->filetoparse($infile);
174
175        # open a temporary gnumakefile to store output.
176        my $fh=FileHandle->new();
177        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
178                                                                "$!\n";
179        @{$self->{filehandlestack}}=($fh);
180
181        #  -- make an alias
182        *GNUmakefile=$fh;
183        if ( -e $ENV{LatestBuildFile} ) {
184          print GNUmakefile "include $ENV{LatestBuildFile}\n";
185        }
186        $self->{switch}->parse("makebuild"); # sort out supported tags
187        close GNUmakefile;
188        return $outfile;
189 }
190
114   sub ParseBuildFile {
115          my $self=shift;
116          my $base=shift;
# Line 201 | Line 124 | sub ParseBuildFile {
124           $fullfilename=$filename;
125          }
126          $self->{path}=$path;
204        #print "Processing $fullfilename\n";
127          $numbins=0;
128          $self->{envnum}=0;
129          $self->{envlevel}=0;
130 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
130 >        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
131                                                                  "BuildFile.mk";
210        $self->{currentenv}=$self->{makefile};
132          $self->{switch}=$self->_initswitcher();
133          $self->{switch}->filetoparse($fullfilename);
134  
135 < #       $self->{switch}->{Strict_no_cr}='no';
215 <        #open a temporary gnumakefile to store output.
135 >        # open a temporary gnumakefile to store output.
136          use Utilities::AddDir;
137 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
138 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
139 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
140 < }
137 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
138 >        my $fh=FileHandle->new();
139 >        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
140 >          ) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
141 >        @{$self->{filehandlestack}}=($fh);
142 >        # make an alias
143 >        *GNUmakefile=$fh;
144 >        if ( -e $ENV{LatestBuildFile} ) {
145 >          print GNUmakefile "include $ENV{LatestBuildFile}\n";
146 >        }
147  
148 < sub classname {
149 <        my $self=shift;
150 <        if ( @_ ) {
151 <          $self->{classname}=shift;
148 >        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
149 >        $self->{switch}->parse("makebuild"); # sort out supported tags
150 >        if ( $numbins > 0 ) {
151 >         print GNUmakefile <<ENDTEXT;
152 > ifndef BINMODE
153 > help::
154 > \t\@echo Generic Binary targets
155 > \t\@echo ----------------------
156 > endif
157 > ENDTEXT
158 >         foreach $target ( keys %$targettypes ) {
159 >         print GNUmakefile <<ENDTEXT;
160 > ifndef BINMODE
161 > help::
162 > \t\@echo $target
163 > endif
164 > ENDTEXT
165 >         }
166          }
167 <        return $self->{classname};
167 >        close GNUmakefile;
168   }
169  
170   sub ParseBuildFile_Export {
171          my $self=shift;
172          my $filename=shift;
173 <        my $bf=BuildSystem::BuildFile->new($self->{area});
173 >        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
174          if ( defined $self->{remoteproject} ) {
175             $bf->{remoteproject}=$self->{remoteproject};
176          }
# Line 259 | Line 199 | sub _parseexport {
199                                          \&export_end_export,$self);
200          $self->_commontags($switchex,"export");
201          $switchex->allowgroup("__export","export");
262 #       $switchex->{Strict_no_cr}='no';
202          $self->{switch}=$switchex;
203          $switchex->parse("export"); # sort out supported tags
204   }
# Line 306 | Line 245 | sub Class_StartTag {
245          
246          if ( $self->{Arch} ) {
247           if ( defined $$hashref{'type'} ) {
248 <                $self->classname($$hashref{'type'});
248 >                $ClassName=$$hashref{'type'};
249           }
250          }
251   }
# Line 332 | Line 271 | sub Build_start {
271          my $hashref=shift;
272  
273          $self->{switch}->checktag($name,$hashref,'class');
335        $self->{switch}->checktag($name,$hashref,'id');
274          if ( $self->{Arch} ) {
275  
276            # -- determine the build products name
# Line 342 | Line 280 | sub Build_start {
280            }
281            else {
282              $self->{switch}->parseerror("No name specified for build product");
345            #$name="\$(buildname)";
283            }
284  
285            # -- check we have a lookup for the class type
# Line 380 | Line 317 | sub Build_start {
317              # -- create a new directory for each type
318              push @targets, $pattern;
319              my $dirname=$$hashref{'class'}."_".$type."_".$name;
320 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
320 >            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
321              my $makefile=$here."/BuildFile.mk";
385 #           AddDir::adddir($here);
322  
323              # -- create link targets to the directory
324              push @targets, $dirname;
# Line 403 | Line 339 | sub Build_start {
339              print $fh "\t cd $dirname; \\\n";
340              print $fh "\t echo include ".$self->{currentenv}." > ".
341                                                          "$makefile; \\\n";
342 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
342 >            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
343                                          " >> $makefile; \\\n";
344              print $fh "\t echo buildname=$name >> $makefile;\\\n";
345              print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
# Line 414 | Line 350 | sub Build_start {
350              }
351              print $fh "\tfi\n";
352              print $fh "\n";
417 #           print $typefile "$name :\n";
418 #           print $typefile "\t\$(_quietbuild_)";
419 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
420 #           print $typefile "\t\$(_quietstamp_)";
421 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
353  
354              # -- cleaning targets
355              push @targets, "clean_$dirname";
# Line 469 | Line 400 | sub Bin_start {
400  
401          # Create a new directory for each binary target
402          my $dirname="bin_".$$hashref{name};
403 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
403 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
404          open (binGNUmakefile,
405 <           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
405 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
406             "BuildFile.mk $!\n";
407  
408          # Create the link targets
# Line 487 | Line 418 | endif
418   ifndef BINMODE
419  
420   define stepdown_$$hashref{'name'}
421 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
422 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
423 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
421 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
422 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
423 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
424   fi
425   endef
426  
427   define stepdown2_$$hashref{'name'}
428 < if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
429 < cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
430 < \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
428 > if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
429 > cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
430 > \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
431   fi
432  
433   endef
# Line 520 | Line 451 | ENDTEXT
451  
452   # the binary specifics makefile
453          print binGNUmakefile "include ".$self->{currentenv}."\n";
454 <        print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n";
454 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
455  
456   # alias for bin_Insure
457          print binGNUmakefile <<ENDTEXT;
# Line 715 | Line 646 | sub Use_start {
646          }
647   }
648  
649 + sub CheckBuildFile {
650 +         my $self=shift;
651 +         my $classdir=shift;
652 +         my $ClassName="";
653 +         my $thisfile="$classdir/$buildfile";
654 +
655 +         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
656 +            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
657 +            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
658 +         }
659 +         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
660 +            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
661 +            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
662 +         }
663 +         return $ClassName;
664 + }
665 +
666   # List association groups between <AssociateGroup> tags
667   # seperated by newlines or spaces
668   sub AssociateGroup {
# Line 910 | Line 858 | sub Environment_start {
858            $self->{envnum}++;
859  
860            # open a new Environment File
861 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
861 >          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
862                  $self->{envnum}.".mk";
863            use FileHandle;
864            my $fh=FileHandle->new();
# Line 920 | Line 868 | sub Environment_start {
868  
869            # include the approprate environment file
870            if ( $self->{envlevel} == 0 ) {
871 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
871 >             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
872                  $self->{path}."/BuildFile.mk\n";
873            }
874            else {
875 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
875 >             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
876                  $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
877            }
878            $self->{envlevel}++;
879            $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
880 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
880 >          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
881          }
882   }
883  
# Line 949 | Line 897 | sub Environment_end {
897            close $fd;
898            *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
899            if ( $self->{envlevel} < 1 ) {
900 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
900 >            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
901                          "BuildFile.mk";
902            }
903            else {
904              $self->{currentenv}=
905 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
905 >             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
906                  $self->{Envlevels}[$self->{envlevel}];
907            }
908          }
909   }
910  
911   sub Store_start {
912 <        my $self=shift;
913 <        my $name=shift;
912 >        my $self=shift;
913 >        my $name=shift;
914          my $hashref=shift;
915  
916 <        if ( $self->{Arch} ) {
917 <          $self->{switch}->checktag( $name, $hashref, 'name' );
916 >        if ( $self->{Arch} ) {
917 >          $self->{switch}->checktag( $name, $hashref, 'name' );
918  
919 <          # -- store creation
920 <          my $dir=$$hashref{'name'};
921 <          AddDir::adddir($self->{area}->location()."/".$dir);
922 <          if ( exists $$hashref{'type'} ) {
923 <            # -- architecture specific store
924 <            if ( $$hashref{'type'}=~/^arch/i ) {
925 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
926 <                AddDir::adddir($self->{area}->location()."/".$dir);
927 <            }
928 <            else {
929 <                $self->parseerror("Unknown type in <$name> tag");
930 <            }
931 <          }
932 <        
933 <          # -- set make variables for the store
934 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
935 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
936 <                                        $self->{localtop}."/".$dir."\n";
937 <          print GNUmakefile "VPATH+=".$self->{localtop}
938 <                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
939 <        }
919 >          # -- store creation
920 >          my $dir=$$hashref{'name'};
921 >          AddDir::adddir($ENV{LOCALTOP}."/".$dir);
922 >          if ( exists $$hashref{'type'} ) {
923 >            # -- architecture specific store
924 >            if ( $$hashref{'type'}=~/^arch/i ) {
925 >                $dir=$dir."/".$ENV{SCRAM_ARCH};
926 >                AddDir::adddir($ENV{LOCALTOP}."/".$dir);
927 >            }
928 >            else {
929 >                $self->parseerror("Unknown type in <$name> tag");
930 >            }
931 >          }
932 >
933 >          # -- set make variables for the store
934 >          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
935 >          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
936 >                                        $ENV{LOCALTOP}."/".$dir."\n";
937 >          print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
938 >                        ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
939 >        }
940   }
941  
994 sub DropDown {
995        my $self=shift;
996        my $name=shift;
997        my $hashref=shift;
998
999        if ( $self->{Arch} ) {
1000          # - default values must always be specified
1001          $self->{switch}->checktag( $name, $hashref, 'defaults' );
1002          my @blockdirs=split /,/ , $$hashref{'defaults'};
1003          $self->{block}->defaultblocks(@blockdirs);
1004        }
1005 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines