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.10 by williamc, Sat Oct 14 17:29:05 2000 UTC

# Line 14 | Line 14 | use Utilities::Verbose;
14   use Utilities::SCRAMUtils;
15   use BuildSystem::BuildFile;
16   use BuildSystem::DateStampRecord;
17 + use BuildSystem::Block;
18   use Utilities::AddDir;
19   @ISA=qw(Utilities::Verbose);
20  
# Line 31 | Line 32 | sub new {
32          }
33          $self->{releasetop}=$self->{releasearea}->location();
34          $self->{buildfilename}="BuildFile";
35 <        #$self->verbosity(1);
35 >        $self->verbosity(1);
36          $self->_configurationsetup();
37          return $self;
38   }
# Line 61 | Line 62 | sub _generateexternals {
62            $fout->open(">".$outfile) or die "Unable to open $outfile for output".
63                                          $!."\n";
64  
65 <          # -- print out tool/ version info
65 >          # -- print out tool/version info
66            my ($tool,$toolobj,$f,$val,$version);
67            foreach $tool ( $self->{toolbox}->tools() ) {
68              $version=$self->{toolbox}->defaultversion($tool);
# Line 85 | Line 86 | sub _generateexternals {
86               print $fout "endif\n";
87              }
88            }
89 <          # some addittional processing of specific vars
89 >          # -- some addittional processing of specific vars
90            print $fout 'INCLUDEPATH+=$(addprefix -I,$(INCLUDE))'."\n";
91            print $fout 'LDFLAGS+=$(addprefix -L,$(LIBDIR))'."\n";
92            print $fout 'CPPFLAGS+=$(addprefix -D,$(CPPDEFINES))'."\n";
# Line 94 | Line 95 | sub _generateexternals {
95            print $fout 'LDLIBS+=$(addprefix -l,$(REQUIRES))'."\n";
96  
97            undef $fout;
98 <          $self->verbose("End Configuration Setup");
98 >          $self->verbose("End Externals Configuration Setup");
99          }
100   }
101  
# Line 151 | Line 152 | sub classsetup {
152          return ($Class,$ClassDir,$classmakefile);
153   }
154  
155 + sub _blockdir {
156 +        my $self=shift;
157 +        my $dir=shift;
158 +
159 +        if ( ! defined $self->{blocks}{$dir} ) {
160 +           $self->{blocks}{$dir}=BuildSystem::Block->new();
161 +        }
162 +        return $self->{blocks}{$dir};
163 + }
164 +
165   sub _configurationsetup {
166          my $self=shift;
167  
# Line 240 | Line 251 | sub BuildDir {
251      # rather than just those which are older than their dependencies
252      $self->_checkdatestampindir($ClassDir);
253  
243        # -- call the block building method
244        #$report=$bs->build(@Targets);
245        
254  
255      # The main build here
256      $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}", @Targets);
# Line 253 | Line 261 | sub BuildDir {
261   sub BuildIt {
262          my $self=shift;
263          my $dir=shift;
264 +        my @Targets=@_;
265 +
266  
267 <        # -- get the building block for the directory
268 <        my $block=$self->_getdirblock($dir);
267 >        # -- get the top building block
268 >        my $topblock=$self->_gettopblock();
269  
270          # -- is there a class block associated with the directory?
271 <        my ($class)=getclass($dir);
272 <        my $classblock=$self->_getclassblock($class);
271 >        my ($Class,$ClassDir)=getclass($dir);
272 >        my $classblock=$self->_getclassblock($Class,$topblock);
273 >
274 >        # -- If target not specified default to the class name target
275 >        if ( $targetnumber == -1 ) {
276 >          push @Targets,$Class;
277 >        }
278 >
279 >        # -- Create working directory
280 >        my $workdir=$self->{workdir}."/".$ClassDir;
281 >        chdir $self->{localtop};
282 >        AddDir::adddir($workdir);
283 >        $ENV{workdir}=$workdir;
284 >        my $fullworkdir=$self->{localtop}."/".$ENV{workdir};
285 >        chdir $fullworkdir || die "Unable to enter working directory $!";
286  
287          # -- Search for Blocks up to tree root
288          my @dirblocks=();
289          my @dirs=split /\//, $dir;
290          my $fulldir="";
291 <        foreach $dire ( "/",@dirs ) {
292 <              $fulldir=$fulldir."/".$dire;  # root is //
293 <              my $block=$self->_getdirblock($fulldir);
294 <              last if $block->ignore(); # we dont need to go futher
295 <              push @dirblocks, $block;
296 <        }
297 <        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 <                }
291 >        my $currentblock=$classblock;
292 >        foreach $dire ( @dirs ) {
293 >              ($fulldir eq "")?$fulldir=$dire
294 >                              :$fulldir=$fulldir."/".$dire;  
295 >              my $block=$self->_getdirblock($fulldir,$currentblock);
296 >              if ( defined $block ) {
297 >                 $currentblock=$block;
298                }
299          }
300  
301 <        # -- call the builder
301 >        # -- Create a makefile to include both BuildFile and
302 >        #    class makefile
303 >
304 >        my $fh=FileHandle->new();
305 >        my $mfile=$fullworkdir."/BuildFile.mk";
306 >        $fh->open($mfile);
307 >        if ( -e $ENV{LatestBuildFile} ) {
308 >          print $fh "include $ENV{LatestBuildFile}\n";
309 >        }
310 >
311 >        # -- Parse the local BuildFile
312 >        my $dbf=$self->_getdirbuildfile($dir);
313 >        if ( defined $dbf ) {
314 >          $dbf->Parsetofh($fh,$currentblock);
315 >        }
316 >
317 >        # -- Parse the class BuildFile
318 >        my $cbf=$self->_getclassbuildfile($class);
319 >        if ( defined $cbf ) {
320 >          $cbf=>Parsetofh($fh,$currentblock);
321 >        }
322 >        $fh->close();                  
323 >        $ENV{DefaultMakefile}=$mfile;
324 >
325 >        # -- Hack around make by checking datestamps in local working and
326 >        #    in _class_ working directories
327 >        $self->_checkdatestampindir($ClassDir);
328 >        opendir $fh, $ClassDir;
329 >        my @dfiles= grep { -d $_ } readdir $fh;
330 >        undef $fh;
331 >        foreach $dir ( @dfiles ) {
332 >          if ( $dir=~/^_class_/ ) {
333 >           $self->_checkdatestampindir($ClassDir."/".$dir);
334 >          }
335 >        }
336 >
337 >        # -- Call gmake to do the actual build
338 >        $rv=system("gmake","--no-print-directory","-r","-k","-f",
339 >                "$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}", @Targets);
340 >        return $rv/256; # return the exit status of gmake  
341 > }
342 >
343 > #
344 > # -- Block generation Routines
345 > #
346 >
347 > sub _getclassblock {
348 >        my $self=shift;
349 >        my $key=shift;
350 >
351 >        if ( ! defined $self->{classblocks}{$key} ) {
352 >            $self->{classblocks}{$key}=BuildSystem::Block->new();
353 >            # -- get class buildfile
354 >            my $bf=$self->_getclassbf($class);
355 >            if ( @_ ) {
356 >              $self->{classblocks}{$key}->parent(shift);
357 >            }
358 >            $bf->BlockParse($self->{classblocks}{$key});
359 >        }
360 >        return $self->{classblocks}{$key};
361  
362   }
363  
364 + sub _gettopblock {
365 +        my $self=shift;
366 +
367 +        return $self->_getclassblock($self->{buildfilename});
368 + }
369 +
370   sub _getdirblock {
371          my $self=shift;
372          my $dir=shift;
373 +        my $block=shift;
374  
375          if ( ! defined $self->{blocks}{$dir} ) {
297        
376            # -- get a buildfile and do a block parse
377 <          my $bf=$self->_startbuildfile($dir);
377 >          $self->{blocks}{$dir}=BuildSystem::Block->new();
378 >          my $bf=$self->_getbuildfile($dir);
379 >          $self->{blocks}{$dir}->parent($block);
380            $bf->blockparse($self->{blocks}{$dir});
301          
381          }
382          return $self->{blocks}{$dir};
383   }
384  
385 + #
386 + # -- BuildFile generation routines
387 + #
388 +
389 + sub _getclassbf {
390 +        my $self=shift;
391 +        my $class=shift;
392 +
393 +        if ( ! defined $self->{classbf}{$class} ) {
394 +
395 +          # -- determine BuildFile or makefile
396 +          my $fname=$self->{localtop}."/".$self->{projconfigdir}.
397 +                                                        "/".$class."_";
398 +          if ( -f $fname.$self->{buildfilename} ) {
399 +             $fname=$fname.$self->{buildfilename};
400 +          }
401 +          elsif ( -f $fname."makefile.mk" ) {
402 +             $fname=$fname."makefile.mk";
403 +          }
404 +          else {
405 +             $self->error("$fname.$self->{buildfilename} does not exist in".
406 +                        $self->{projconfigdir});
407 +          }
408 +
409 +          # -- create a BuildFile object
410 +          $self->{classbf}{$class}=BuildSystem::BuildFile->new($self->{area});
411 +          $self->{classbf}{$class}->buildfile($fname);
412 +        }
413 +        return $self->{classbf}{$class};
414 + }
415 +
416 + sub _gettopbuildfile {
417 +        my $self=shift;
418 +
419 +        if ( ! defined $self->{topbf} ) {
420 +          $self->{topbf}=BuildSystem::BuildFile->new($self->{area});
421 +          $self->{topbf}->buildfile($self->{localtop}."/".
422 +                        $self->{projconfigdir}."/".$self->{buildfilename});
423 +        }
424 +        return $self->{topbf};
425 + }
426 +
427 + #
428 + # Returns undef if BF does not exist at this dir level
429 + #
430 + sub _getdirbuildfile {
431 +        my $self=shift;
432 +        my $dir=shift;
433 +
434 +        if ( ! exists $self->{dirbf}{$dir} ) {
435 +          # -- determine if local or releasetop
436 +          my $fname=$self->{path}."/".$self->{buildfilename};
437 +          if ( -f $self->{localtop}."/".$fname ) {
438 +            $fname=$self->{localtop}."/".$fname;
439 +          }
440 +          elsif ( -f $self->{releasetop}."/".$fname ) {
441 +            $fname=$self->{releasetop}."/".$fname;
442 +          }
443 +          else {
444 +                $self->{dirbf}{$dir}=undef;
445 +                return $self->{dirbf}{$dir};
446 +          }
447 +
448 +          # -- construct the bf object
449 +          $self->{dirbf}{$dir}=BuildSystem::BuildFile->new($self->{area});
450 +          $self->{dirbf}{$dir}->buildfile($fname);
451 +
452 +        }
453 +        return $self->{dirbf}{$dir};
454 + }
455 +
456   sub getclass {
457      my $self=shift;
458      my $dirname = shift;
# Line 384 | Line 534 | sub _startbuildfile {
534   sub _topbuildfile {
535      my $self=shift;
536  
537 +    $self->verbose("Generating Top Level BuildFile");
538      # -- Analyse project buildfile if it exists
388    $self->{topbf}=BuildSystem::BuildFile->new($self->{area});
539  
540 <    $self->{topbf}->buildfile($self->{localtop}."/".$self->{projconfigdir}
541 <                ."/".$self->{buildfilename});
540 >    my $topbf=$self->_gettopbuildfile();
541 >
542      # -- generate top level makefile
393    $self->verbose("Generating Top Level BuildFile");
543      undef $ENV{LatestBuildFile};
544 <    $self->{topbf}->ParseBuildFile($self->{localtop},
544 >    $topbf->ParseBuildFile($self->{localtop},
545                          $self->{projconfigdir},$self->{buildfilename});
546  
547 +    # -- Extract BuildStructure Information
548      my @ClassPaths=split /:/, $self->{topbf}->BlockClassPath();
549      foreach $BClassPath ( @ClassPaths ) {
550        next if ( $BClassPath eq "");
551        push @{$self->{LoBCA}}, [ split /\//, $BClassPath ];
552      }
553 <
553 >    $self->verbose("End top buildfile generation");
554   }
555  
556   sub _checkdatestampindir {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines