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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines