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

Comparing COMP/SCRAM/src/BuildSystem/ToolBox.pm (file contents):
Revision 1.3 by williamc, Thu Sep 21 13:36:52 2000 UTC vs.
Revision 1.10 by sashby, Fri Nov 16 16:29:48 2001 UTC

# Line 23 | Line 23
23   # interactive(0|1)      : set the setup mode
24   # searcher(SearchObject) : Set the search object for matching tools during setup
25   # copytools(ToolBox)            : copy tools from this to the supplied toolbox
26 + # toolmakefile(name,version)    : Return the location of the tool makefile
27  
28   package BuildSystem::ToolBox;
29   use FileHandle;
# Line 41 | Line 42 | sub new {
42          bless $self, $class;
43          $self->{arch}=shift;
44          $self->init($area);
44        #$self->verbosity(1);
45          return $self;
46   }
47  
# Line 50 | Line 50 | sub init {
50          my $area=shift;
51          my $top=$area->location();
52          my $config=$top."/".$area->configurationdir();
53 <        $self->{urlhandler}=URL::URLhandler->new($area->cache());
53 >
54 >        my $cache=$area->cache();
55 >        if ( defined $cache ) {
56 >          $self->{urlhandler}=URL::URLhandler->new($cache);
57 >        }
58          $self->{toolfiledir}="$top/.SCRAM/ToolFiles";
59          $self->{datastore}=$top."/.SCRAM/".$self->{arch};
56        #$self->{datastore}=$area->archdir();
60          $self->{tooladmin}=$self->{datastore}."/admin";
61          AddDir::adddir($self->{toolfiledir});
62          if ( -f $self->{tooladmin} ) {
# Line 63 | Line 66 | sub init {
66           # do we have toolfile dir and no admin? if so maybe its an old
67           # area and we can attempt to get something from the filenames
68           if ( -d $self->{datastore} ) {
69 <          my $dh=FileHandle->new();
69 >          my $dh=DirHandle->new();
70            opendir $dh, $self->{datastore};
71            my @files=grep /.*_.*/, readdir $dh;
72            undef $dh;
# Line 94 | Line 97 | sub tools {
97   }
98  
99   sub toolsetup {
100 <        my $self=shift;
101 <        my $name=shift;
102 <
103 <        AddDir::adddir($self->{datastore});
100 >        my $self=shift;
101 >        my $name=shift;
102 >        
103 >        AddDir::adddir($self->{datastore});
104          $name=~tr[A-Z][a-z];
105          my $rv=0;
106          # -- get version
# Line 131 | Line 134 | sub toolsetup {
134          $filename=$self->_download($url, $name, $version);
135  
136          # -- the tool setup
137 <        print "\n ----------- Setting Up $name $version ---------------\n";
137 >        print "\n----------- Setting Up $name $version -----------------------------------------------\n\n";
138          require BuildSystem::ToolDoc;
139          my $doc=BuildSystem::ToolDoc->new();
140          $doc->tool($tool);
# Line 141 | Line 144 | sub toolsetup {
144          }
145          $doc->interactive($self->interactive());
146          $tool->reset();
147 <        if ( ! $doc->setup($filename,$name,$version) ) {
147 >        if ( ! $doc->setup($filename,$name,$version,$self) ) {
148            $tool->store($self->_toolfile($name,$version));
149            # -- keep an internal record of the tool
150            $name=~tr[A-Z][a-z];
# Line 161 | Line 164 | sub toolsetup {
164            $self->error("Unable to find $name $version in $url");
165          }
166          undef $doc;
164
167          return $rv;
168   }
169  
# Line 227 | Line 229 | sub gettool {
229            return undef, if ( ! defined $version );
230          }
231          my ($tool,$rv)=$self->_toolobject($product,$version);
232 +        if ( $rv != 0 ) {
233 +          delete $self->{tools}{$product}{$version};
234 +        }
235          return ( $rv==0?$tool:undef ); # only return if already set up
236   }
237  
# Line 237 | Line 242 | sub defaultversion {
242          return $self->{defaults}{$product};
243   }
244  
245 + sub toolmakefile {
246 +        my $self=shift;
247 +        my $name=shift;
248 +        my $version=shift;
249 +
250 +        $name=~tr[A-Z][a-z];
251 +        return $self->{datastore}."/".$name."_$version.mk";
252 + }
253 +
254   sub _toolfile {
255          my $self=shift;
256          my $name=shift;
# Line 341 | Line 355 | sub _toolobject {
355          my $rv=0;
356  
357          if ( ! exists $self->{tools}{$product}{$version} ) {
358 <           $self->verbose("$product $version being Intitialised");
358 >           $self->verbose("$product $version being Initialised");
359             $self->{tools}{$product}{$version}=BuildSystem::Tool->new();
360             my $file=$self->_toolfile($product,$version);
361             if ( -f $file ) { # restore it from disk
# Line 354 | Line 368 | sub _toolobject {
368                  $self->{tools}{$product}{$version}->version($version);
369                  $self->verbose("Tool $product $version needs set up");
370             }
357        #   push @{$self->{toollist}}, [$product, $version];
371          }
372          return ($self->{tools}{$product}{$version}, $rv);
373   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines