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.6 by williamc, Wed Sep 6 08:14:46 2000 UTC vs.
Revision 1.12 by sashby, Tue Jun 12 16:02:56 2001 UTC

# Line 19 | Line 19
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 + # classverbose(classstring,setting) : Set the class verbosity level
26 + # toolruntime(ConfigArea): Get a runtime object withthe settings from
27 + #                          the specified toolbox
28  
29   package Scram::ScramFunctions;
30   use URL::URLcache;
# Line 27 | Line 33 | require 5.004;
33  
34   @ISA=qw(Utilities::Verbose);
35  
36 < sub new {
36 > sub new
37 >   {
38 >   my $class=shift;
39 >   $self={};
40 >   bless $self, $class;
41 >   # -- default settings
42 >   $self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
43 >   $self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
44 >   ($self->{scram_top})=( $ENV{SCRAM_HOME}=~/(.*)\//) ;
45 >  
46 >   return $self;
47 >   }
48 >
49 > sub classverbose {
50 >        my $self=shift;
51          my $class=shift;
52 <        $self={};
53 <        bless $self, $class;
54 <        # -- default settings
35 <        $self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
36 <        $self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
37 <        return $self;
52 >        my $val=shift;
53 >
54 >        $ENV{"VERBOSE_".$class}=$val;
55   }
56  
57   sub project {
# Line 74 | Line 91 | sub setuptoolsinarea {
91  
92          # -- create a new toolbox object
93          my $toolbox=$self->areatoolbox($area);
94 <        $toolbox->searcher($self->_projsearcher());
94 >        $toolbox->searcher($self->_allprojectinitsearcher());
95  
96          if ( @_ ) {
97              # -- specific tool specified
# Line 143 | Line 160 | sub satellite {
160          return $area;
161   }
162  
163 + sub toolruntime {
164 +        my $self=shift;
165 +        my $area=shift;
166 +
167 +        my $name=$area->location();
168 +        if ( ! defined $self->{toolruntime}{$name} ) {
169 +         require Runtime;
170 +         my $toolbox=$self->areatoolbox($area);
171 +         $self->{toolruntime}{$name}=Runtime->new();
172 +
173 +         # -- add scram area specific runtimes
174 +         $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
175 +                $area->location()."/lib/".$self->arch(),"path");
176 +         $self->{toolruntime}{$name}->addvar("PATH",
177 +                $area->location()."/bin/".$self->arch(),"path");
178 +         if ( defined $area->linkarea() ) {
179 +          my $reltop=$area->linkarea()->location();
180 +          $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
181 +                $reltop."/lib/".$self->arch(),"path");
182 +          $self->{toolruntime}{$name}->addvar("PATH",
183 +                $reltop."/bin/".$self->arch(),"path");
184 +         }
185 +
186 +         # -- get the runtime environment from all the tools
187 +         my $tool;
188 +         foreach $toolname ( $toolbox->tools() ) {
189 +          $tool=$toolbox->gettool($toolname);
190 +          if ( defined $tool ) {
191 +            # -- get runtime paths
192 +            foreach $f ( $tool->listtype("runtime_path")) {
193 +             foreach $val ( $tool->getfeature($f) ) {
194 +              $self->{toolruntime}{$name}->addvar($f,$val,"path");
195 +             }
196 +            }
197 +            # -- get runtime vars
198 +            foreach $f ( $tool->listtype("runtime")) {
199 +             foreach $val ( $tool->getfeature($f) ) {
200 +              $self->{toolruntime}{$name}->addvar($f,$val);
201 +             }
202 +            }
203 +          }
204 +         }
205 +
206 +         # -- Get the project level environment
207 +         my $runtimefile=$area->location()."/".$area->configurationdir()
208 +                                                                ."/Runtime";
209 +         if ( -f $runtimefile ) {
210 +          $self->{toolruntime}{$name}->file($runtimefile);
211 +         }
212 +        }
213 +        return $self->{toolruntime}{$name};
214 + }
215 +
216 + sub webget {
217 +        my $self=shift;
218 +        my $area=shift;
219 +        my $url=shift;
220 +
221 +        require URL::URLhandler;
222 +        my $handler=URL::URLhandler->new($area->cache());
223 +        return ($handler->download($url));
224 + }
225 +
226   sub addareatoDB {
227          my $self=shift;
228          my $area=shift;
# Line 161 | Line 241 | sub addareatoDB {
241          $self->scramprojectdb()->addarea($tagname,$version,$area);
242   }
243  
244 + sub spawnversion
245 +   {
246 +   my $self=shift;
247 +   my $version=shift;
248 +   my $rv=0;
249 +  
250 +   my $thisversion=$self->getversion();
251 +
252 +   if ( defined $version )
253 +      {
254 +      if ( $version ne $thisversion )
255 +         {
256 +         # first try to use the correct version
257 +         if ( -d $self->{scram_top}."/".$version )
258 +            {
259 +            $ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
260 +            $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
261 +            $self->verbose("Spawning SCRAM version $version");
262 +            my $rv=system("scram", @_)/256;
263 +            exit $rv;
264 +            }
265 +         else
266 +            { # if not then simply warn
267 +            print "******* Warning : scram version inconsistent ********\n";
268 +            print "This version: $thisversion; Required version: $version\n";
269 +            print "*****************************************************\n";
270 +            print "\n";
271 +            }
272 +         }
273 +      }
274 +   else
275 +      {
276 +      $self->error("Undefined value for version requested");
277 +      $rv=1;
278 +      }
279 +   return $rv;
280 +   }
281 +
282   sub globalcache {
283          my $self=shift;
284          if ( @_ ) {
# Line 186 | Line 304 | sub scramprojectdb {
304          }
305          return $self->{scramprojectsdb};
306   }
307 +
308 + sub getversion {
309 +        my $self=shift;
310 +        
311 +        my $thisversion;
312 +        ($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
313 +        my $scram_top=$1;
314 +        my $scram_version=$thisversion;
315 +        # deal with links
316 +        my $version=readlink $ENV{SCRAM_HOME};
317 +        if ( defined $version)  {
318 +          $scram_version=$version;
319 +        }
320 +        return $scram_version;
321 + }
322  
323   sub areatoolbox {
324          my $self=shift;
# Line 195 | Line 328 | sub areatoolbox {
328          if ( ! defined $self->{toolboxes}{$name} ) {
329            # -- create a new toolbox object
330            require BuildSystem::ToolBox;
331 <          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area);
331 >          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area,
332 >                                                        $self->arch());
333            $self->{toolboxes}{$name}->verbosity($self->verbosity());
334          }
335          return $self->{toolboxes}{$name};
# Line 235 | Line 369 | sub arch {
369   }
370  
371   sub scramobjectinterface {
372 <        my $self=shift;
373 <        my $class=shift;
372 >        my $self=shift;
373 >        my $class=shift;
374  
375 <        my $file;
376 <        ($file=$class."\.pm")=~s/::/\//g;
377 <        $file=$ENV{TOOL_HOME}."/".$file;
375 >        my $file;
376 >        ($file=$class."\.pm")=~s/::/\//g;
377 >        $file=$ENV{TOOL_HOME}."/".$file;
378  
379 <        if ( ! -f $file ) {
380 <          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});    
381 <        }
382 <        print "--------------------- $class ------------------\n";
383 <        my $fh=FileHandle->new();
379 >        if ( ! -f $file ) {
380 >          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});
381 >        }
382 >        print "--------------------- $class ------------------\n";
383 >        my $fh=FileHandle->new();
384          $fh->open("<$file");
385          while ( <$fh> ) {
386             if ( $_=~/#\s*Interface/g ) {
# Line 270 | Line 404 | sub scramobjectinterface {
404             }
405          }
406          print "\n";
407 <        undef $fh;
407 >        undef $fh;
408   }
409  
410   # -------------- Support Routines ------------------------------
# Line 283 | Line 417 | sub _allprojectinitsearcher {
417             $search->addproject($$proj[0],$$proj[1]);
418            }
419          }
420 +        return $self->{projsearcher};
421   }
422  
423   sub _projsearcher {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines