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

Comparing COMP/SCRAM/src/BuildSystem/ToolManager.pm (file contents):
Revision 1.13 by sashby, Fri Oct 7 16:05:44 2005 UTC vs.
Revision 1.19 by muzaffar, Fri Dec 14 09:03:47 2007 UTC

# Line 18 | Line 18 | use BuildSystem::ToolParser;
18   use Utilities::AddDir;
19   use URL::URLhandler;
20   use Utilities::Verbose;
21 + use SCRAM::MsgLog;
22  
23   @ISA=qw(BuildSystem::ToolCache Utilities::Verbose);
24   @EXPORT_OK=qw( );
# Line 48 | Line 49 | sub new
49     $self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools";
50     $self->{datastore}=$self->{topdir}."/.SCRAM";
51     $self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH};
52 +   $self->{tooltimestamp}="timestamps";
53    
54     # Make sure our tool download dir exists:
55     AddDir::adddir($self->{toolfiledir});
# Line 127 | Line 129 | sub setupalltools()
129     # want to pick up everything from any scram-managed projects):
130     if ($setupopt == 1) # We're booting from scratch
131        {
130      # Check to see if there are any SCRAM-managed projects in our local requirements:
131      my $scramprojects = $::scram->_loadscramdb();
132      
132        # Look for a match in the scram db:
133        foreach my $S (@$selected)
134           {
136         if (exists ($scramprojects->{$S}))
137            {
138            # Now check the version required exists in
139            # list of scram projects with this name:
140            while (my ($pdata,$plocation) = each %{$scramprojects->{$S}})
141               {
142               # Split the $pdata string to get the real name and the version:
143               my ($pname,$pversion) = split(":",$pdata);
144               if ($pversion eq $self->defaultversion($S))
145                  {
146                  # Get the tool manager for the scram project:
147                  my $sa=$::scram->scramfunctions()->scramprojectdb()->getarea($pname,$pversion);
148                  # Load the tool cache:
149                  if ( -r $sa->toolcachename())
150                     {
151                     use Cache::CacheUtilities;
152                     my $satoolmanager=&Cache::CacheUtilities::read($sa->toolcachename());
153                     # Copy needed content from toolmanager for scram-managed project:
154                     $self->inheritcontent($satoolmanager);
155                     }
156                  }
157               }
158            # Also add this scram-managed project to list of tools to set up:
159            push(@localtools,$S);
160            }
161         else
162            {
135              # Store other tools in ReqDoc in separate array. We will set up these tools later:
136              push(@localtools,$S);
165            }
137           }
138        
139        # Set up extra tools required in this project, in addition to
# Line 178 | Line 149 | sub setupalltools()
149              }
150           else
151              {
152 <            print $localtool," already set up.","\n",if ($ENV{SCRAM_DEBUG});
152 >            scramlogmsg($localtool," already set up.","\n"),if ($ENV{SCRAM_DEBUG});
153              }
154           }
155        }
# Line 191 | Line 162 | sub setupalltools()
162           }
163        }
164    
165 <   print "\n";
165 >   scramlogmsg("\n");
166     }
167  
168   sub coresetup()
# Line 200 | Line 171 | sub coresetup()
171     my ($toolname, $toolversion, $toolfile, $force) = @_;
172     my ($toolcheck, $toolparser);
173    
174 <   print "\n";
204 <   print $::bold."Setting up ",$toolname," version ",$toolversion,":  ".$::normal,"\n";
174 >   scramlogmsg("\n",$::bold."Setting up ",$toolname," version ",$toolversion,":  ".$::normal,"\n");
175    
176     # New ToolParser object for this tool if there isn't one already.
177     # Look in array of raw tools to see if this tool has a ToolParser object:
# Line 216 | Line 186 | sub coresetup()
186     if ($toolcheck != 1 || $force == 1)
187        {
188        $toolparser = BuildSystem::ToolParser->new();
189 +      $toolparser->filehead('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">');
190 +      $toolparser->filetail('</doc>');
191        # We only want to store the stuff relevant for one particular version:
192        $toolparser->parse($toolname, $toolversion, $toolfile);
193        # Store the ToolParser object in the cache:
# Line 240 | Line 212 | sub coresetup()
212        $self->scram_compiler($supported_language[0],$toolname,$compilername[0]);
213        }
214    
215 <   # Store the ToolData object in the cache:
215 >   # Store the ToolData object in the cache:  
216     $self->storeincache($toolparser->toolname(),$store);
217     return $self;
218     }
# Line 389 | Line 361 | sub setupself()
361     my ($location)=@_;
362     # Process the file "Self" in local config directory. This is used to
363     # set all the paths/runtime settings for this project:
364 <   my $filename=$location."/config/Self";
364 >   my $filename=$location."/config/Self.xml";
365  
366     if ( -f $filename )
367        {
368 <      print "\n";
397 <      print $::bold."Setting up SELF:".$::normal,"\n";
368 >      scramlogmsg("\n",$::bold."Setting up SELF:".$::normal,"\n");
369        # Self file exists so process it:
370        $selfparser = BuildSystem::ToolParser->new();
371 +      $selfparser->filehead ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">');
372 +      $selfparser->filehead ('</doc>');
373        $selfparser->parse('self','SELF',$filename);
374  
375        # Next, set up the tool:
376        $store = $selfparser->processrawtool($self->interactive());
377 <      
377 >
378        # If we are in a developer area, also add RELEASETOP paths:
379        if (exists($ENV{RELEASETOP}))
380           {
# Line 411 | Line 384 | sub setupself()
384        
385        # Store the ToolData object in the cache:
386        $self->storeincache($selfparser->toolname(),$store);
387 <      print "\n";
387 >      scramlogmsg("\n");
388        }
389     else
390        {
391 +      scramlogdump();
392        print "\n";
393 <      print "SCRAM: No file config/Self...nothing to do.";
393 >      print "SCRAM: No file config/Self.xml...nothing to do.";
394        print "\n";
395        return;
396        }
# Line 438 | Line 412 | sub storeincache()
412     # Store ToolData object (for a set-up tool) in cache:
413     if (ref($dataobject) eq 'BuildSystem::ToolData')
414        {
415 +      $self->updatetooltimestamp($dataobject, $toolname);
416        $self->{SETUP}->{$toolname} = $dataobject;
417        }
418     else
# Line 551 | Line 526 | sub remove_tool()
526        }
527    
528     $self->{SETUP} = $newtlist;
529 <  
529 >   $self->updatetooltimestamp ("", $toolname);
530     # Now remove from the RAW tool list:
531     $self->cleanup_raw($toolname);
532     print "ToolManager: Updating tool cache.","\n";
# Line 604 | Line 579 | sub updatetool()
579        # the desired name:
580        if ($obj->toolname() eq $name)
581           {
582 +         $self->updatetooltimestamp ($obj, $name);
583           print "ToolManager: Updating the cached copy of ".$name."\n";
584           delete $self->{SETUP}->{$name};
585           $self->{SETUP}->{$name} = $obj;
# Line 621 | Line 597 | sub updatetool()
597        }
598     }
599  
600 + sub check_compatibility()
601 +   {
602 +   my $self=shift;
603 +   my ($itoolmgr)=@_;
604 +   # Get the version of the toolmanager. If the project fails to return a version
605 +   # string we return 0 for no compatibility (in which case, all tools will be set
606 +   # up in the traditional way):
607 +   my $itm_configversion = $itoolmgr->configversion();
608 +   if ($itm_configversion)
609 +      {
610 +      # The configurations won't be identical. We must compare the digits:
611 +      my ($numeric_version) = ($itm_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
612 +      my $current_configversion = $self->configversion();
613 +      my ($current_numeric_version) = ($current_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
614 +      ($current_numeric_version == $numeric_version) && return 1; # OK, compatible;
615 +      }
616 +   # Project does not define configuration version so just return:
617 +   return 0;
618 +   }
619 +
620 + sub configversion()
621 +   {
622 +   my $self=shift;
623 +   @_ ? $self->{CONFIGVERSION} = shift
624 +      : $self->{CONFIGVERSION};
625 +   }
626 +
627 + sub updatetooltimestamp ()
628 +   {
629 +   my $self=shift;
630 +   my $obj=shift;
631 +   my $toolname=shift;
632 +   my $samevalues=0;
633 +   my $stampdir = $self->{archstore}."/timestamps";
634 +   my $stampfile="${stampdir}/${toolname}";
635 +   if (exists $self->{SETUP}->{$toolname})
636 +      {
637 +      $samevalues=$self->comparetoolsdata($self->{SETUP}->{$toolname},$obj);
638 +      }
639 +   if ((!$samevalues) || (!-f $stampfile))
640 +      {
641 +      if (!-d $stampdir)
642 +         {
643 +         AddDir::adddir($stampdir);
644 +         }
645 +      open(TIMESTAMPFILE,">$stampfile");
646 +      close(TIMESTAMPFILE);
647 +      }
648 +   }
649 +
650 + sub comparetoolsdata ()
651 +   {
652 +   my $self=shift;
653 +   my $data1=shift || ();
654 +   my $data2=shift || ();
655 +  
656 +   my $ref1=ref($data1);
657 +   my $ref2=ref($data2);
658 +  
659 +   if ($ref1 ne $ref2)
660 +      {
661 +      return 0;
662 +      }
663 +   elsif ($ref1 eq "CODE")
664 +      {
665 +      return 1;
666 +      }
667 +   elsif(($ref1 eq "SCALAR") || ($ref1 eq ""))
668 +      {
669 +      if ($data1 eq $data2)
670 +         {
671 +         return 1;
672 +         }
673 +      return 0;
674 +      }
675 +   elsif ($ref1 eq "ARRAY")
676 +      {
677 +      my $count = scalar(@$data1);
678 +      if ($count != scalar(@$data2))
679 +         {
680 +         return 0;
681 +         }
682 +      for (my $i=0; $i<$count; $i++)
683 +          {
684 +          if (! $self->comparetoolsdata($data1->[$i],$data2->[$i]))
685 +             {
686 +             return 0;
687 +             }
688 +          }
689 +      return 1;
690 +      }
691 +   else
692 +      {
693 +      foreach my $k (keys %{$data1})
694 +         {
695 +         if (! exists $data2->{$k})
696 +            {
697 +            return 0;
698 +            }
699 +         }
700 +      foreach my $k (keys %{$data2})
701 +         {
702 +         if (! exists $data1->{$k})
703 +            {
704 +            return 0;
705 +            }
706 +         }
707 +      foreach my $k (keys %{$data2})
708 +         {
709 +         if (! $self->comparetoolsdata($data1->{$k},$data2->{$k}))
710 +            {
711 +            return 0;
712 +            }
713 +         }
714 +      return 1;
715 +      }
716 +   }
717 +
718   1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines