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.11 by sashby, Fri Jul 15 15:27:27 2005 UTC vs.
Revision 1.15 by sashby, Mon Sep 11 14:53:39 2006 UTC

# Line 150 | Line 150 | sub setupalltools()
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);
153 >                     # Copy needed content from toolmanager for scram-managed project only
154 >                     # if the projects have compatible configurations (compare first set of
155 >                     # digits):
156 >                     if ($self->check_compatibility($satoolmanager))
157 >                        {
158 >                        $self->inheritcontent($satoolmanager);
159 >                        }
160                       }
161                    }
162                 }
# Line 197 | Line 202 | sub setupalltools()
202   sub coresetup()
203     {
204     my $self=shift;
205 <   my ($toolname, $toolversion, $toolfile) = @_;
205 >   my ($toolname, $toolversion, $toolfile, $force) = @_;
206     my ($toolcheck, $toolparser);
207    
208     print "\n";
# Line 213 | Line 218 | sub coresetup()
218        } $self->rawtools();
219    
220     # Tool not known so we create a new ToolParser object and parse it:
221 <   if ($toolcheck != 1)
221 >   if ($toolcheck != 1 || $force == 1)
222        {
223        $toolparser = BuildSystem::ToolParser->new();
224        # We only want to store the stuff relevant for one particular version:
225        $toolparser->parse($toolname, $toolversion, $toolfile);
226        # Store the ToolParser object in the cache:
227        $self->store($toolparser);
228 +      print "\nFile $toolfile reparsed (modified)","\n",if ($ENV{SCRAM_DEBUG});
229        }
230    
231     # Next, set up the tool:
# Line 250 | Line 256 | sub toolsetup()
256     my ($arealocation, $toolname, $toolversion, $toolurl) = @_;
257     my ($urlcache, $url, $filename, $tfname);
258     my $toolfile;
259 +   my $force = 0; # we may have to force a reparse of a tool file
260    
261     $toolname =~ tr[A-Z][a-z];
262     $toolversion ||= $self->defaultversion($toolname);
# Line 278 | Line 285 | sub toolsetup()
285        if ($proto eq 'file')
286           {
287           # Check to see if there is a ~ and substitute the user
288 <         # home directory if there is:
289 <         my ($urlpath) = ($urlv =~ m|^\~/(.*)$|);
290 <         $urlv = $ENV{HOME}."/".$urlpath;
291 <
288 >         # home directory if there is (file:~/xyz):      
289 >         if (my ($urlpath) = ($urlv =~ m|^\~/(.*)$|))
290 >            {
291 >            $urlv = $ENV{HOME}."/".$urlpath;
292 >            }
293 >         elsif (my ($urlpath) = ($urlv =~ m|^\./(.*)$|))
294 >            {
295 >            # Relative to current directory (file:./xyz):
296 >            use Cwd qw(&cwd);
297 >            $urlv = cwd()."/".$urlpath;
298 >            }
299 >        
300           # If the tool url is a file and the file exists,
301           # copy it to .SCRAM/InstalledTools and set the
302           # filename accordingly:
# Line 291 | Line 306 | sub toolsetup()
306              copy($urlv, $filename);
307              my $mode = 0644; chmod $mode, $filename;
308              $toolfile=$filename;
309 +            # Here we must account for the fact that the file tool doc may be
310 +            # a modified version of an existing tool in the current config. we
311 +            # make sure that this file is reparsed, even if there is already a
312 +            # ToolParser object for the tool:
313 +            $force = 1;
314              }
315           else
316              {
317 <            $::scram->scramerror("Unable to set up $toolname from URL $toolurl-- $urlv does not exist!");                  
317 >            $::scram->scramerror("Unable to set up $toolname from URL \"$toolurl\" - $urlv does not exist!");              
318              }
319           }
320        elsif ($proto eq 'http')
# Line 303 | Line 323 | sub toolsetup()
323           # Download from WWW first:
324           use LWP::Simple qw(&getstore);
325           my $http_response_val = &getstore($toolurl, $filename);
326 <
326 >        
327           # Check the HTTP status. If doc not found, exit:
328           if ($http_response_val != 200)
329              {
# Line 364 | Line 384 | sub toolsetup()
384        }
385    
386     # Run the core setup routine:
387 <   $self->coresetup($toolname, $toolversion, $toolfile);
387 >   $self->coresetup($toolname, $toolversion, $toolfile,$force);
388     return $self;
389     }
390  
# Line 375 | Line 395 | sub setupself()
395     # Process the file "Self" in local config directory. This is used to
396     # set all the paths/runtime settings for this project:
397     my $filename=$location."/config/Self";
398 <
398 >  
399     if ( -f $filename )
400        {
401        print "\n";
# Line 577 | Line 597 | sub scram_compiler()
597        }
598     }
599  
600 < sub updatecompiler()
600 > sub updatetool()
601     {
602     my $self=shift;
603 <   my ($compilername, $compilerobj) = @_;
603 >   my ($name, $obj) = @_;
604  
605     # Replace the existing copy of the tool with the new one:
606 <   if (exists $self->{SETUP}->{$compilername})
606 >   if (exists $self->{SETUP}->{$name})
607        {
608        # Check to make sure that we were really passed a compiler with
609        # the desired name:
610 <      if ($compilerobj->toolname() eq $compilername)
610 >      if ($obj->toolname() eq $name)
611           {
612 <         print "ToolManager: Updating the cached copy of ".$compilername."\n";
613 <         delete $self->{SETUP}->{$compilername};
614 <         $self->{SETUP}->{$compilername} = $compilerobj;
612 >         print "ToolManager: Updating the cached copy of ".$name."\n";
613 >         delete $self->{SETUP}->{$name};
614 >         $self->{SETUP}->{$name} = $obj;
615           $self->writecache();
616           }
617        else
618           {
619 <         print "WARNING: compiler name (".$compilername.") and tool obj name (".$compilerobj->toolname().") don't match!","\n";
619 >         print "WARNING: Tool name (".$name.") and tool obj name (".$obj->toolname().") don't match!","\n";
620           print "         Not making any changes.","\n";
621           }
622        }
623     else
624        {
625 <      print "WARNING: No entry in cache for ".$compilername.". Not making any updates.\n";
625 >      print "WARNING: No entry in cache for ".$name.". Not making any updates.\n";
626 >      }
627 >   }
628 >
629 > sub check_compatibility()
630 >   {
631 >   my $self=shift;
632 >   my ($itoolmgr)=@_;
633 >   # Get the version of the toolmanager. If the project fails to return a version
634 >   # string we return 0 for no compatibility (in which case, all tools will be set
635 >   # up in the traditional way):
636 >   my $itm_configversion = $itoolmgr->configversion();
637 >   if ($itm_configversion)
638 >      {
639 >      # The configurations won't be identical. We must compare the digits:
640 >      my ($numeric_version) = ($itm_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
641 >      my $current_configversion = $self->configversion();
642 >      my ($current_numeric_version) = ($current_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
643 >      ($current_numeric_version == $numeric_version) && return 1; # OK, compatible;
644        }
645 +   # Project does not define configuration version so just return:
646 +   return 0;
647 +   }
648 +
649 + sub configversion()
650 +   {
651 +   my $self=shift;
652 +   @_ ? $self->{CONFIGVERSION} = shift
653 +      : $self->{CONFIGVERSION};
654     }
655  
656   1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines