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.4 by williamc, Tue Sep 12 13:01:39 2000 UTC vs.
Revision 1.8 by williamc, Fri Sep 29 06:45:51 2000 UTC

# Line 5 | Line 5
5   # new(ConfigArea)
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
14  
15   package BuildSystem::BuildFile;
16   use ActiveDoc::SimpleDoc;
# Line 23 | Line 27 | sub new {
27          bless $self, $class;
28          $self->{area}=shift;
29          $self->{toolbox}=$self->{area}->toolbox();
30 +        $self->{localtop}=$self->{area}->location();
31          $self->{Arch}=1;
32          push @{$self->{ARCHBLOCK}}, $self->{Arch};
33          return $self;
34   }
35  
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 +
60   sub ignore {
61          my $self=shift;
62          return (defined $self->{ignore})?$self->{ignore}:0;
# Line 40 | Line 69 | sub _initswitcher {
69          $switch->newparse($parse);
70          $switch->addignoretags($parse);
71          $self->_commontags($switch,$parse);
72 <        $switch->addtag($parse,"Build", \&Build_start, $self);
72 >        #$switch->addtag($parse,"Build", \&Build_start, $self);
73          $switch->addtag($parse,"none",
74                                          \&OutToMakefile,$self,
75                                          \&OutToMakefile, $self,
# Line 49 | Line 78 | sub _initswitcher {
78                                          \&Bin_start,$self,
79                                          \&OutToScreen, $self,
80                                          "", $self);
81 +        $switch->addtag($parse,"ProductStore",
82 +                                        \&Store_start,$self,
83 +                                        "", $self,
84 +                                        "", $self);
85          $switch->addtag($parse,"LibType",
86                                          \&LibType_Start,$self,
87                                          \&LibType_text, $self,
# Line 76 | Line 109 | sub _initswitcher {
109          return $switch;
110   }
111  
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 +
126   sub _commontags {
127          my $self=shift;
128          my $switch=shift;
# Line 127 | Line 174 | sub GenerateMakefile {
174          if ( -e $ENV{LatestBuildFile} ) {
175            print GNUmakefile "include $ENV{LatestBuildFile}\n";
176          }
130        $ENV{LatestBuildFile}=$outfile;
177          $self->{switch}->parse("makebuild"); # sort out supported tags
178          close GNUmakefile;
179 +        return $outfile;
180   }
181  
182   sub ParseBuildFile {
# Line 149 | Line 196 | sub ParseBuildFile {
196          $numbins=0;
197          $self->{envnum}=0;
198          $self->{envlevel}=0;
199 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
199 >        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
200                                                                  "BuildFile.mk";
201 +        $self->{currentenv}=$self->{makefile};
202          $self->{switch}=$self->_initswitcher();
203          $self->{switch}->filetoparse($fullfilename);
204  
205   #       $self->{switch}->{Strict_no_cr}='no';
206          #open a temporary gnumakefile to store output.
207          use Utilities::AddDir;
208 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
209 <        my $fh=FileHandle->new();
210 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
211 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
212 <        @{$self->{filehandlestack}}=($fh);
213 <        # make an alias
214 <        *GNUmakefile=$fh;
215 <        if ( -e $ENV{LatestBuildFile} ) {
216 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
169 <        }
170 < #       print "writing to :\n".
171 < #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
172 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
173 <        $self->{switch}->parse("makebuild"); # sort out supported tags
174 <        if ( $numbins > 0 ) {
175 <         print GNUmakefile <<ENDTEXT;
176 < ifndef BINMODE
177 < help::
178 < \t\@echo Generic Binary targets
179 < \t\@echo ----------------------
180 < endif
181 < ENDTEXT
182 <         foreach $target ( keys %$targettypes ) {
183 <         print GNUmakefile <<ENDTEXT;
184 < ifndef BINMODE
185 < help::
186 < \t\@echo $target
187 < endif
188 < ENDTEXT
189 <         }
208 >        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
209 >        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
210 >          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
211 > }
212 >
213 > sub classname {
214 >        my $self=shift;
215 >        if ( @_ ) {
216 >          $self->{classname}=shift;
217          }
218 <        close GNUmakefile;
218 >        return $self->{classname};
219   }
220  
221   sub ParseBuildFile_Export {
# Line 270 | Line 297 | sub Class_StartTag {
297          
298          if ( $self->{Arch} ) {
299           if ( defined $$hashref{'type'} ) {
300 <                $ClassName=$$hashref{'type'};
300 >                $self->classname($$hashref{'type'});
301           }
302          }
303   }
# Line 296 | Line 323 | sub Build_start {
323          my $hashref=shift;
324  
325          $self->{switch}->checktag($name,$hashref,'class');
326 +        $self->{switch}->checktag($name,$hashref,'id');
327          if ( $self->{Arch} ) {
328  
329            # -- determine the build products name
# Line 343 | Line 371 | sub Build_start {
371              # -- create a new directory for each type
372              push @targets, $pattern;
373              my $dirname=$$hashref{'class'}."_".$type."_".$name;
374 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
374 >            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
375              my $makefile=$here."/BuildFile.mk";
376   #           AddDir::adddir($here);
377  
# Line 366 | Line 394 | sub Build_start {
394              print $fh "\t cd $dirname; \\\n";
395              print $fh "\t echo include ".$self->{currentenv}." > ".
396                                                          "$makefile; \\\n";
397 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
397 >            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
398                                          " >> $makefile; \\\n";
399              print $fh "\t echo buildname=$name >> $makefile;\\\n";
400              print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
# Line 381 | Line 409 | sub Build_start {
409   #           print $typefile "\t\$(_quietbuild_)";
410   #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
411   #           print $typefile "\t\$(_quietstamp_)";
412 < #           print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
412 > #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
413  
414              # -- cleaning targets
415              push @targets, "clean_$dirname";
# Line 432 | Line 460 | sub Bin_start {
460  
461          # Create a new directory for each binary target
462          my $dirname="bin_".$$hashref{name};
463 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
463 >        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
464          open (binGNUmakefile,
465 <           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
465 >           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
466             "BuildFile.mk $!\n";
467  
468          # Create the link targets
# Line 450 | Line 478 | endif
478   ifndef BINMODE
479  
480   define stepdown_$$hashref{'name'}
481 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
482 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
483 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
481 > if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
482 > cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
483 > \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
484   fi
485   endef
486  
487   define stepdown2_$$hashref{'name'}
488 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
489 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
490 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
488 > if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
489 > cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
490 > \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
491   fi
492  
493   endef
# Line 483 | Line 511 | ENDTEXT
511  
512   # the binary specifics makefile
513          print binGNUmakefile "include ".$self->{currentenv}."\n";
514 <        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
514 >        print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n";
515  
516   # alias for bin_Insure
517          print binGNUmakefile <<ENDTEXT;
# Line 539 | Line 567 | ENDTEXT
567          print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
568          print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
569          print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
570 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
570 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
571          print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
572          print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
573 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
573 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
574          print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
575          print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
576 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
576 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
577          print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
578          print binGNUmakefile "\t\$(CClinkCmd)\n";
579 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
579 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
580          print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
581          print binGNUmakefile "-include $$hashref{name}.dep\n";
582   print binGNUmakefile <<ENDTEXT;
# Line 678 | Line 706 | sub Use_start {
706          }
707   }
708  
681 sub CheckBuildFile {
682         my $self=shift;
683         my $classdir=shift;
684         my $ClassName="";
685         my $thisfile="$classdir/$buildfile";
686
687         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
688            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
689            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
690         }
691         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
692            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
693            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
694         }
695         return $ClassName;
696 }
697
709   # List association groups between <AssociateGroup> tags
710   # seperated by newlines or spaces
711   sub AssociateGroup {
# Line 890 | Line 901 | sub Environment_start {
901            $self->{envnum}++;
902  
903            # open a new Environment File
904 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
904 >          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
905                  $self->{envnum}.".mk";
906            use FileHandle;
907            my $fh=FileHandle->new();
# Line 900 | Line 911 | sub Environment_start {
911  
912            # include the approprate environment file
913            if ( $self->{envlevel} == 0 ) {
914 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
914 >             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
915                  $self->{path}."/BuildFile.mk\n";
916            }
917            else {
918 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
918 >             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
919                  $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
920            }
921            $self->{envlevel}++;
922            $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
923 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
923 >          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
924          }
925   }
926  
# Line 929 | Line 940 | sub Environment_end {
940            close $fd;
941            *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
942            if ( $self->{envlevel} < 1 ) {
943 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
943 >            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
944                          "BuildFile.mk";
945            }
946            else {
947              $self->{currentenv}=
948 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
948 >             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
949                  $self->{Envlevels}[$self->{envlevel}];
950            }
951          }
952   }
953 +
954 + sub Store_start {
955 +        my $self=shift;
956 +        my $name=shift;
957 +        my $hashref=shift;
958 +
959 +        if ( $self->{Arch} ) {
960 +          $self->{switch}->checktag( $name, $hashref, 'name' );
961 +
962 +          # -- store creation
963 +          my $dir=$$hashref{'name'};
964 +          AddDir::adddir($self->{area}->location()."/".$dir);
965 +          if ( exists $$hashref{'type'} ) {
966 +            # -- architecture specific store
967 +            if ( $$hashref{'type'}=~/^arch/i ) {
968 +                $dir=$dir."/".$ENV{SCRAM_ARCH};
969 +                AddDir::adddir($self->{area}->location()."/".$dir);
970 +            }
971 +            else {
972 +                $self->parseerror("Unknown type in <$name> tag");
973 +            }
974 +          }
975 +        
976 +          # -- set make variables for the store
977 +          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
978 +          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
979 +                                        $self->{localtop}."/".$dir."\n";
980 +          print GNUmakefile "VPATH+=".$self->{localtop}
981 +                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
982 +        }
983 + }
984 +
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