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.6 by williamc, Fri Sep 15 11:18:21 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   # BlockClassPath() : Return the class path
9   # ignore()      : return 1 if directory should be ignored 0 otherwise
10 # classname()   : get/set the associated class
11 # buildfile()   : get/set BuildFile location
10  
11   package BuildSystem::BuildFile;
12   use ActiveDoc::SimpleDoc;
# Line 23 | Line 21 | sub new {
21          my $class=shift;
22          my $self={};
23          bless $self, $class;
24 <        $self->{area}=shift;
27 <        $self->{toolbox}=$self->{area}->toolbox();
28 <        $self->{localtop}=$self->{area}->location();
24 >        $self->{toolbox}=shift;
25          $self->{Arch}=1;
26          push @{$self->{ARCHBLOCK}}, $self->{Arch};
27          return $self;
28   }
29  
34 sub buildfile {
35        my $self=shift;
36        if ( @_ ) {
37          $self->{buildfile}=shift;
38        }
39        return $self->{buildfile};
40 }
41
30   sub ignore {
31          my $self=shift;
32          return (defined $self->{ignore})?$self->{ignore}:0;
# Line 60 | 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);
55          $switch->addtag($parse,"LibType",
56                                          \&LibType_Start,$self,
57                                          \&LibType_text, $self,
# Line 119 | Line 111 | sub _commontags {
111          return $switch;
112   }
113  
122 sub GenerateMakefile {
123        my $self=shift;
124        my $infile=shift;
125        my $outfile=shift;
126
127        $self->{switch}=$self->_initswitcher();
128        $self->{switch}->filetoparse($infile);
129
130        # open a temporary gnumakefile to store output.
131        my $fh=FileHandle->new();
132        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
133                                                                "$!\n";
134        @{$self->{filehandlestack}}=($fh);
135
136        #  -- make an alias
137        *GNUmakefile=$fh;
138        if ( -e $ENV{LatestBuildFile} ) {
139          print GNUmakefile "include $ENV{LatestBuildFile}\n";
140        }
141        $ENV{LatestBuildFile}=$outfile;
142        $self->{switch}->parse("makebuild"); # sort out supported tags
143        close GNUmakefile;
144 }
145
114   sub ParseBuildFile {
115          my $self=shift;
116          my $base=shift;
# Line 160 | Line 128 | sub ParseBuildFile {
128          $numbins=0;
129          $self->{envnum}=0;
130          $self->{envlevel}=0;
131 <        $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
131 >        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
132                                                                  "BuildFile.mk";
133          $self->{switch}=$self->_initswitcher();
134          $self->{switch}->filetoparse($fullfilename);
# Line 168 | Line 136 | sub ParseBuildFile {
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}");
139 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
140          my $fh=FileHandle->new();
141 <        open ( $fh, ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
142 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
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;
# Line 179 | Line 147 | sub ParseBuildFile {
147            print GNUmakefile "include $ENV{LatestBuildFile}\n";
148          }
149   #       print "writing to :\n".
150 < #               "$self->{localtop}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
151 <        $ENV{LatestBuildFile}="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
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;
# Line 202 | Line 170 | ENDTEXT
170          close GNUmakefile;
171   }
172  
205 sub classname {
206        my $self=shift;
207        if ( @_ ) {
208          $self->{classname}=shift;
209        }
210        return $self->{classname};
211 }
212
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 289 | 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 362 | 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 385 | 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 451 | 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 469 | 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 502 | 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 697 | 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 892 | 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 902 | 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 931 | 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;
925 +        my $hashref=shift;
926 +
927 +        if ( $self->{Arch} ) {
928 +          $self->{switch}->checktag( $name, $hashref, 'name' );
929 +
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 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines