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.6 by williamc, Tue Sep 19 10:09:30 2000 UTC vs.
Revision 1.7 by williamc, Wed Sep 20 16:47:45 2000 UTC

# Line 3 | Line 3
3   # Interface
4   # ---------
5   # new(ConfigArea) : A new BuildSetup
6 < # BuildSetup(directory,targets) : prepare the ground for a build and build
6 > # BuildDir(directory,targets) : prepare the ground for a build and build
7   # getclass(directory) : return (Class, ClassDir, BuildFileobject)
8   #                       associated with directory
9   # setup(dir)
# Line 13 | Line 13 | require 5.004;
13   use Utilities::Verbose;
14   use Utilities::SCRAMUtils;
15   use BuildSystem::BuildFile;
16 + use BuildSystem::DateStampRecord;
17   use Utilities::AddDir;
18   @ISA=qw(Utilities::Verbose);
19  
# Line 24 | Line 25 | sub new {
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();
35          return $self;
# Line 177 | Line 183 | sub BuildDir {
183          my $fullworkdir=$self->{localtop}."/".$ENV{workdir};
184          chdir $fullworkdir || die "Unable to enter working directory $!";
185  
186 <        # -- setup Class specifics
186 >        # -- Setup Class specifics
187          ($Class,$ClassDir,$classmakefile)=$self->classsetup($THISDIR);
188          $ENV{classmakefile}=$classmakefile;
189          $ENV{Class}=$Class;
# Line 232 | Line 238 | sub BuildDir {
238  
239      # Do a datestamp check so that make will build files that have changed
240      # 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}",datestamp_config);
237 <    $rv=system("gmake","--no-print-directory","-r","-k","-f","$ENV{DefaultMakefile}","-I$ENV{TOOL_HOME}",datestamp, @Targets);
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   }
247  
# Line 285 | Line 292 | sub getclass {
292        $ClassDir=".";
293      }
294  
295 <    # -- retunrs
295 >    # -- returns
296      ($ClassDir_c=$ClassDir)=~s/^\.\///;
297      return ( $Class, $ClassDir_c, $self->{pathbf}{$ClassDir});
298   }
# Line 334 | Line 341 | sub _topbuildfile {
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;                  
444 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines