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.7 by sashby, Wed Apr 6 18:17:15 2005 UTC vs.
Revision 1.15 by sashby, Mon Sep 11 14:53:39 2006 UTC

# Line 22 | Line 22 | use Utilities::Verbose;
22   @ISA=qw(BuildSystem::ToolCache Utilities::Verbose);
23   @EXPORT_OK=qw( );
24   #
25 < #
25 >
26   sub new
27     ###############################################################
28     # new                                                         #
# 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 227 | Line 233 | sub coresetup()
233     # Make sure that we have this tool in the list of selected tools (just in case this tool was
234     # set up by hand afterwards):
235     $self->addtoselected($toolname);
236 +
237 +   # Check to see if this tool is a compiler. If so, store it.
238 +   # Also store the language that this compiler supprots, and a
239 +   # compiler name (e.g. gcc323) which, in conjunction with a stem
240 +   # architecture name like slc3_ia32_, can be used to build a complete arch string:
241 +   if ($store->scram_compiler() == 1)
242 +      {
243 +      my @supported_language = $store->flags("SCRAM_LANGUAGE_TYPE");
244 +      my @compilername = $store->flags("SCRAM_COMPILER_NAME");
245 +      $self->scram_compiler($supported_language[0],$toolname,$compilername[0]);
246 +      }
247 +  
248     # Store the ToolData object in the cache:
249     $self->storeincache($toolparser->toolname(),$store);
250     return $self;
# Line 238 | 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 265 | Line 284 | sub toolsetup()
284        # See what kind of URL (file:, http:, cvs:, svn:, .. ):
285        if ($proto eq 'file')
286           {
287 +         # Check to see if there is a ~ and substitute the user
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 274 | 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 286 | 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 347 | 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 358 | 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 498 | Line 535 | sub remove_tool()
535           }
536        else
537           {
538 <         print "Deleting $toolname from cache.","\n";
538 >         # Is this tool a compiler?
539 >         if ($tooldata->scram_compiler() == 1)
540 >            {
541 >            # Also remove this from the compiler info if there happens to be an entry:
542 >            while (my ($langtype, $ctool) = each %{$self->{SCRAM_COMPILER}})
543 >               {
544 >               if ($toolname eq $ctool->[0])
545 >                  {
546 >                  delete $self->{SCRAM_COMPILER}->{$langtype};
547 >                  print "Deleting compiler $toolname from cache.","\n";
548 >                  }
549 >               }
550 >            }
551 >         else
552 >            {
553 >            print "Deleting $toolname from cache.","\n";
554 >            }
555           }
556        }
557    
558     $self->{SETUP} = $newtlist;
559 <
559 >  
560     # Now remove from the RAW tool list:
561     $self->cleanup_raw($toolname);
509  
562     print "ToolManager: Updating tool cache.","\n";
563     $self->writecache();
564     }
# Line 526 | Line 578 | sub scram_projects()
578     return $scram_projects;
579     }
580  
581 + sub scram_compiler()
582 +   {
583 +   my $self=shift;
584 +   my ($langtype, $toolname, $compilername)=@_;
585 +
586 +   if ($langtype)
587 +      {
588 +      # Store the compiler info according to supported
589 +      # language types.
590 +      #
591 +      # ---------------------- e.g C++      cxxcompiler    gcc323
592 +      $self->{SCRAM_COMPILER}->{$langtype}=[ $toolname, $compilername ];
593 +      }
594 +   else
595 +      {
596 +      return $self->{SCRAM_COMPILER};
597 +      }
598 +   }
599 +
600 + sub updatetool()
601 +   {
602 +   my $self=shift;
603 +   my ($name, $obj) = @_;
604 +
605 +   # Replace the existing copy of the tool with the new one:
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 ($obj->toolname() eq $name)
611 +         {
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: 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 ".$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