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.5 by williamc, Wed Sep 13 14:00:33 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   # BlockClassPath() : Return the class path
# Line 21 | Line 21 | sub new {
21          my $class=shift;
22          my $self={};
23          bless $self, $class;
24 <        $self->{area}=shift;
25 <        $self->{toolbox}=$self->{area}->toolbox();
26 <        $self->{localtop}=$self->{area}->location();
24 >        $self->{toolbox}=shift;
25          $self->{Arch}=1;
26          push @{$self->{ARCHBLOCK}}, $self->{Arch};
27          return $self;
# Line 50 | 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 109 | Line 111 | sub _commontags {
111          return $switch;
112   }
113  
112 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
114   sub ParseBuildFile {
115          my $self=shift;
116          my $base=shift;
# Line 146 | Line 124 | sub ParseBuildFile {
124           $fullfilename=$filename;
125          }
126          $self->{path}=$path;
149        #print "Processing $fullfilename\n";
127          $numbins=0;
128          $self->{envnum}=0;
129          $self->{envlevel}=0;
130 <        $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
130 >        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
131                                                                  "BuildFile.mk";
132          $self->{switch}=$self->_initswitcher();
133          $self->{switch}->filetoparse($fullfilename);
134  
135 < #       $self->{switch}->{Strict_no_cr}='no';
159 <        #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}");
137 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
138          my $fh=FileHandle->new();
139 <        open ( $fh, ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
140 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
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 < #       print "writing to :\n".
148 < #               "$self->{localtop}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
173 <        $ENV{LatestBuildFile}="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
147 >
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;
# Line 195 | Line 170 | ENDTEXT
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 224 | Line 199 | sub _parseexport {
199                                          \&export_end_export,$self);
200          $self->_commontags($switchex,"export");
201          $switchex->allowgroup("__export","export");
227 #       $switchex->{Strict_no_cr}='no';
202          $self->{switch}=$switchex;
203          $switchex->parse("export"); # sort out supported tags
204   }
# Line 306 | Line 280 | sub Build_start {
280            }
281            else {
282              $self->{switch}->parseerror("No name specified for build product");
309            #$name="\$(buildname)";
283            }
284  
285            # -- check we have a lookup for the class type
# Line 344 | 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";
349 #           AddDir::adddir($here);
322  
323              # -- create link targets to the directory
324              push @targets, $dirname;
# Line 367 | 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 378 | Line 350 | sub Build_start {
350              }
351              print $fh "\tfi\n";
352              print $fh "\n";
381 #           print $typefile "$name :\n";
382 #           print $typefile "\t\$(_quietbuild_)";
383 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
384 #           print $typefile "\t\$(_quietstamp_)";
385 #           print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
353  
354              # -- cleaning targets
355              push @targets, "clean_$dirname";
# Line 433 | 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 451 | 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 484 | 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 540 | Line 507 | ENDTEXT
507          print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
508          print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
509          print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
510 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
510 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
511          print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
512          print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
513 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
513 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
514          print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
515          print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
516 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
516 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
517          print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
518          print binGNUmakefile "\t\$(CClinkCmd)\n";
519 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
519 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
520          print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
521          print binGNUmakefile "-include $$hashref{name}.dep\n";
522   print binGNUmakefile <<ENDTEXT;
# Line 685 | Line 652 | sub CheckBuildFile {
652           my $ClassName="";
653           my $thisfile="$classdir/$buildfile";
654  
655 <         if ( -e $self->{localtop}."/".$thisfile ) {
656 <            $DefaultBuildfile="$self->{localtop}/$thisfile";
657 <            $self->ParseBuildFile($self->{localtop}, $classdir, $buildfile);
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";
# Line 891 | 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 901 | 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 930 | 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;
914 +        my $hashref=shift;
915 +
916 +        if ( $self->{Arch} ) {
917 +          $self->{switch}->checktag( $name, $hashref, 'name' );
918 +
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 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines