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.3 by sashby, Wed Feb 2 17:41:41 2005 UTC vs.
Revision 1.13 by sashby, Fri Oct 7 16:05:44 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 197 | Line 197 | sub setupalltools()
197   sub coresetup()
198     {
199     my $self=shift;
200 <   my ($toolname, $toolversion, $toolfile) = @_;
200 >   my ($toolname, $toolversion, $toolfile, $force) = @_;
201     my ($toolcheck, $toolparser);
202    
203     print "\n";
# Line 213 | Line 213 | sub coresetup()
213        } $self->rawtools();
214    
215     # Tool not known so we create a new ToolParser object and parse it:
216 <   if ($toolcheck != 1)
216 >   if ($toolcheck != 1 || $force == 1)
217        {
218        $toolparser = BuildSystem::ToolParser->new();
219        # We only want to store the stuff relevant for one particular version:
220        $toolparser->parse($toolname, $toolversion, $toolfile);
221        # Store the ToolParser object in the cache:
222        $self->store($toolparser);
223 +      print "\nFile $toolfile reparsed (modified)","\n",if ($ENV{SCRAM_DEBUG});
224        }
225    
226     # Next, set up the tool:
# Line 227 | Line 228 | sub coresetup()
228     # Make sure that we have this tool in the list of selected tools (just in case this tool was
229     # set up by hand afterwards):
230     $self->addtoselected($toolname);
231 +
232 +   # Check to see if this tool is a compiler. If so, store it.
233 +   # Also store the language that this compiler supprots, and a
234 +   # compiler name (e.g. gcc323) which, in conjunction with a stem
235 +   # architecture name like slc3_ia32_, can be used to build a complete arch string:
236 +   if ($store->scram_compiler() == 1)
237 +      {
238 +      my @supported_language = $store->flags("SCRAM_LANGUAGE_TYPE");
239 +      my @compilername = $store->flags("SCRAM_COMPILER_NAME");
240 +      $self->scram_compiler($supported_language[0],$toolname,$compilername[0]);
241 +      }
242 +  
243     # Store the ToolData object in the cache:
244     $self->storeincache($toolparser->toolname(),$store);
245     return $self;
# Line 238 | Line 251 | sub toolsetup()
251     my ($arealocation, $toolname, $toolversion, $toolurl) = @_;
252     my ($urlcache, $url, $filename, $tfname);
253     my $toolfile;
254 +   my $force = 0; # we may have to force a reparse of a tool file
255    
256     $toolname =~ tr[A-Z][a-z];
257     $toolversion ||= $self->defaultversion($toolname);
# Line 248 | Line 262 | sub toolsetup()
262        {
263        $self->{urlhandler}=URL::URLhandler->new($urlcache);
264        }
265 <  
265 >
266     $url = $self->toolurls()->{$toolname};
267     $filename = $self->{toolfiledir}."/".$toolname;
268    
269 +   # If .SCRAM/InstalledTools doesn't exist, create it:
270 +   if (! -d $self->{toolfiledir})
271 +      {
272 +      AddDir::adddir($self->{toolfiledir});
273 +      }
274 +  
275     # First, check to see if there was a tool URL given. If so, we might need to read
276     # from http or from a file: type URL:
277     if (my ($proto, $urlv) = ($toolurl =~ /(.*):(.*)/))
# Line 259 | Line 279 | sub toolsetup()
279        # See what kind of URL (file:, http:, cvs:, svn:, .. ):
280        if ($proto eq 'file')
281           {
282 +         # Check to see if there is a ~ and substitute the user
283 +         # home directory if there is (file:~/xyz):      
284 +         if (my ($urlpath) = ($urlv =~ m|^\~/(.*)$|))
285 +            {
286 +            $urlv = $ENV{HOME}."/".$urlpath;
287 +            }
288 +         elsif (my ($urlpath) = ($urlv =~ m|^\./(.*)$|))
289 +            {
290 +            # Relative to current directory (file:./xyz):
291 +            use Cwd qw(&cwd);
292 +            $urlv = cwd()."/".$urlpath;
293 +            }
294 +        
295           # If the tool url is a file and the file exists,
296           # copy it to .SCRAM/InstalledTools and set the
297           # filename accordingly:
# Line 266 | Line 299 | sub toolsetup()
299              {
300              use File::Copy;
301              copy($urlv, $filename);
302 +            my $mode = 0644; chmod $mode, $filename;
303              $toolfile=$filename;
304 +            # Here we must account for the fact that the file tool doc may be
305 +            # a modified version of an existing tool in the current config. we
306 +            # make sure that this file is reparsed, even if there is already a
307 +            # ToolParser object for the tool:
308 +            $force = 1;
309              }
310           else
311              {
312 <            $::scram->scramerror("Unable to set up $toolname from URL $toolurl-- $urlv does not exist!");                  
312 >            $::scram->scramerror("Unable to set up $toolname from URL \"$toolurl\" - $urlv does not exist!");              
313              }
314           }
315        elsif ($proto eq 'http')
# Line 279 | Line 318 | sub toolsetup()
318           # Download from WWW first:
319           use LWP::Simple qw(&getstore);
320           my $http_response_val = &getstore($toolurl, $filename);
321 <
321 >        
322           # Check the HTTP status. If doc not found, exit:
323           if ($http_response_val != 200)
324              {
# Line 313 | Line 352 | sub toolsetup()
352        # Copy the downloaded tool file to InstalledTools directory:
353        if ( ! -f $filename )
354           {
355 <         $self->verbose("Attempting Download of $url");
356 <         # Get file from download cache:
357 <         ($url,$filename)=$self->{urlhandler}->get($url);
358 <         use File::Copy;
359 <         $tfname=$self->{toolfiledir}."/".$toolname;
360 <         copy($filename, $tfname);
361 <         $toolfile=$tfname;
355 >         # If the URL is empty, the chances are that this tool was not downloaded to .SCRAM/InstalledTools.
356 >         # We signal an error and exit:
357 >         if ($url eq '')
358 >            {
359 >            $::scram->scramerror("$toolname was selected in project requirements but is not in the configuration!");
360 >            }
361 >         else
362 >            {
363 >            # Otherwise, we try to download it:
364 >            $self->verbose("Attempting Download of $url");
365 >            # Get file from download cache:
366 >            ($url,$filename)=$self->{urlhandler}->get($url);                
367 >            use File::Copy;
368 >            $tfname=$self->{toolfiledir}."/".$toolname;  
369 >            copy($filename, $tfname);
370 >            my $mode = 0644; chmod $mode, $tfname;
371 >            $toolfile=$tfname;
372 >            }
373           }
374        else
375           {
# Line 329 | Line 379 | sub toolsetup()
379        }
380    
381     # Run the core setup routine:
382 <   $self->coresetup($toolname, $toolversion, $toolfile);
382 >   $self->coresetup($toolname, $toolversion, $toolfile,$force);
383     return $self;
384     }
385  
# Line 480 | Line 530 | sub remove_tool()
530           }
531        else
532           {
533 <         print "Deleting $toolname from cache.","\n";
533 >         # Is this tool a compiler?
534 >         if ($tooldata->scram_compiler() == 1)
535 >            {
536 >            # Also remove this from the compiler info if there happens to be an entry:
537 >            while (my ($langtype, $ctool) = each %{$self->{SCRAM_COMPILER}})
538 >               {
539 >               if ($toolname eq $ctool->[0])
540 >                  {
541 >                  delete $self->{SCRAM_COMPILER}->{$langtype};
542 >                  print "Deleting compiler $toolname from cache.","\n";
543 >                  }
544 >               }
545 >            }
546 >         else
547 >            {
548 >            print "Deleting $toolname from cache.","\n";
549 >            }
550           }
551        }
552    
553     $self->{SETUP} = $newtlist;
554 <
554 >  
555     # Now remove from the RAW tool list:
556     $self->cleanup_raw($toolname);
491  
557     print "ToolManager: Updating tool cache.","\n";
558     $self->writecache();
559     }
# Line 508 | Line 573 | sub scram_projects()
573     return $scram_projects;
574     }
575  
576 + sub scram_compiler()
577 +   {
578 +   my $self=shift;
579 +   my ($langtype, $toolname, $compilername)=@_;
580 +
581 +   if ($langtype)
582 +      {
583 +      # Store the compiler info according to supported
584 +      # language types.
585 +      #
586 +      # ---------------------- e.g C++      cxxcompiler    gcc323
587 +      $self->{SCRAM_COMPILER}->{$langtype}=[ $toolname, $compilername ];
588 +      }
589 +   else
590 +      {
591 +      return $self->{SCRAM_COMPILER};
592 +      }
593 +   }
594 +
595 + sub updatetool()
596 +   {
597 +   my $self=shift;
598 +   my ($name, $obj) = @_;
599 +
600 +   # Replace the existing copy of the tool with the new one:
601 +   if (exists $self->{SETUP}->{$name})
602 +      {
603 +      # Check to make sure that we were really passed a compiler with
604 +      # the desired name:
605 +      if ($obj->toolname() eq $name)
606 +         {
607 +         print "ToolManager: Updating the cached copy of ".$name."\n";
608 +         delete $self->{SETUP}->{$name};
609 +         $self->{SETUP}->{$name} = $obj;
610 +         $self->writecache();
611 +         }
612 +      else
613 +         {
614 +         print "WARNING: Tool name (".$name.") and tool obj name (".$obj->toolname().") don't match!","\n";
615 +         print "         Not making any changes.","\n";
616 +         }
617 +      }
618 +   else
619 +      {
620 +      print "WARNING: No entry in cache for ".$name.". Not making any updates.\n";
621 +      }
622 +   }
623 +
624   1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines