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

Comparing COMP/SCRAM/src/Scram/ScramFunctions.pm (file contents):
Revision 1.3 by williamc, Wed Aug 30 09:31:31 2000 UTC vs.
Revision 1.9 by williamc, Fri Oct 20 11:31:43 2000 UTC

# Line 18 | Line 18
18   # areatoolbox(ConfigArea) : return the toolbox of the specified area
19   # setuptoolsinarea($area[,$toolname[,$toolversion[,toolfile]) : setup
20   # arch()                : get/set the architecture string
21 + # scramobjectinterface(Class)  : print out the interface of a scram class
22 + # webget(area,url)      : get the url into the cache of the specified area
23 + # getversion()          : return the current scram version
24 + # spawnversion(version,@args) : spawn the scram version with the given args
25  
26   package Scram::ScramFunctions;
27   use URL::URLcache;
28 + use URL::URLhandler;
29   use Utilities::Verbose;
30   require 5.004;
31  
# Line 31 | Line 36 | sub new {
36          $self={};
37          bless $self, $class;
38          # -- default settings
39 <        $self->{cachedir}=$ENV{HOME}."/.SCRAM/globalcache";
39 >        $self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
40          $self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
41 +        ($self->{scram_top})=( $ENV{SCRAM_HOME}=~/(.*)\//) ;
42 +
43          return $self;
44   }
45  
# Line 98 | Line 105 | sub satellite {
105          my $version=shift;
106          my $installarea=shift;
107  
108 <        my $areaname="";
108 >        my $areaname=undef;
109          if ( @_ ) {
110            $areaname=shift;
111          }
# Line 109 | Line 116 | sub satellite {
116            $self->error("Unable to Find Project $name $version");
117          }
118  
119 +        # -- fix for old broken areas
120 +        if ( (! defined $relarea->version()) || ($relarea->version() eq "") ) {
121 +           $relarea->version($version);
122 +        }
123 +
124          # -- create satellite
125          my $area=$relarea->satellite($installarea,$areaname);
126          $area->archname($self->arch());
# Line 137 | Line 149 | sub satellite {
149          return $area;
150   }
151  
152 + sub webget {
153 +        my $self=shift;
154 +        my $area=shift;
155 +        my $url=shift;
156 +
157 +        my $handler=URL::URLhandler->new($area->cache());
158 +        return ($handler->get($url));
159 + }
160 +
161   sub addareatoDB {
162          my $self=shift;
163          my $area=shift;
# Line 155 | Line 176 | sub addareatoDB {
176          $self->scramprojectdb()->addarea($tagname,$version,$area);
177   }
178  
179 + sub spawnversion {
180 +        my $self=shift;
181 +        my $version=shift;
182 +
183 +        my $rv=0;
184 +        my $thisversion=$self->getversion();
185 +        if ( defined $version ) {
186 +          if ( $version ne $thisversion ) {
187 +              # first try to use the correct version
188 +              if ( -d $self->{scram_top}."/".$version ) {
189 +                $ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
190 +                $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
191 +                $self->verbose("Spawning SCRAM version $version");
192 +                my $rv=system("scram", @_)/256;
193 +                exit $rv;
194 +              }
195 +              else { # if not then simply warn
196 +               print "******* Warning : scram version inconsistent ********\n";
197 +               print "This version: $thisversion; Required version: $version\n";
198 +               print "*****************************************************\n";
199 +               print "\n";
200 +              }
201 +           }
202 +        }
203 +        else {
204 +           $self->error("Undefined value for version requested");
205 +           $rv=1;
206 +        }
207 +        return $rv;
208 + }
209 +
210   sub globalcache {
211          my $self=shift;
212          if ( @_ ) {
# Line 180 | Line 232 | sub scramprojectdb {
232          }
233          return $self->{scramprojectsdb};
234   }
235 +
236 + sub getversion {
237 +        my $self=shift;
238 +        
239 +        my $thisversion;
240 +        ($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
241 +        my $scram_top=$1;
242 +        my $scram_version=$thisversion;
243 +        # deal with links
244 +        my $version=readlink $ENV{SCRAM_HOME};
245 +        if ( defined $version)  {
246 +          $scram_version=$version;
247 +        }
248 +        return $scram_version;
249 + }
250  
251   sub areatoolbox {
252          my $self=shift;
# Line 189 | Line 256 | sub areatoolbox {
256          if ( ! defined $self->{toolboxes}{$name} ) {
257            # -- create a new toolbox object
258            require BuildSystem::ToolBox;
259 <          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area);
259 >          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area,
260 >                                                        $self->arch());
261            $self->{toolboxes}{$name}->verbosity($self->verbosity());
262          }
263          return $self->{toolboxes}{$name};
# Line 228 | Line 296 | sub arch {
296            :$self->{arch};
297   }
298  
299 + sub scramobjectinterface {
300 +        my $self=shift;
301 +        my $class=shift;
302 +
303 +        my $file;
304 +        ($file=$class."\.pm")=~s/::/\//g;
305 +        $file=$ENV{TOOL_HOME}."/".$file;
306 +
307 +        if ( ! -f $file ) {
308 +          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});    
309 +        }
310 +        print "--------------------- $class ------------------\n";
311 +        my $fh=FileHandle->new();
312 +        $fh->open("<$file");
313 +        while ( <$fh> ) {
314 +           if ( $_=~/#\s*Interface/g ) {
315 +                $intregion=1;
316 +                next;
317 +           }
318 +           if ( $intregion ) { # if we are in the interface documentation
319 +            if ( ( $_!~/^#/ ) || ( $_=~/^#\s?-{40}/ ) ) { #moving out of Int doc
320 +                $intregion=0;
321 +                next;
322 +            }
323 +            print $_;
324 +            if ( $_=~/^#\s*(.*)\((.*)\)?:(.*)/ ) {
325 +             $interface=$1;
326 +             $args=$2;
327 +             $rest=$3;
328 +             next if ($interface eq "");
329 +             push @interfaces,$interface;
330 +             $interfaceargs{$interface}=$args;
331 +            }
332 +           }
333 +        }
334 +        print "\n";
335 +        undef $fh;
336 + }
337 +
338   # -------------- Support Routines ------------------------------
339  
340  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines