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.4 by sashby, Wed Feb 2 18:57:01 2005 UTC vs.
Revision 1.11 by sashby, Fri Jul 15 15:27:27 2005 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 227 | Line 227 | sub coresetup()
227     # Make sure that we have this tool in the list of selected tools (just in case this tool was
228     # set up by hand afterwards):
229     $self->addtoselected($toolname);
230 +
231 +   # Check to see if this tool is a compiler. If so, store it.
232 +   # Also store the language that this compiler supprots, and a
233 +   # compiler name (e.g. gcc323) which, in conjunction with a stem
234 +   # architecture name like slc3_ia32_, can be used to build a complete arch string:
235 +   if ($store->scram_compiler() == 1)
236 +      {
237 +      my @supported_language = $store->flags("SCRAM_LANGUAGE_TYPE");
238 +      my @compilername = $store->flags("SCRAM_COMPILER_NAME");
239 +      $self->scram_compiler($supported_language[0],$toolname,$compilername[0]);
240 +      }
241 +  
242     # Store the ToolData object in the cache:
243     $self->storeincache($toolparser->toolname(),$store);
244     return $self;
# Line 238 | Line 250 | sub toolsetup()
250     my ($arealocation, $toolname, $toolversion, $toolurl) = @_;
251     my ($urlcache, $url, $filename, $tfname);
252     my $toolfile;
253 <
253 >  
254     $toolname =~ tr[A-Z][a-z];
255     $toolversion ||= $self->defaultversion($toolname);
256     $urlcache=URL::URLcache->new($arealocation."/.SCRAM/cache"); # Download tool cache
257 <
257 >  
258     # Check for the downloaded tools cache:
259     if (defined($urlcache))
260        {
261        $self->{urlhandler}=URL::URLhandler->new($urlcache);
262        }
263 <  
263 >
264     $url = $self->toolurls()->{$toolname};
265     $filename = $self->{toolfiledir}."/".$toolname;
266    
# Line 265 | Line 277 | sub toolsetup()
277        # See what kind of URL (file:, http:, cvs:, svn:, .. ):
278        if ($proto eq 'file')
279           {
280 +         # Check to see if there is a ~ and substitute the user
281 +         # home directory if there is:
282 +         my ($urlpath) = ($urlv =~ m|^\~/(.*)$|);
283 +         $urlv = $ENV{HOME}."/".$urlpath;
284 +
285           # If the tool url is a file and the file exists,
286           # copy it to .SCRAM/InstalledTools and set the
287           # filename accordingly:
# Line 272 | Line 289 | sub toolsetup()
289              {
290              use File::Copy;
291              copy($urlv, $filename);
292 +            my $mode = 0644; chmod $mode, $filename;
293              $toolfile=$filename;
294              }
295           else
# Line 319 | Line 337 | sub toolsetup()
337        # Copy the downloaded tool file to InstalledTools directory:
338        if ( ! -f $filename )
339           {
340 <         $self->verbose("Attempting Download of $url");
341 <         # Get file from download cache:
342 <         ($url,$filename)=$self->{urlhandler}->get($url);
343 <         use File::Copy;
344 <         $tfname=$self->{toolfiledir}."/".$toolname;    
345 <         copy($filename, $tfname);
346 <         $toolfile=$tfname;
340 >         # If the URL is empty, the chances are that this tool was not downloaded to .SCRAM/InstalledTools.
341 >         # We signal an error and exit:
342 >         if ($url eq '')
343 >            {
344 >            $::scram->scramerror("$toolname was selected in project requirements but is not in the configuration!");
345 >            }
346 >         else
347 >            {
348 >            # Otherwise, we try to download it:
349 >            $self->verbose("Attempting Download of $url");
350 >            # Get file from download cache:
351 >            ($url,$filename)=$self->{urlhandler}->get($url);                
352 >            use File::Copy;
353 >            $tfname=$self->{toolfiledir}."/".$toolname;  
354 >            copy($filename, $tfname);
355 >            my $mode = 0644; chmod $mode, $tfname;
356 >            $toolfile=$tfname;
357 >            }
358           }
359        else
360           {
# Line 486 | Line 515 | sub remove_tool()
515           }
516        else
517           {
518 <         print "Deleting $toolname from cache.","\n";
518 >         # Is this tool a compiler?
519 >         if ($tooldata->scram_compiler() == 1)
520 >            {
521 >            # Also remove this from the compiler info if there happens to be an entry:
522 >            while (my ($langtype, $ctool) = each %{$self->{SCRAM_COMPILER}})
523 >               {
524 >               if ($toolname eq $ctool->[0])
525 >                  {
526 >                  delete $self->{SCRAM_COMPILER}->{$langtype};
527 >                  print "Deleting compiler $toolname from cache.","\n";
528 >                  }
529 >               }
530 >            }
531 >         else
532 >            {
533 >            print "Deleting $toolname from cache.","\n";
534 >            }
535           }
536        }
537    
538     $self->{SETUP} = $newtlist;
539 <
539 >  
540     # Now remove from the RAW tool list:
541     $self->cleanup_raw($toolname);
497  
542     print "ToolManager: Updating tool cache.","\n";
543     $self->writecache();
544     }
# Line 514 | Line 558 | sub scram_projects()
558     return $scram_projects;
559     }
560  
561 + sub scram_compiler()
562 +   {
563 +   my $self=shift;
564 +   my ($langtype, $toolname, $compilername)=@_;
565 +
566 +   if ($langtype)
567 +      {
568 +      # Store the compiler info according to supported
569 +      # language types.
570 +      #
571 +      # ---------------------- e.g C++      cxxcompiler    gcc323
572 +      $self->{SCRAM_COMPILER}->{$langtype}=[ $toolname, $compilername ];
573 +      }
574 +   else
575 +      {
576 +      return $self->{SCRAM_COMPILER};
577 +      }
578 +   }
579 +
580 + sub updatecompiler()
581 +   {
582 +   my $self=shift;
583 +   my ($compilername, $compilerobj) = @_;
584 +
585 +   # Replace the existing copy of the tool with the new one:
586 +   if (exists $self->{SETUP}->{$compilername})
587 +      {
588 +      # Check to make sure that we were really passed a compiler with
589 +      # the desired name:
590 +      if ($compilerobj->toolname() eq $compilername)
591 +         {
592 +         print "ToolManager: Updating the cached copy of ".$compilername."\n";
593 +         delete $self->{SETUP}->{$compilername};
594 +         $self->{SETUP}->{$compilername} = $compilerobj;
595 +         $self->writecache();
596 +         }
597 +      else
598 +         {
599 +         print "WARNING: compiler name (".$compilername.") and tool obj name (".$compilerobj->toolname().") don't match!","\n";
600 +         print "         Not making any changes.","\n";
601 +         }
602 +      }
603 +   else
604 +      {
605 +      print "WARNING: No entry in cache for ".$compilername.". Not making any updates.\n";
606 +      }
607 +   }
608 +
609   1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines