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.2 by williamc, Mon Aug 28 08:23:08 2000 UTC vs.
Revision 1.9 by williamc, Fri Sep 29 10:32:18 2000 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(toolbox)
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 21 | Line 25 | sub new {
25          my $class=shift;
26          my $self={};
27          bless $self, $class;
28 <        $self->{toolbox}=shift;
28 >        $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();
40          $self->{Arch}=1;
41          push @{$self->{ARCHBLOCK}}, $self->{Arch};
42          return $self;
43   }
44  
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 +
69   sub ignore {
70          my $self=shift;
71          return (defined $self->{ignore})?$self->{ignore}:0;
# Line 39 | Line 78 | sub _initswitcher {
78          $switch->newparse($parse);
79          $switch->addignoretags($parse);
80          $self->_commontags($switch,$parse);
81 <        $switch->addtag($parse,"Build", \&Build_start, $self);
81 >        #$switch->addtag($parse,"Build", \&Build_start, $self);
82          $switch->addtag($parse,"none",
83                                          \&OutToMakefile,$self,
84                                          \&OutToMakefile, $self,
# Line 48 | Line 87 | sub _initswitcher {
87                                          \&Bin_start,$self,
88                                          \&OutToScreen, $self,
89                                          "", $self);
90 +        $switch->addtag($parse,"ProductStore",
91 +                                        \&Store_start,$self,
92 +                                        "", $self,
93 +                                        "", $self);
94          $switch->addtag($parse,"LibType",
95                                          \&LibType_Start,$self,
96                                          \&LibType_text, $self,
# Line 75 | Line 118 | sub _initswitcher {
118          return $switch;
119   }
120  
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 +
135   sub _commontags {
136          my $self=shift;
137          my $switch=shift;
# Line 107 | Line 164 | sub _commontags {
164          return $switch;
165   }
166  
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 +
191   sub ParseBuildFile {
192          my $self=shift;
193          my $base=shift;
# Line 124 | Line 205 | sub ParseBuildFile {
205          $numbins=0;
206          $self->{envnum}=0;
207          $self->{envlevel}=0;
208 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
208 >        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
209                                                                  "BuildFile.mk";
210 +        $self->{currentenv}=$self->{makefile};
211          $self->{switch}=$self->_initswitcher();
212          $self->{switch}->filetoparse($fullfilename);
213  
214   #       $self->{switch}->{Strict_no_cr}='no';
215          #open a temporary gnumakefile to store output.
216          use Utilities::AddDir;
217 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
218 <        my $fh=FileHandle->new();
219 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
220 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
221 <        @{$self->{filehandlestack}}=($fh);
222 <        # make an alias
223 <        *GNUmakefile=$fh;
224 <        if ( -e $ENV{LatestBuildFile} ) {
225 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
144 <        }
145 < #       print "writing to :\n".
146 < #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
147 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
148 <        $self->{switch}->parse("makebuild"); # sort out supported tags
149 <        if ( $numbins > 0 ) {
150 <         print GNUmakefile <<ENDTEXT;
151 < ifndef BINMODE
152 < help::
153 < \t\@echo Generic Binary targets
154 < \t\@echo ----------------------
155 < endif
156 < ENDTEXT
157 <         foreach $target ( keys %$targettypes ) {
158 <         print GNUmakefile <<ENDTEXT;
159 < ifndef BINMODE
160 < help::
161 < \t\@echo $target
162 < endif
163 < ENDTEXT
164 <         }
217 >        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
218 >        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
219 >          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
220 > }
221 >
222 > sub classname {
223 >        my $self=shift;
224 >        if ( @_ ) {
225 >          $self->{classname}=shift;
226          }
227 <        close GNUmakefile;
227 >        return $self->{classname};
228   }
229  
230   sub ParseBuildFile_Export {
231          my $self=shift;
232          my $filename=shift;
233 <        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
233 >        my $bf=BuildSystem::BuildFile->new($self->{area});
234          if ( defined $self->{remoteproject} ) {
235             $bf->{remoteproject}=$self->{remoteproject};
236          }
# Line 245 | Line 306 | sub Class_StartTag {
306          
307          if ( $self->{Arch} ) {
308           if ( defined $$hashref{'type'} ) {
309 <                $ClassName=$$hashref{'type'};
309 >                $self->classname($$hashref{'type'});
310           }
311          }
312   }
# Line 271 | Line 332 | sub Build_start {
332          my $hashref=shift;
333  
334          $self->{switch}->checktag($name,$hashref,'class');
335 +        $self->{switch}->checktag($name,$hashref,'id');
336          if ( $self->{Arch} ) {
337  
338            # -- determine the build products name
# Line 318 | Line 380 | sub Build_start {
380              # -- create a new directory for each type
381              push @targets, $pattern;
382              my $dirname=$$hashref{'class'}."_".$type."_".$name;
383 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
383 >            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
384              my $makefile=$here."/BuildFile.mk";
385   #           AddDir::adddir($here);
386  
# Line 341 | Line 403 | sub Build_start {
403              print $fh "\t cd $dirname; \\\n";
404              print $fh "\t echo include ".$self->{currentenv}." > ".
405                                                          "$makefile; \\\n";
406 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
406 >            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
407                                          " >> $makefile; \\\n";
408              print $fh "\t echo buildname=$name >> $makefile;\\\n";
409              print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
# Line 356 | Line 418 | sub Build_start {
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";
421 > #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
422  
423              # -- cleaning targets
424              push @targets, "clean_$dirname";
# Line 407 | Line 469 | sub Bin_start {
469  
470          # Create a new directory for each binary target
471          my $dirname="bin_".$$hashref{name};
472 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
472 >        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
473          open (binGNUmakefile,
474 <           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
474 >           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
475             "BuildFile.mk $!\n";
476  
477          # Create the link targets
# Line 425 | Line 487 | endif
487   ifndef BINMODE
488  
489   define stepdown_$$hashref{'name'}
490 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
491 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
492 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
490 > if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
491 > cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
492 > \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
493   fi
494   endef
495  
496   define stepdown2_$$hashref{'name'}
497 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
498 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
499 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
497 > if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
498 > cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
499 > \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
500   fi
501  
502   endef
# Line 458 | Line 520 | ENDTEXT
520  
521   # the binary specifics makefile
522          print binGNUmakefile "include ".$self->{currentenv}."\n";
523 <        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
523 >        print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n";
524  
525   # alias for bin_Insure
526          print binGNUmakefile <<ENDTEXT;
# Line 514 | Line 576 | ENDTEXT
576          print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
577          print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
578          print binGNUmakefile "\t\$(CClinkCmdDebug)\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}_l_d.exe:$objectname_d\n";
581          print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
582 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
582 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
583          print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
584          print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
585 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
585 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
586          print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
587          print binGNUmakefile "\t\$(CClinkCmd)\n";
588 <        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
588 >        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
589          print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
590          print binGNUmakefile "-include $$hashref{name}.dep\n";
591   print binGNUmakefile <<ENDTEXT;
# Line 653 | Line 715 | sub Use_start {
715          }
716   }
717  
656 sub CheckBuildFile {
657         my $self=shift;
658         my $classdir=shift;
659         my $ClassName="";
660         my $thisfile="$classdir/$buildfile";
661
662         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
663            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
664            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
665         }
666         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
667            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
668            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
669         }
670         return $ClassName;
671 }
672
718   # List association groups between <AssociateGroup> tags
719   # seperated by newlines or spaces
720   sub AssociateGroup {
# Line 865 | Line 910 | sub Environment_start {
910            $self->{envnum}++;
911  
912            # open a new Environment File
913 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
913 >          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
914                  $self->{envnum}.".mk";
915            use FileHandle;
916            my $fh=FileHandle->new();
# Line 875 | Line 920 | sub Environment_start {
920  
921            # include the approprate environment file
922            if ( $self->{envlevel} == 0 ) {
923 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
923 >             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
924                  $self->{path}."/BuildFile.mk\n";
925            }
926            else {
927 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
927 >             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
928                  $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
929            }
930            $self->{envlevel}++;
931            $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
932 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
932 >          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
933          }
934   }
935  
# Line 904 | Line 949 | sub Environment_end {
949            close $fd;
950            *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
951            if ( $self->{envlevel} < 1 ) {
952 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
952 >            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
953                          "BuildFile.mk";
954            }
955            else {
956              $self->{currentenv}=
957 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
957 >             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
958                  $self->{Envlevels}[$self->{envlevel}];
959            }
960          }
961   }
962 +
963 + sub Store_start {
964 +        my $self=shift;
965 +        my $name=shift;
966 +        my $hashref=shift;
967 +
968 +        if ( $self->{Arch} ) {
969 +          $self->{switch}->checktag( $name, $hashref, 'name' );
970 +
971 +          # -- store creation
972 +          my $dir=$$hashref{'name'};
973 +          AddDir::adddir($self->{area}->location()."/".$dir);
974 +          if ( exists $$hashref{'type'} ) {
975 +            # -- architecture specific store
976 +            if ( $$hashref{'type'}=~/^arch/i ) {
977 +                $dir=$dir."/".$ENV{SCRAM_ARCH};
978 +                AddDir::adddir($self->{area}->location()."/".$dir);
979 +            }
980 +            else {
981 +                $self->parseerror("Unknown type in <$name> tag");
982 +            }
983 +          }
984 +        
985 +          # -- set make variables for the store
986 +          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
987 +          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
988 +                                        $self->{localtop}."/".$dir."\n";
989 +          print GNUmakefile "VPATH+=".$self->{localtop}
990 +                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
991 +        }
992 + }
993 +
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