ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildSetup.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildSystem/BuildSetup.pm (file contents):
Revision 1.9 by williamc, Fri Sep 29 10:32:18 2000 UTC vs.
Revision 1.14 by sashby, Fri Jul 13 09:59:10 2001 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(ConfigArea) : A new BuildSetup
6 < # BuildDir(directory,targets) : prepare the ground for a build and build
5 > # new(toolbox) : A new BuildSetup
6 > # BuildSetup(directory,targets) : prepare the ground for a build and build
7   # getclass(directory) : return (Class, ClassDir, BuildFileobject)
8   #                       associated with directory
9 < # setup(dir)
9 > #
10  
11   package BuildSystem::BuildSetup;
12   require 5.004;
13   use Utilities::Verbose;
14   use Utilities::SCRAMUtils;
15   use BuildSystem::BuildFile;
16 use BuildSystem::DateStampRecord;
16   use Utilities::AddDir;
17   @ISA=qw(Utilities::Verbose);
18  
# Line 21 | Line 20 | sub new {
20          my $class=shift;
21          my $self={};
22          bless $self,$class;
23 <        $self->{area}=shift;
25 <        $self->{toolbox}=$self->{area}->toolbox();
26 <        $self->{projconfigdir}=$self->{area}->configurationdir();
27 <        $self->{localtop}=$self->{area}->location();
28 <        $self->{releasearea}=$self->{area}->linkarea();
29 <        if ( ! defined $self->{releasearea} ) {
30 <           $self->{releasearea}=$self->{area};
31 <        }
32 <        $self->{releasetop}=$self->{releasearea}->location();
33 <        $self->{buildfilename}="BuildFile";
34 <        #$self->verbosity(1);
35 <        $self->_configurationsetup();
23 >        $self->{toolbox}=shift;
24          return $self;
25   }
26  
27 < sub _generateexternals {
28 <        my $self=shift;
29 <        my $outfile=shift;
30 <
31 <        # -- specify these files for dependency information
32 <        my $depfile=$self->{projconfigdir}."/External_Dependencies";
33 <
34 <        # -- get list of dependent files
35 <        my $datadir=$self->{localtop}."/.SCRAM/".$ENV{SCRAM_ARCH};
36 <        $fdir=FileHandle->new();
37 <        opendir $fdir, $datadir;
38 <        my @depfiles=grep !/^\.\.?$/, readdir $fdir;
39 <        undef $fdir;
40 <        for (my $i=0; $i<=$#depfiles; $i++ ) {
41 <           $depfiles[$i]=$datadir."/".$depfiles[$i];
42 <        }
43 <
44 <        # -- do we need to rebuild?
45 <        if ( SCRAMUtils::dated($outfile,@depfiles) ) {
46 <          print "Configuring Local Area\n";
47 <          # -- open output file
48 <          my $fout=FileHandle->new();
49 <          $fout->open(">".$outfile) or die "Unable to open $outfile for output".
50 <                                        $!."\n";
51 <
52 <          # -- print out tool/ version info
53 <          my ($tool,$toolobj,$f,$val,$version);
54 <          foreach $tool ( $self->{toolbox}->tools() ) {
55 <            $version=$self->{toolbox}->defaultversion($tool);
56 <            # default versions
57 <            print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n";
58 <            # -- set up the different version  -- externals
59 <            foreach $version ( $self->{toolbox}->versions($tool) ) {
60 <             $toolobj=$self->{toolbox}->gettool($tool,$version);
61 <             @deps=$toolobj->getfeature("_externals");
62 <             foreach $d ( @deps ) {
63 <              $d=~tr[A-Z][a-z];
64 <              print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n";
65 <             }
66 <             # -- tool info
67 <             print $fout "ifdef ".$tool."_V_".$version."\n";
68 <             foreach $f ( $toolobj->features() ) {
81 <              foreach $val ( $toolobj->getfeature($f) ) {
82 <                print $fout "\t".$f." += ".$val."\n";
83 <              }
84 <             }
85 <             print $fout "endif\n";
86 <            }
87 <          }
88 <          # some addittional processing of specific vars
89 <          print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n";
90 <          print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n";
91 <          print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n";
92 <          print $fout 'lib+=$(extralib)'."\n";
93 <          print $fout 'LDLIBS+=$(addprefix -l,$(lib))'."\n";
94 <          print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n";
95 <
96 <          undef $fout;
97 <          $self->verbose("End Configuration Setup");
98 <        }
99 < }
100 <
101 < sub classsetup {
102 <        my $self=shift;
103 <        my $THISDIR=shift;
104 <
105 <        my $classmakefile;
106 <
107 <        my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR);
108 <        $self->verbose("Class = $Class : ClassDir = $ClassDir for directory ".
109 <                        $THISDIR);
110 <
111 <        # -- should we ignore?
112 <        if ( $bf->ignore() ) {
113 <           print "Nothing to be done - empty group\n";
114 <           exit;
115 <        }      
116 <
117 <
118 <        # -- Create a makefile from the class BuildFile
119 <        my $classbuildfile=$self->{localtop}."/".
120 <                $self->{projconfigdir}."/".$Class."_BuildFile";
121 <        if ( -f $classbuildfile ) {
122 <              $classmakefile=$self->{localtop}."/".$ENV{INTwork}.
123 <                                        "/".$Class."_makefile.mk";
124 <              if ( SCRAMUtils::dated($classmakefile, $classbuildfile) ) {
125 <                # -- generate the new makefile if out of date
126 <                $self->verbose("Generating $classmakefile from".
127 <                                                " $classbuildfile");
128 <                my $classbf=BuildSystem::BuildFile->new($self->{area});
129 <                undef $ENV{LatestBuildFile}; # gets set by BuildFile
130 <                $classbf->GenerateMakefile($classbuildfile, $classmakefile);
131 <                undef $ENV{LatestBuildFile}; # gets set by BuildFile
132 <              }
133 <        }
134 <        else {
135 <           # -- No BuildFile - maybe its old style makefile
136 <              $classmakefile=$self->{localtop}."/".
137 <              $self->{projconfigdir}."/".$Class."_makefile.mk";
138 <              if ( ! -f $classmakefile ) {
139 <                   $self->error("Unable to find matching ".$Class.
140 <                                "_BuildFile or ".$Class."_makefile.mk");
141 <              }
142 <        }
143 <        # -- set LatestBuildFile
144 <        if ( $bf->buildfile() ne "" ) {
145 <          $ENV{LatestBuildFile}=$bf->makefile();
146 <        }
147 <        else {
148 <          $ENV{LatestBuildFile}=$self->{topbf}->makefile();
149 <        }
150 <
151 <        return ($Class,$ClassDir,$classmakefile);
152 < }
153 <
154 < sub _configurationsetup {
155 <        my $self=shift;
156 <
157 <        # -- set working directory
158 <        $self->{workdir}=$ENV{INTwork};
159 <        $self->{fullworkdir}=$self->{localtop}."/".$self->{workdir};
160 <
161 <        # -- make working directory
162 <        chdir $self->{localtop};
163 <        AddDir::adddir($self->{workdir});
27 > sub _generateexternals
28 >   ###############################################################
29 >   # _generateexternals                                          #
30 >   ###############################################################
31 >   # modified : Thu Jul 12 12:06:50 2001 / SFA                   #
32 >   # params   :                                                  #
33 >   #          :                                                  #
34 >   #          :                                                  #
35 >   #          :                                                  #
36 >   # function :                                                  #
37 >   #          :                                                  #
38 >   #          :                                                  #
39 >   ###############################################################
40 >   {
41 >   my $self=shift;
42 >   my $outfile=shift;
43 >
44 >   # -- specifiy these files for dependency information
45 >   # NB: This file is never used!
46 >  
47 >   my $depfile=$ENV{projconfigdir}."/External_Dependencies";
48 >  
49 >   # -- get list of dependent files
50 >   my $datadir=$ENV{LOCALTOP}."/.SCRAM/".$ENV{SCRAM_ARCH};
51 >   $fdir=FileHandle->new();
52 >   opendir $fdir, $datadir;
53 >   my @depfiles=grep !/^\.\.?$/, readdir $fdir;
54 >   undef $fdir;
55 >  
56 >   for (my $i=0; $i<=$#depfiles; $i++ )
57 >      {
58 >      $depfiles[$i]=$datadir."/".$depfiles[$i];
59 >      }
60 >  
61 >   # -- do we need to rebuild?
62 >   if ( SCRAMUtils::dated($outfile,@depfiles) )
63 >      {
64 >      print "Configuring Local Area\n";
65 >      # -- open output file
66 >      my $fout=FileHandle->new();
67 >      $fout->open(">".$outfile) or die "Unable to open $outfile for output".
68 >         $!."\n";
69  
70 <        # -- generate tool info
71 <        $self->_generateexternals($self->{fullworkdir}."/clientmakefile");
72 <
73 <        # -- process project BuildFile
74 <        $self->_topbuildfile();
75 < }
70 >      # -- print out tool/ version info
71 >      my ($tool,$toolobj,$f,$val,$version);
72 >          
73 >      foreach $tool ( $self->{toolbox}->tools() )
74 >         {
75 >         $version=$self->{toolbox}->defaultversion($tool);
76 >        
77 >         # default versions
78 >         print $fout "ifdef $tool\n".$tool."_V_".$version."=true\nendif\n";
79 >
80 >         # -- set up the different version  -- externals
81 >         foreach $version ( $self->{toolbox}->versions($tool) )
82 >            {
83 >            $toolobj=$self->{toolbox}->gettool($tool,$version);
84 >            @deps=$toolobj->getfeature("_externals");
85 >            #
86 >            foreach $d ( @deps )
87 >               {
88 >               $d=~tr[A-Z][a-z];
89 >               print $fout "ifdef ".$tool."_V_".$version."\n $d=true\nendif\n";
90 >               }
91 >            # -- tool info
92 >            print $fout "ifdef ".$tool."_V_".$version."\n";
93 >            
94 >            foreach $f ( $toolobj->features() )
95 >               {
96 >               foreach $val ( $toolobj->getfeature($f) )
97 >                  {
98 >                  print $fout "\t".$f." += ".$val."\n";
99 >                  }
100 >               }
101 >            # -- include any makefiles associated with the tool
102 >            if ( -f $self->{toolbox}->toolmakefile($tool,$version) )
103 >               {
104 >               print $fout "-include ".
105 >                  $self->{toolbox}->toolmakefile($tool,$version)."\n";
106 >               }
107 >            print $fout "endif\n";
108 >            }
109 >         }
110 >      # some addittional processing of specific vars
111 >      print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n";
112 >      print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n";
113 >      print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n";
114 >      print $fout 'lib+=$(extralib)'."\n";
115 >      print $fout 'LDLIBS+=$(addprefix -l,$(lib))'."\n";
116 >      print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n";
117 >      print $fout 'LD_LIBRARY_PATH:=$(subst $(space),:,$(LD_LIBRARY_PATH))'."\n";
118 >      
119 >      undef $fout;
120 >      }
121 >   }
122  
123 < sub BuildDir {
124 <        my $self=shift;
125 <        my $THISDIR=shift;
126 <        my @Targets=@_;
127 <        my $DefaultBuildFile="";
128 <
129 <        # -- Setup Class specifics
130 <        ($Class,$ClassDir,$classmakefile)=$self->classsetup($THISDIR);
131 <        $ENV{classmakefile}=$classmakefile;
132 <        $ENV{Class}=$Class;
133 <        $ENV{ClassDir}=$ClassDir;
134 <        $DefaultBuildFile=$ENV{classmakefile};
135 <        $ENV{DefaultBuildFile}=$DefaultBuildFile;
136 <
186 <        # -- Create working directory
187 <        my $workdir=$self->{workdir}."/".$ClassDir;
188 <        chdir $self->{localtop};
189 <        AddDir::adddir($workdir);
190 <        $ENV{workdir}=$workdir;
191 <        my $fullworkdir=$self->{localtop}."/".$ENV{workdir};
192 <        chdir $fullworkdir || die "Unable to enter working directory $!";
123 > sub BuildSetup {
124 >    my $self=shift;
125 >    my $THISDIR=shift;
126 >    my @Targets=@_;
127 >    my $DefaultBuildFile="";
128 >    my $Class="";
129 >
130 >    # -- Create working directory
131 >    chdir $ENV{LOCALTOP};
132 >    AddDir::adddir($ENV{INTwork}."/".$THISDIR);
133 >
134 >    my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR);
135 >    $self->verbose("Class = $Class");
136 >    $self->verbose("ClassDir = $ClassDir");
137          
138 <        # -- Set up some other useful variables for the Build
139 <        # set variables listing directories/files available
140 <        my $fh=FileHandle->new();
141 <        opendir $fh, "$self->{localtop}/$ClassDir";
142 <        my @allfiles= grep !/^\.\.?$/, readdir $fh;
143 <        undef $fh;
144 <        foreach $file ( @allfiles ) {
145 <         if ( -d "$self->{localtop}/$ClassDir/$file" ) {
146 <           $ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
147 <         }
148 <         else {
149 <           $ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
150 <         }
151 <        }
152 <        my $targetnumber=$#Targets;
153 <        $ENV{"MAKETARGETS"}="";
154 <        foreach $word ( @Targets ) {
155 <         if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target
156 <           $targetnumber--;
157 <         }
158 <         else {
159 <          # set some variables for use in makefiles
160 <          $ENV{"MAKETARGET_".$word}=$word;
161 <          if ( $ENV{"MAKETARGETS"} ne "" ) {
162 <            $ENV{"MAKETARGETS"}=$ENV{"MAKETARGETS"}." ".$word;
163 <          }
164 <          else {
165 <            $ENV{"MAKETARGETS"}=$word;
166 <          }
167 <         }
168 <        }
138 >    if ( $bf->ignore() ) {
139 >        print "Nothing to be done - empty group\n";
140 >        exit;
141 >    }  
142 >    shift;
143 >    $self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile");
144 >
145 >    # set up the workdir variable
146 >    $ENV{workdir}=$ENV{INTwork}."/".$ClassDir;
147 >    my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir};
148 >
149 >    # set up projdeps variable
150 >    my $projectfile=$ENV{projconfigdir}."/External_Dependencies";
151 >    if ( -e $ENV{LOCALTOP}."/".$projectfile ) {
152 >      $ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile;
153 >    }
154 >    elsif ( -e $ENV{RELEASETOP}."/".$projectfile ) {
155 >      $ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile;
156 >    }
157 >    if ( $DefaultBuildFile eq "" ) {
158 >      # Map Relevant makefile classmakefile directory
159 >      my $classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk";
160 >      if ( -e $ENV{LOCALTOP}."/".$classmakefile ) {
161 >         $ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile;
162 >      }
163 >      elsif ( -e $ENV{RELEASETOP}."/".$classmakefile ) {
164 >         $ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile;
165 >      }
166 >      else {
167 >        print "\nUnable to locate $classmakefile\n";
168 >        print " Not in $ENV{LOCALTOP}\n";
169 >        print " Not in $ENV{RELEASETOP}\n";
170 >        exit 1;
171 >      }
172 >      $DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override
173 >    }
174 >
175 >    $ENV{ClassDir}=$ClassDir;
176 >    $ENV{Class}=$Class;
177 >    $ENV{DefaultBuildFile}=$DefaultBuildFile;
178 >
179 >    chdir $fullworkdir || die "Unable to enter working directory $!";
180 >
181 >    # Set up some other useful variables fo the Build
182 >    # list of directories available
183 >    opendir IDR, "$ENV{LOCALTOP}/$THISDIR";
184 >    @allfiles= grep !/^\.\.?$/, readdir IDR;
185 >    foreach $file ( @allfiles ) {
186 >      if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" ) { # only add if its a directory
187 >        $ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
188 >      }
189 >      else {
190 >        $ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
191 >      }
192 >    }
193 >    $targetnumber=$#Targets;
194 >    foreach $word ( @Targets ) {
195 >      if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target
196 >         $targetnumber--;
197 >      }
198 >      elsif ( $word=~/^-/ ) {
199 >         $targetnumber--;
200 >      }
201 >      else {
202 >        $ENV{"MAKETARGET_".$word}=$word;
203 >      }
204 >    }
205  
206 <       # -- If target not specified default to the class name target
207 <       if ( $targetnumber == -1 ) {
206 >    # If not specified default to the class name target
207 >    if ( $targetnumber == -1 ) {
208          push @Targets,$Class;
209 <       }
209 >    }
210  
211      $ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk";
212  
213 <
234 <    $SCRAM_GROUPSDIR=$self->{localtop}."/".$self->{projconfigdir}."/groups.mk";
213 >    $SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk";
214      if ( -f $SCRAM_GROUPSDIR ) {
215        $ENV{SCRAM_GROUPSDIR}=$SCRAM_GROUPSDIR;
216      }
217  
218      # Do a datestamp check so that make will build files that have changed
219      # rather than just those which are older than their dependencies
241    $self->_checkdatestampindir($ClassDir);
242
243        # -- call the block building method
244        #$report=$bs->build(@Targets);
245        
246
220      # The main build here
221 <    $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}", @Targets);
221 >    $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config);
222 >    $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets);
223      return $rv/256; # return the exit status of gmake
250        
251 }
252
253 sub BuildIt {
254        my $self=shift;
255        my $dir=shift;
256
257        # -- get the building block for the directory
258        my $block=$self->_getdirblock($dir);
259
260        # -- is there a class block associated with the directory?
261        my ($class)=getclass($dir);
262        my $classblock=$self->_getclassblock($class);
263
264        # -- Search for Blocks up to tree root
265        my @dirblocks=();
266        my @dirs=split /\//, $dir;
267        my $fulldir="";
268        foreach $dire ( "/",@dirs ) {
269              $fulldir=$fulldir."/".$dire;  # root is //
270              my $block=$self->_getdirblock($fulldir);
271              last if $block->ignore(); # we dont need to go futher
272              push @dirblocks, $block;
273        }
274        foreach $block ( $classblock, @dirblocks ) {
275              # -- merge class blocks together
276              foreach $name ( $block->classes() ) {
277                $object->merge();
278              }
279              foreach $classinst ( $block->classinst() ) {
280                $types{$classinst->id()}=$class->newinst();
281                foreach $element ( $classinst ) {
282                  $types{$classinst->id()}->setelement($element,
283                                                $classinst->value($element));
284                }
285              }
286        }
287
288        # -- call the builder
289
290 }
291
292 sub _getdirblock {
293        my $self=shift;
294        my $dir=shift;
295
296        if ( ! defined $self->{blocks}{$dir} ) {
297        
298          # -- get a buildfile and do a block parse
299          my $bf=$self->_startbuildfile($dir);
300          $bf->blockparse($self->{blocks}{$dir});
301          
302        }
303        return $self->{blocks}{$dir};
224   }
225  
226   sub getclass {
# Line 312 | Line 232 | sub getclass {
232      #return if $dirname eq "";
233      @DIRA=split /\//, $dirname;
234  
235 <    my $thispath=".";
236 <    # -- construct all class buildfiles in the path
235 >    $thispath=".";
236 >    # bootstrap from project buildfile if it exists
237 >    my $bf=BuildSystem::BuildFile->new($self->{toolbox});
238 >    $bf->CheckBuildFile($ENV{projconfigdir});
239 >
240 >    my @ClassPaths=split /:/, $bf->BlockClassPath();
241 >    foreach $BClassPath ( @ClassPaths ) {
242 >      next if ( $BClassPath eq "");
243 >      push @LoBCA, [ split /\//, $BClassPath ];
244 >    }
245      for ( $i=0; $i<=$#DIRA; $i++ ) {
246 <        #$thispath=(($thispath eq "")?$DIRA[$i]:$thispath."/".$DIRA[$i]);
247 <        $thispath=$thispath."/".$DIRA[$i];
248 <        if ( ! exists $self->{pathbf}{$thispath} ) {
321 <          $self->verbose("Initialising BuildFile in $thispath");
322 <          $self->{pathbf}{$thispath}=$self->_startbuildfile($thispath);
323 <        }
324 <        # -- check class overriden by BuildFile
325 <        if ( defined $self->{pathbf}{$thispath}->classname() ) {
326 <                $Class=$self->{pathbf}{$thispath}->classname();
246 >        $thispath=$thispath."/".$DIRA[$i];
247 >        if ( ($ClassName=$bf->CheckBuildFile($thispath)) ne "" ) {
248 >                $Class=$ClassName;
249                  $ClassDir=$thispath;
250          }
251 +        # TODO --- Must test against position of last new BlockCaseA
252 +        # Need to reset array LoBCA to the New BlockPath
253 +        # - merge and replace options
254 +        #
255          else {
256 <          # -- sort it out from classpath directives
257 <          foreach $BlockClassA ( @{$self->{LoBCA}} ) {
258 <           next if ( $#{$BlockClassA} < $i );
333 <           $elem=${$BlockClassA}[$i];
334 <            if ( $elem=~/^$DIRA[$i]\+/ ) {
335 <                $elem=~s/^$DIRA[$i]//;
256 >          foreach $BlockClassA ( @LoBCA ) {
257 >            if ( $$BlockClassA[0]=~/^$DIRA[$i]\+/ ) {
258 >                $$BlockClassA[0]=~s/^$DIRA[$i]//;
259              }
260 <            #print $elem." ".$DIRA[$i]."\n";
261 <            if ( $elem=~/^\+/ ) {
339 <                ($Class=$elem)=~s/^\+//;
260 >            if ( $$BlockClassA[0]=~/^\+/ ) {
261 >                ($Class=$$BlockClassA[0])=~s/^\+//;
262                  $ClassDir=$thispath;
263 +                shift @$BlockClassA;
264 +            }
265 +            else {
266 +                @$BlockClassA=();
267              }
342          #}
343         }
344        }
345    }
346    # -- default case
347    if ( $ClassDir eq "" ) {
348      if ( ! defined $self->{pathbf}{'.'}) {
349          $self->{pathbf}{'.'}=$self->_startbuildfile(".");
350          $self->verbose("DEFAULT class initialised : ".$self->{pathbf}{'.'});
351      }
352      $ClassDir=".";
353    }
354
355    # -- returns
356    ($ClassDir_c=$ClassDir)=~s/^\.\///;
357    return ( $Class, $ClassDir_c, $self->{pathbf}{$ClassDir});
358 }
359
360 #
361 # Check to see if the buildfile is local or in the release area and
362 # parse appropriately
363 #
364 sub _startbuildfile {
365         my $self=shift;
366         my $classdir=shift;
367
368         my $bf=BuildSystem::BuildFile->new($self->{area});
369         my $thisfile="$classdir/$self->{buildfilename}";
370
371         if ( -e $self->{localtop}."/".$thisfile ) {
372            $bf->buildfile($self->{localtop}."/".$thisfile);
373            $bf->ParseBuildFile($self->{localtop}, $classdir,
374                                $self->{buildfilename});
375         }
376         elsif ( -e $self->{releasetop}."/".$thisfile ) {
377            $bf->buildfile($self->{releasetop}."/".$thisfile);
378            $bf->ParseBuildFile($self->{releasetop}, $classdir,
379                                                $self->{buildfilename});
380         }
381         return $bf;
382 }
383
384 sub _topbuildfile {
385    my $self=shift;
386
387    # -- Analyse project buildfile if it exists
388    $self->{topbf}=BuildSystem::BuildFile->new($self->{area});
389
390    $self->{topbf}->buildfile($self->{localtop}."/".$self->{projconfigdir}
391                ."/".$self->{buildfilename});
392    # -- generate top level makefile
393    $self->verbose("Generating Top Level BuildFile");
394    undef $ENV{LatestBuildFile};
395    $self->{topbf}->ParseBuildFile($self->{localtop},
396                        $self->{projconfigdir},$self->{buildfilename});
397
398    my @ClassPaths=split /:/, $self->{topbf}->BlockClassPath();
399    foreach $BClassPath ( @ClassPaths ) {
400      next if ( $BClassPath eq "");
401      push @{$self->{LoBCA}}, [ split /\//, $BClassPath ];
402    }
403
404 }
405
406 sub _checkdatestampindir {
407        my $self=shift;
408        my $dir=shift;
409        
410        # -- get all local .ds files
411        my $fh=FileHandle->new();
412        my $ldir=$self->{localtop}."/".$self->{workdir}."/".$dir;
413        opendir $fh, $ldir;
414        my @dsfiles= grep /^.*\.ds$/, readdir $fh;
415        $fh->close();                  
416
417        # -- copy across ds files from releasetop if not existing locally
418        if ( $#dsfiles < 0 ) {
419          # -- get all releasetop .ds files
420          my $rdir=$self->{releasetop}."/".$self->{workdir}."/".$dir;
421          opendir $fh, $rdir;
422          my @releasedsfiles= grep /^.*\.ds$/, readdir $fh;
423          foreach $file ( @releasedsfiles ) {
424                use File::Copy;
425                $self->verbose("Copying $file from $rdir to $ldir");
426                copy($rdir."/".$file,$ldir."/".$file);
427          }
428          $fh->close();
429          @dsfiles=@releasedsfiles;
430        }
431
432        # -- process ds files
433        my $file;
434        foreach $datafile ( @dsfiles ) {
435          $self->verbose("Processing $ldir/$datafile\n");
436          my $ds=BuildSystem::DateStampRecord->new($ldir."/".$datafile);
437          $ds->verbosity($self->verbosity());
438          my $needsupdate;
439          my $productfile=$ds->product();
440          my (%files,%moddate);
441
442          # now get dates in our dependency list
443          my @datedfiles=$ds->dated();
444          if ( $#datedfiles >= 0 ) {
445            
446             $needsupdate=1;
447             $date=$datedfiles[0][1]-1;
448          }
449          else {
450           # -- extra checks for local replacement of files
451           foreach $file ( $ds->contents() ) {
452            # -- only check files
453            if ( -f $file ) {
454             $files{$file}=$ds->filedate($file);
455             # -- check to see if we have a new local copy
456             if ( ($file=~/\Q$self->{releasetop}\E/) &&
457                                ($self->{releasetop} ne $self->{localtop}) ) {
458              ($tempfile=$file)=~s/\Q$self->{releasetop}\E/$self->{localtop}/;
459              if ( -f $tempfile ) {
460                $files{$tempfile}=$files{$file};
461                $file=$tempfile;
462              }
463             }
464             $moddate{$file}=(stat($file))[9];
465             if ( $moddate{$file} != $files{$file} ) {
466              $self->verbose($file." changed");
467              $date=$moddate{$file}-1;
468              $needsupdate=1;
469             }
470            }
471           }
472          }
473          # time stamp the product file to be older than the dependencies
474          if ( $needsupdate == 1 ) { # touch file into the past
475          my $newproductfile;
476          if ( $productfile!~/\Q$self->{localtop}\E/ ) {
477           if ( $productfile=~/\Q$self->{releasetop}\E/ ) {
478             ($newproductfile=$productfile)=~
479                        s/\Q$self->{releasetop}\E/$self->{localtop}/;
480             $self->verbose("Copying $productfile to $newproductfile");
481             copy($productfile,$newproductfile);
482           }
483           else { # assume no path to worry about
484             $newproductfile=$self->{localtop}."/".$ENV{workdir}.
485                                                      "/".$productfile;
486              # -- make a local copy of the product file if not already here
487              my $oldproductfile=$self->{releasetop}."/".$ENV{workdir}.
488                                                        "/".$productfile;
489             if ( ! -f $newproductfile ) {
490              if ( -f $oldproductfile ) {  
491                $self->verbose("Copying $oldproductfile to $newproductfile");
492                copy($oldproductfile,$newproductfile);
493              }
494             }
495           }
496          }
497          else {
498             $newproductfile=$productfile;
268            }
500          if ( -f $newproductfile ) {
501            $self->verbose("Blasting $newproductfile to the past ($date)");
502            # If the (local) productfile exists - make it older
503            utime($date,$date,$newproductfile);
504          }
505          else {
506            $self->verbose("SomeThing Wrong(?) with $newproductfile\n".
507                "RELEASETOP=".$self->{releasetop}."\n".
508                "LOCALTOP=".$self->{localtop}."\n".
509                "workdir=".$ENV{workdir});
510          }
269          }
270 <        else {
271 <          $self->verbose("No need to touch $productfile");
272 <        }      
515 <        }
516 <        undef $fh;                  
270 >    }
271 >    $ClassDir=~s/^\.\///;
272 >    return ( $Class, $ClassDir, $bf);
273   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines