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.8 by williamc, Thu Sep 21 13:44:26 2000 UTC vs.
Revision 1.15 by sashby, Wed Aug 22 12:40:13 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
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 30 | 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={};
36 <        bless $self, $class;
37 <        # -- default settings
38 <        $self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
39 <        $self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
40 <        ($self->{scram_top})=( $ENV{SCRAM_HOME}=~/(.*)\//) ;
52 >        my $val=shift;
53  
54 <        return $self;
54 >        $ENV{"VERBOSE_".$class}=$val;
55   }
56  
57   sub project {
# Line 74 | Line 86 | sub setuptoolsinarea {
86          my $self=shift;
87          my $area=shift;
88  
89 <        # -- initialise
89 >        # -- initialise
90 >        print "Initialising setup procedure......","\n";
91          $self->_allprojectinitsearcher();
92  
93          # -- create a new toolbox object
94          my $toolbox=$self->areatoolbox($area);
95 <        $toolbox->searcher($self->_projsearcher());
95 >        $toolbox->searcher($self->_allprojectinitsearcher());
96  
97          if ( @_ ) {
98              # -- specific tool specified
# Line 148 | Line 161 | sub satellite {
161          return $area;
162   }
163  
164 < sub webget {
164 > sub toolruntime {
165          my $self=shift;
166          my $area=shift;
154        my $url=shift;
167  
168 <        my $handler=URL::URLhandler->new($area->cache());
169 <        return ($handler->get($url));
168 >        my $name=$area->location();
169 >        if ( ! defined $self->{toolruntime}{$name} ) {
170 >         require Runtime;
171 >         my $toolbox=$self->areatoolbox($area);
172 >         $self->{toolruntime}{$name}=Runtime->new();
173 >
174 >         # -- add scram area specific runtimes
175 >         $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
176 >                $area->location()."/lib/".$self->arch(),"path");
177 >         $self->{toolruntime}{$name}->addvar("PATH",
178 >                $area->location()."/bin/".$self->arch(),"path");
179 >         if ( defined $area->linkarea() ) {
180 >          my $reltop=$area->linkarea()->location();
181 >          $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
182 >                $reltop."/lib/".$self->arch(),"path");
183 >          $self->{toolruntime}{$name}->addvar("PATH",
184 >                $reltop."/bin/".$self->arch(),"path");
185 >         }
186 >
187 >         # -- get the runtime environment from all the tools
188 >         my $tool;
189 >         foreach $toolname ( $toolbox->tools() ) {
190 >          $tool=$toolbox->gettool($toolname);
191 >          if ( defined $tool ) {
192 >            # -- get runtime paths
193 >            foreach $f ( $tool->listtype("runtime_path")) {
194 >             foreach $val ( $tool->getfeature($f) ) {
195 >              $self->{toolruntime}{$name}->addvar($f,$val,"path");
196 >             }
197 >            }
198 >            # -- get runtime vars
199 >            foreach $f ( $tool->listtype("runtime")) {
200 >             foreach $val ( $tool->getfeature($f) ) {
201 >              $self->{toolruntime}{$name}->addvar($f,$val);
202 >             }
203 >            }
204 >          }
205 >         }
206 >
207 >         # -- Get the project level environment
208 >         my $runtimefile=$area->location()."/".$area->configurationdir()
209 >                                                                ."/Runtime";
210 >         if ( -f $runtimefile ) {
211 >          $self->{toolruntime}{$name}->file($runtimefile);
212 >         }
213 >        }
214 >        return $self->{toolruntime}{$name};
215 > }
216 >
217 > sub webget {
218 >        my $self=shift;
219 >        my $area=shift;
220 >        my $url=shift;
221 >
222 >        require URL::URLhandler;
223 >        my $handler=URL::URLhandler->new($area->cache());
224 >        return ($handler->download($url));
225   }
226  
227   sub addareatoDB {
# Line 175 | Line 242 | sub addareatoDB {
242          $self->scramprojectdb()->addarea($tagname,$version,$area);
243   }
244  
178 sub spawnversion {
179        my $self=shift;
180        my $version=shift;
245  
246 <        my $rv=0;
247 <        my $thisversion=$self->getversion();
248 <        if ( defined $version ) {
249 <          if ( $version ne $thisversion ) {
250 <              # first try to use the correct version
251 <              if ( -d $self->{scram_top}."/".$version ) {
252 <                $ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
253 <                $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
254 <                $self->verbose("Spawning SCRAM version $version");
255 <                my $rv=system("scram", @_)/256;
256 <                exit $rv;
257 <              }
258 <              else { # if not then simply warn
259 <               print "******* Warning : scram version inconsistent ********\n";
260 <               print "This version: $thisversion; Required version: $version\n";
261 <               print "*****************************************************\n";
262 <               print "\n";
263 <              }
264 <           }
265 <        }
266 <        else {
267 <           $self->error("Undefined value for version requested");
268 <           $rv=1;
269 <        }
270 <        return $rv;
271 < }
246 > sub removeareafromDB
247 >   {
248 >   ###############################################################
249 >   # removearefromDB()                                           #
250 >   ###############################################################
251 >   # modified : Thu Jun 14 10:46:22 2001 / SFA                   #
252 >   # params   : projectname, projectversion                      #
253 >   #          :                                                  #
254 >   #          :                                                  #
255 >   #          :                                                  #
256 >   # function : Remove project <projectname> from DB file.       #
257 >   #          :                                                  #
258 >   #          :                                                  #
259 >   ###############################################################
260 >   my $self=shift;
261 >   my $projname=shift;
262 >   my $version=shift;
263 >  
264 >   # -- Remove from the DB:
265 >   $self->scramprojectdb()->removearea($projname,$version);
266 >   }
267 >
268 >
269 > sub spawnversion
270 >   {
271 >   ###############################################################
272 >   # spawnversion                                                #
273 >   ###############################################################
274 >   # modified : Fri Aug 10 15:42:08 2001 / SFA                   #
275 >   # params   :                                                  #
276 >   #          :                                                  #
277 >   #          :                                                  #
278 >   #          :                                                  #
279 >   # function : Check for version of scram to run, and run it.   #
280 >   #          :                                                  #
281 >   #          :                                                  #
282 >   ###############################################################
283 >
284 >   my $self=shift;
285 >   my $version=shift;
286 >   my $rv=0;
287 >  
288 >   my $thisversion=$self->getversion();
289 >
290 >   if ( defined $version )
291 >      {
292 >      if ( $version ne $thisversion )
293 >         {
294 >         # first try to use the correct version
295 >         if ( -d $self->{scram_top}."/".$version )
296 >            {
297 >            $ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
298 >            $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
299 >            $self->verbose("Spawning SCRAM version $version");
300 >            my $rv=system("scram", @_)/256;
301 >            exit $rv;
302 >            }
303 >         else
304 >            { # if not then simply warn
305 >            print "******* Warning : scram version inconsistent ********\n";
306 >            print "This version: $thisversion; Required version: $version\n";
307 >            print "*****************************************************\n";
308 >            print "\n";
309 >            }
310 >         }
311 >      }
312 >   else
313 >      {
314 >      $self->error("Undefined value for version requested");
315 >      $rv=1;
316 >      }
317 >   return $rv;
318 >   }
319  
320   sub globalcache {
321          my $self=shift;
# Line 296 | Line 407 | sub arch {
407   }
408  
409   sub scramobjectinterface {
410 <        my $self=shift;
411 <        my $class=shift;
410 >        my $self=shift;
411 >        my $class=shift;
412  
413 <        my $file;
414 <        ($file=$class."\.pm")=~s/::/\//g;
415 <        $file=$ENV{TOOL_HOME}."/".$file;
413 >        my $file;
414 >        ($file=$class."\.pm")=~s/::/\//g;
415 >        $file=$ENV{TOOL_HOME}."/".$file;
416  
417 <        if ( ! -f $file ) {
418 <          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});    
419 <        }
420 <        print "--------------------- $class ------------------\n";
421 <        my $fh=FileHandle->new();
417 >        if ( ! -f $file ) {
418 >          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});
419 >        }
420 >        print "--------------------- $class ------------------\n";
421 >        my $fh=FileHandle->new();
422          $fh->open("<$file");
423          while ( <$fh> ) {
424             if ( $_=~/#\s*Interface/g ) {
# Line 331 | Line 442 | sub scramobjectinterface {
442             }
443          }
444          print "\n";
445 <        undef $fh;
445 >        undef $fh;
446   }
447  
448   # -------------- Support Routines ------------------------------
# Line 344 | Line 455 | sub _allprojectinitsearcher {
455             $search->addproject($$proj[0],$$proj[1]);
456            }
457          }
458 +        return $self->{projsearcher};
459   }
460  
461   sub _projsearcher {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines