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.7 by williamc, Wed Sep 20 16:47:45 2000 UTC vs.
Revision 1.17 by sashby, Fri Oct 19 18:14:22 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->_configurationsetup();
23 >        $self->{toolbox}=shift;
24          return $self;
25   }
26  
27 < sub _generateexternals {
28 <        my $self=shift;
29 <        my $outfile=shift;
30 <
31 <        # -- specifiy 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() ) {
69 <              foreach $val ( $toolobj->getfeature($f) ) {
70 <                print $fout "\t".$f." += ".$val."\n";
71 <              }
72 <             }
73 <             print $fout "endif\n";
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 >      # -- 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 <
118 <          undef $fout;
119 <          $self->verbose("End Configuration Setup");
120 <        }
121 < }
99 <
100 < sub classsetup {
101 <        my $self=shift;
102 <        my $THISDIR=shift;
103 <
104 <        my $classmakefile;
105 <
106 <        my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR);
107 <        $self->verbose("Class = $Class : ClassDir = $ClassDir for directory ".
108 <                        $THISDIR);
109 <
110 <        # -- should we ignore?
111 <        if ( $bf->ignore() ) {
112 <           print "Nothing to be done - empty group\n";
113 <           exit;
114 <        }      
115 <
116 <
117 <        # -- Create a makefile from the class BuildFile
118 <        my $classbuildfile=$self->{localtop}."/".
119 <                $self->{projconfigdir}."/".$Class."_BuildFile";
120 <        if ( -f $classbuildfile ) {
121 <              $classmakefile=$self->{localtop}."/".$ENV{INTwork}.
122 <                                        "/".$Class."_makefile.mk";
123 <              if ( SCRAMUtils::dated($classmakefile, $classbuildfile) ) {
124 <                # -- generate the new makefile if out of date
125 <                $self->verbose("Generating $classmakefile from".
126 <                                                " $classbuildfile");
127 <                my $classbf=BuildSystem::BuildFile->new($self->{area});
128 <                undef $ENV{LatestBuildFile}; # gets set by BuildFile
129 <                $classbf->GenerateMakefile($classbuildfile, $classmakefile);
130 <                undef $ENV{LatestBuildFile}; # we dont want this included in the
131 <                                             # hierarchy
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});
164 <
165 <        # -- generate tool info
166 <        $self->_generateexternals($self->{fullworkdir}."/clientmakefile");
167 <
168 <        # -- process project BuildFile
169 <        $self->_topbuildfile();
170 < }
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 <        # -- Create working directory
130 <        my $workdir=$self->{workdir}."/".$THISDIR;
131 <        chdir $self->{localtop};
132 <        AddDir::adddir($workdir);
133 <        $ENV{workdir}=$workdir;
134 <        my $fullworkdir=$self->{localtop}."/".$ENV{workdir};
135 <        chdir $fullworkdir || die "Unable to enter working directory $!";
136 <
137 <        # -- Setup Class specifics
138 <        ($Class,$ClassDir,$classmakefile)=$self->classsetup($THISDIR);
139 <        $ENV{classmakefile}=$classmakefile;
140 <        $ENV{Class}=$Class;
141 <        $ENV{ClassDir}=$ClassDir;
142 <        $DefaultBuildFile=$ENV{classmakefile};
143 <        $ENV{DefaultBuildFile}=$DefaultBuildFile;
123 > sub BuildSetup
124 >   {
125 >   ###############################################################
126 >   # BuildSetup                                                  #
127 >   ###############################################################
128 >   # modified : Fri Aug 10 16:57:03 2001 / SFA                   #
129 >   # params   :                                                  #
130 >   #          :                                                  #
131 >   #          :                                                  #
132 >   #          :                                                  #
133 >   # function : Build targets.                                   #
134 >   #          :                                                  #
135 >   #          :                                                  #
136 >   ###############################################################
137 >   my $self=shift;
138 >   my $THISDIR=shift;
139 >   my @Targets=@_;
140 >   my $DefaultBuildFile="";
141 >   my $Class="";
142 >
143 >   # -- Create working directory
144 >   chdir $ENV{LOCALTOP};
145 >   AddDir::adddir($ENV{INTwork}."/".$THISDIR);
146 >
147 >   my ($Class, $ClassDir, $bf)=$self->getclass($THISDIR);
148 >   $self->verbose("Class = $Class");
149 >   $self->verbose("ClassDir = $ClassDir");
150          
151 +   if ( $bf->ignore() )
152 +      {
153 +      print "Nothing to be done - empty group\n";
154 +      exit;
155 +      }
156 +   shift;
157 +   $self->_generateexternals($ENV{LOCALTOP}."/".$ENV{INTwork}."/clientmakefile");
158 +
159 +   # set up the workdir variable
160 +   $ENV{workdir}=$ENV{INTwork}."/".$ClassDir;
161 +   my $fullworkdir=$ENV{LOCALTOP}."/".$ENV{workdir};
162 +  
163 +   # set up projdeps variable
164 +   my $projectfile=$ENV{projconfigdir}."/External_Dependencies";
165 +   if ( -e $ENV{LOCALTOP}."/".$projectfile )
166 +      {
167 +      $ENV{projdeps}=$ENV{LOCALTOP}."/".$projectfile;
168 +      }
169 +   elsif ( -e $ENV{RELEASETOP}."/".$projectfile )
170 +      {
171 +      $ENV{projectfile}=$ENV{RELEASETOP}."/".$projectfile;
172 +      }
173 +   if ( $DefaultBuildFile eq "" )
174 +      {
175 +      # Map Relevant makefile classmakefile directory
176 +      my $classmakefile=$ENV{projconfigdir}."/".$Class."_makefile.mk";
177 +      if ( -e $ENV{LOCALTOP}."/".$classmakefile )
178 +         {
179 +         $ENV{classmakefile}=$ENV{LOCALTOP}."/".$classmakefile;
180 +         }
181 +      elsif ( -e $ENV{RELEASETOP}."/".$classmakefile )
182 +         {
183 +         $ENV{classmakefile}=$ENV{RELEASETOP}."/".$classmakefile;
184 +         }
185 +      else
186 +         {
187 +         print "\nUnable to locate $classmakefile\n";
188 +         print " Not in $ENV{LOCALTOP}\n";
189 +         print " Not in $ENV{RELEASETOP}\n";
190 +         exit 1;
191 +         }
192 +      $DefaultBuildFile=$ENV{classmakefile}; # TODO - only for override
193 +      }
194 +  
195 +   $ENV{ClassDir}=$ClassDir;
196 +   $ENV{Class}=$Class;
197 +   $ENV{DefaultBuildFile}=$DefaultBuildFile;
198 +  
199 +   chdir $fullworkdir || die "Unable to enter working directory $!";
200 +
201 +   # Set up some other useful variables fo the Build
202 +   # list of directories available
203 +   opendir IDR, "$ENV{LOCALTOP}/$THISDIR";
204 +   @allfiles= grep !/^\.\.?$/, readdir IDR;
205 +   foreach $file ( @allfiles )
206 +      {
207 +      if ( -d "$ENV{LOCALTOP}/$THISDIR/$file" )
208 +         { # only add if its a directory
209 +         $ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
210 +         }
211 +      else
212 +         {
213 +         $ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
214 +         }
215 +      }
216 +   $targetnumber=$#Targets;
217  
218 <        # -- Set up some other useful variables for the Build
219 <        # set variables listing directories/files available
220 <        my $fh=FileHandle->new();
221 <        opendir $fh, "$self->{localtop}/$THISDIR";
222 <        my @allfiles= grep !/^\.\.?$/, readdir $fh;
223 <        undef $fh;
224 <        foreach $file ( @allfiles ) {
225 <         if ( -d "$self->{localtop}/$THISDIR/$file" ) {
226 <           $ENV{SCRAM_AVAILDIRS}=$ENV{SCRAM_AVAILDIRS}." ".$file;
227 <         }
228 <         else {
229 <           $ENV{SCRAM_AVAILFILES}=$ENV{SCRAM_AVAILFILES}." ".$file;
230 <         }
231 <        }
232 <        my $targetnumber=$#Targets;
210 <        $ENV{"MAKETARGETS"}="";
211 <        foreach $word ( @Targets ) {
212 <         if ( $word=~/.*=.*/ ) { # if we have an assignment it cant be a target
213 <           $targetnumber--;
214 <         }
215 <         else {
216 <          # set some variables for use in makefiles
217 <          $ENV{"MAKETARGET_".$word}=$word;
218 <          if ( $ENV{"MAKETARGETS"} ne "" ) {
219 <            $ENV{"MAKETARGETS"}=$ENV{"MAKETARGETS"}." ".$word;
220 <          }
221 <          else {
222 <            $ENV{"MAKETARGETS"}=$word;
223 <          }
224 <         }
225 <        }
218 >   foreach $word ( @Targets )
219 >      {
220 >      if ( $word=~/.*=.*/ )
221 >         { # if we have an assignment it cant be a target
222 >         $targetnumber--;
223 >         }
224 >      elsif ( $word=~/^-/ )
225 >         {
226 >         $targetnumber--;
227 >         }
228 >      else
229 >         {
230 >         $ENV{"MAKETARGET_".$word}=$word;
231 >         }
232 >      }
233  
234 <       # -- If target not specified default to the class name target
235 <       if ( $targetnumber == -1 ) {
236 <        push @Targets,$Class;
237 <       }
234 >   # If not specified default to the class name target
235 >   if ( $targetnumber == -1 )
236 >      {
237 >      push @Targets,$Class;
238 >      }
239  
240 <    $ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk";
240 >   $ENV{DefaultMakefile}="$ENV{TOOL_HOME}/basics.mk";
241  
242 <    $SCRAM_GROUPSDIR=$self->{localtop}."/".$self->{projconfigdir}."/groups.mk";
243 <    if ( -f $SCRAM_GROUPSDIR ) {
242 >   $SCRAM_GROUPSDIR=$ENV{LOCALTOP}."/".$ENV{projconfigdir}."/groups.mk";
243 >   if ( -f $SCRAM_GROUPSDIR )
244 >      {
245        $ENV{SCRAM_GROUPSDIR}=$SCRAM_GROUPSDIR;
246 <    }
246 >      }
247 >  
248 >   # Do a datestamp check so that make will build files that have changed
249 >   # rather than just those which are older than their dependencies
250 >   # The main build here
251 >   $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp_config);
252 >
253 > #   my $gmakejobsflag = "-j";
254 > #   chomp(my $currentOS = `uname`);
255 >  
256 >   # Only use -j option if there are more then 1 cpu's.....
257 > #   if ( $currentOS eq "Linux" )
258 > #      {
259 > #      chomp($ncpu=`cat /proc/cpuinfo | grep -c processor`);
260 > #      }
261 > #   elsif ( $currentOS eq "SunOS" )
262 > #      {
263 > #      ($ncpu) = (`/usr/sbin/psrinfo | wc -l` =~ /\s+(\d+)/);
264 > #      }
265 > #   else
266 > #      # Who knows what the OS is? Leave as default:
267 > #      {
268 > #      $ncpu = 1;
269 > #      }
270 > #
271 >   # Print a little debug message:
272 > #   print "\n","scram BUILDSYSTEM(v1.0) >> Scram has determined that your system has ",$ncpu," CPU(s).","\n";
273 >   # Temporarily hard-code ncpu as 1:
274 >   $ncpu = 1;
275 > #   print "                        >> Multi-CPU builds not supported yet.","\n\n";
276 >  
277 >   # Modify: try to force make to spawn more than one job (option: -j ).
278 >   $rv=system("gmake","--no-print-directory","$gmakejobsflag","$ncpu","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets);
279  
280 <    # Do a datestamp check so that make will build files that have changed
281 <    # rather than just those which are older than their dependencies
241 <    $self->_checkdatestampindir($THISDIR);
242 <
243 <    # The main build here
244 <    $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}", @Targets);
245 <    return $rv/256; # return the exit status of gmake
246 < }
280 >   return $rv/256; # return the exit status of gmake
281 >   }
282  
283   sub getclass {
284      my $self=shift;
# Line 251 | Line 286 | sub getclass {
286      my $Class="DEFAULT";
287      my $ClassDir="";
288          
254    #return if $dirname eq "";
289      @DIRA=split /\//, $dirname;
290  
291 <    my $thispath=".";
292 <    # -- construct all class buildfiles in the path
291 >    $thispath=".";
292 >    # bootstrap from project buildfile if it exists
293 >    my $bf=BuildSystem::BuildFile->new($self->{toolbox});
294 >    $bf->CheckBuildFile($ENV{projconfigdir});
295 >
296 >    my @ClassPaths=split /:/, $bf->BlockClassPath();
297 >    foreach $BClassPath ( @ClassPaths ) {
298 >      next if ( $BClassPath eq "");
299 >      push @LoBCA, [ split /\//, $BClassPath ];
300 >    }
301      for ( $i=0; $i<=$#DIRA; $i++ ) {
302 <        #$thispath=(($thispath eq "")?$DIRA[$i]:$thispath."/".$DIRA[$i]);
303 <        $thispath=$thispath."/".$DIRA[$i];
304 <        if ( ! exists $self->{pathbf}{$thispath} ) {
263 <          $self->verbose("Initialising BuildFile in $thispath");
264 <          $self->{pathbf}{$thispath}=$self->_startbuildfile($thispath);
265 <        }
266 <        # -- check class overriden by BuildFile
267 <        if ( defined $self->{pathbf}{$thispath}->classname() ) {
268 <                $Class=$self->{pathbf}{$thispath}->classname();
302 >        $thispath=$thispath."/".$DIRA[$i];
303 >        if ( ($ClassName=$bf->CheckBuildFile($thispath)) ne "" ) {
304 >                $Class=$ClassName;
305                  $ClassDir=$thispath;
306          }
307 +        # TODO --- Must test against position of last new BlockCaseA
308 +        # Need to reset array LoBCA to the New BlockPath
309 +        # - merge and replace options
310 +        #
311          else {
312 <          # -- sort it out from classpath directives
313 <          foreach $BlockClassA ( @{$self->{LoBCA}} ) {
314 <           foreach $elem ( @$BlockClassA ) {
275 <            if ( $elem=~/^$DIRA[$i]\+/ ) {
276 <                $elem=~s/^$DIRA[$i]//;
312 >          foreach $BlockClassA ( @LoBCA ) {
313 >            if ( $$BlockClassA[0]=~/^$DIRA[$i]\+/ ) {
314 >                $$BlockClassA[0]=~s/^$DIRA[$i]//;
315              }
316 <            if ( $elem=~/^\+/ ) {
317 <                ($Class=$elem)=~s/^\+//;
316 >            if ( $$BlockClassA[0]=~/^\+/ ) {
317 >                ($Class=$$BlockClassA[0])=~s/^\+//;
318                  $ClassDir=$thispath;
319 +                shift @$BlockClassA;
320 +            }
321 +            else {
322 +                @$BlockClassA=();
323              }
324            }
283         }
325          }
326      }
327 <    # -- default case
328 <    if ( $ClassDir eq "" ) {
288 <      if ( ! defined $self->{pathbf}{'.'}) {
289 <          $self->{pathbf}{'.'}=$self->_startbuildfile(".");
290 <          $self->verbose("DEFAULT class initialised : ".$self->{pathbf}{'.'});
291 <      }
292 <      $ClassDir=".";
293 <    }
294 <
295 <    # -- returns
296 <    ($ClassDir_c=$ClassDir)=~s/^\.\///;
297 <    return ( $Class, $ClassDir_c, $self->{pathbf}{$ClassDir});
298 < }
299 <
300 < #
301 < # Check to see if the buildfile is local or in the release area and
302 < # parse appropriately
303 < #
304 < sub _startbuildfile {
305 <         my $self=shift;
306 <         my $classdir=shift;
307 <
308 <         my $bf=BuildSystem::BuildFile->new($self->{area});
309 <         my $thisfile="$classdir/$self->{buildfilename}";
310 <
311 <         if ( -e $self->{localtop}."/".$thisfile ) {
312 <            $bf->buildfile($self->{localtop}."/".$thisfile);
313 <            $bf->ParseBuildFile($self->{localtop}, $classdir,
314 <                                $self->{buildfilename});
315 <         }
316 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
317 <            $bf->buildfile("$ENV{RELEASETOP}/$thisfile");
318 <            $bf->ParseBuildFile($ENV{RELEASETOP}, $classdir,
319 <                                                $slef->{buildfilename});
320 <         }
321 <         return $bf;
322 < }
323 <
324 < sub _topbuildfile {
325 <    my $self=shift;
326 <
327 <    # -- Analyse project buildfile if it exists
328 <    $self->{topbf}=BuildSystem::BuildFile->new($self->{area});
329 <
330 <    $self->{topbf}->buildfile($self->{localtop}."/".$self->{projconfigdir}
331 <                ."/".$self->{buildfilename});
332 <    # -- generate top level makefile
333 <    $self->verbose("Generating Top Level BuildFile");
334 <    $self->{topbf}->ParseBuildFile($self->{localtop},
335 <                        $self->{projconfigdir},$self->{buildfilename});
336 <
337 <    my @ClassPaths=split /:/, $self->{topbf}->BlockClassPath();
338 <    foreach $BClassPath ( @ClassPaths ) {
339 <      next if ( $BClassPath eq "");
340 <      push @{$self->{LoBCA}}, [ split /\//, $BClassPath ];
341 <    }
342 <
343 < }
344 <
345 < sub _checkdatestampindir {
346 <        my $self=shift;
347 <        my $dir=shift;
348 <        
349 <        # -- get all local .ds files
350 <        my $fh=FileHandle->new();
351 <        my $ldir=$self->{localtop}."/".$self->{workdir}."/".$dir;
352 <        opendir $fh, $ldir;
353 <        my @dsfiles= grep /^.*\.ds$/, readdir $fh;
354 <        $fh->close();                  
355 <
356 <        # -- copy across ds files from releasetop if not existing locally
357 <        if ( $#dsfiles < 0 ) {
358 <          # -- get all releasetop .ds files
359 <          my $rdir=$self->{releasetop}."/".$self->{workdir}."/".$dir;
360 <          opendir $fh, $rdir;
361 <          my @releasedsfiles= grep /^.*\.ds$/, readdir $fh;
362 <          foreach $file ( @releasedsfiles ) {
363 <                use File::Copy;
364 <                copy($rdir."/".$file,$ldir."/".$file);
365 <          }
366 <          $fh->close();
367 <          @dsfiles=@releasedsfiles;
368 <        }
369 <
370 <        # -- process ds files
371 <        my $file;
372 <        foreach $datafile ( @dsfiles ) {
373 <          my $ds=BuildSystem::DateStampRecord->new($datafile);
374 <          my $needsupdate;
375 <          my $productfile=$ds->product();
376 <          my (%files,%moddate);
377 <
378 <          # now get dates in our dependency list
379 <          foreach $file ( $ds->contents() ) {
380 <           # -- only check files
381 <           if ( -f $file ) {
382 <            $files{$file}=$ds->filedate($file);
383 <            # -- check to see if we have a new local copy
384 <            if ( ($file=~/\Q$self->{releasetop}\E/) &&
385 <                                ($self->{releasetop} ne $self->{localtop}) ) {
386 <              ($tempfile=$file)=~s/$self->{releasetop}/$self->{localtop}/;
387 <              if ( -f $tempfile ) {
388 <                $files{$tempfile}=$files{$file};
389 <                $file=$tempfile;
390 <              }
391 <            }
392 <            $moddate{$file}=(stat($file))[9];
393 <            if ( $moddate{$file} != $files{$file} ) {
394 <              $self->verbose($file." changed");
395 <              $date=$moddate{$file}-1;
396 <              $needsupdate=1;
397 <            }
398 <           }
399 <          }
400 <          # time stamp the product file to be older than the dependencies
401 <          if ( $needsupdate == 1 ) { # touch file into the past
402 <          my $newproductfile;
403 <          if ( $productfile!~/\Q$self->{localtop}\E/ ) {
404 <           if ( $productfile=~/\Q$self->{releasetop}\E/ ) {
405 <             ($newproductfile=$productfile)=~
406 <                        s/\Q$self->{releasetop}\E/$self->{localtop}/;
407 <             $self->verbose("Copying $productfile to $newproductfile");
408 <             copy($productfile,$newproductfile);
409 <           }
410 <           else { # assume no path to worry about
411 <             $newproductfile=$self->{localtop}."/".$ENV{workdir}.
412 <                                                      "/".$productfile;
413 <              # -- make a local copy of the product file if not already here
414 <              my $oldproductfile=$self->{releasetop}."/".$ENV{workdir}.
415 <                                                        "/".$productfile;
416 <             if ( ! -f $newproductfile ) {
417 <              if ( -f $oldproductfile ) {  
418 <                $self->verbose("Copying $oldproductfile to $newproductfile");
419 <                copy($oldproductfile,$newproductfile);
420 <              }
421 <             }
422 <           }
423 <          }
424 <          else {
425 <             $newproductfile=$productfile;
426 <          }
427 <          if ( -f $newproductfile ) {
428 <            $self->verbose("Blasting $newproductfile to the past");
429 <            # If the (local) productfile exists - make it older
430 <            utime($date,$date,$newproductfile);
431 <          }
432 <          else {
433 <            $self->verbose("SomeThing Wrong(?) with $newproductfile\n".
434 <                "RELEASETOP=".$self->{releasetop}."\n".
435 <                "LOCALTOP=".$self->{localtop}."\n".
436 <                "workdir=".$ENV{workdir});
437 <          }
438 <        }
439 <        else {
440 <          $self->verbose("No need to touch $productfile");
441 <        }      
442 <        }
443 <        undef $fh;                  
327 >    $ClassDir=~s/^\.\///;
328 >    return ( $Class, $ClassDir, $bf);
329   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines