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.7 by williamc, Wed Sep 13 15:46:18 2000 UTC vs.
Revision 1.10 by williamc, Wed Nov 15 10:08:27 2000 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 35 | Line 40 | sub new {
40          # -- default settings
41          $self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
42          $self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
43 +        ($self->{scram_top})=( $ENV{SCRAM_HOME}=~/(.*)\//) ;
44 +
45          return $self;
46   }
47  
48 + sub classverbose {
49 +        my $self=shift;
50 +        my $class=shift;
51 +        my $val=shift;
52 +
53 +        $ENV{"VERBOSE_".$class}=$val;
54 + }
55 +
56   sub project {
57          my $self=shift;
58          my $url=shift;
# Line 75 | Line 90 | sub setuptoolsinarea {
90  
91          # -- create a new toolbox object
92          my $toolbox=$self->areatoolbox($area);
93 <        $toolbox->searcher($self->_projsearcher());
93 >        $toolbox->searcher($self->_allprojectinitsearcher());
94  
95          if ( @_ ) {
96              # -- specific tool specified
# Line 144 | Line 159 | sub satellite {
159          return $area;
160   }
161  
162 < sub webget {
162 > sub toolruntime {
163          my $self=shift;
164          my $area=shift;
150        my $url=shift;
165  
166 <        my $handler=URL::URLhandler->new($area->cache());
167 <        return ($handler->get($url));
166 >        my $name=$area->location();
167 >        if ( ! defined $self->{toolruntime}{$name} ) {
168 >         require Runtime;
169 >         my $toolbox=$self->areatoolbox($area);
170 >         $self->{toolruntime}{$name}=Runtime->new();
171 >
172 >         # -- add scram area specific runtimes
173 >         $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
174 >                $area->location()."/lib/".$self->arch(),"path");
175 >         $self->{toolruntime}{$name}->addvar("PATH",
176 >                $area->location()."/bin/".$self->arch(),"path");
177 >         if ( defined $area->linkarea() ) {
178 >          my $reltop=$area->linkarea()->location();
179 >          $self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",
180 >                $reltop."/lib/".$self->arch(),"path");
181 >          $self->{toolruntime}{$name}->addvar("PATH",
182 >                $reltop."/bin/".$self->arch(),"path");
183 >         }
184 >
185 >         # -- get the runtime environment from all the tools
186 >         my $tool;
187 >         foreach $toolname ( $toolbox->tools() ) {
188 >          $tool=$toolbox->gettool($toolname);
189 >          if ( defined $tool ) {
190 >            # -- get runtime paths
191 >            foreach $f ( $tool->listtype("runtime_path")) {
192 >             foreach $val ( $tool->getfeature($f) ) {
193 >              $self->{toolruntime}{$name}->addvar($f,$val,"path");
194 >             }
195 >            }
196 >            # -- get runtime vars
197 >            foreach $f ( $tool->listtype("runtime")) {
198 >             foreach $val ( $tool->getfeature($f) ) {
199 >              $self->{toolruntime}{$name}->addvar($f,$val);
200 >             }
201 >            }
202 >          }
203 >         }
204 >
205 >         # -- Get the project level environment
206 >         my $runtimefile=$area->location()."/".$area->configurationdir()
207 >                                                                ."/Runtime";
208 >         if ( -f $runtimefile ) {
209 >          $self->{toolruntime}{$name}->file($runtimefile);
210 >         }
211 >        }
212 >        return $self->{toolruntime}{$name};
213 > }
214 >
215 > sub webget {
216 >        my $self=shift;
217 >        my $area=shift;
218 >        my $url=shift;
219 >
220 >        require URL::URLhandler;
221 >        my $handler=URL::URLhandler->new($area->cache());
222 >        return ($handler->download($url));
223   }
224  
225   sub addareatoDB {
# Line 171 | Line 240 | sub addareatoDB {
240          $self->scramprojectdb()->addarea($tagname,$version,$area);
241   }
242  
243 + sub spawnversion {
244 +        my $self=shift;
245 +        my $version=shift;
246 +
247 +        my $rv=0;
248 +        my $thisversion=$self->getversion();
249 +        if ( defined $version ) {
250 +          if ( $version ne $thisversion ) {
251 +              # first try to use the correct version
252 +              if ( -d $self->{scram_top}."/".$version ) {
253 +                $ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
254 +                $ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src";
255 +                $self->verbose("Spawning SCRAM version $version");
256 +                my $rv=system("scram", @_)/256;
257 +                exit $rv;
258 +              }
259 +              else { # if not then simply warn
260 +               print "******* Warning : scram version inconsistent ********\n";
261 +               print "This version: $thisversion; Required version: $version\n";
262 +               print "*****************************************************\n";
263 +               print "\n";
264 +              }
265 +           }
266 +        }
267 +        else {
268 +           $self->error("Undefined value for version requested");
269 +           $rv=1;
270 +        }
271 +        return $rv;
272 + }
273 +
274   sub globalcache {
275          my $self=shift;
276          if ( @_ ) {
# Line 196 | Line 296 | sub scramprojectdb {
296          }
297          return $self->{scramprojectsdb};
298   }
299 +
300 + sub getversion {
301 +        my $self=shift;
302 +        
303 +        my $thisversion;
304 +        ($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
305 +        my $scram_top=$1;
306 +        my $scram_version=$thisversion;
307 +        # deal with links
308 +        my $version=readlink $ENV{SCRAM_HOME};
309 +        if ( defined $version)  {
310 +          $scram_version=$version;
311 +        }
312 +        return $scram_version;
313 + }
314  
315   sub areatoolbox {
316          my $self=shift;
# Line 205 | Line 320 | sub areatoolbox {
320          if ( ! defined $self->{toolboxes}{$name} ) {
321            # -- create a new toolbox object
322            require BuildSystem::ToolBox;
323 <          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area);
323 >          $self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area,
324 >                                                        $self->arch());
325            $self->{toolboxes}{$name}->verbosity($self->verbosity());
326          }
327          return $self->{toolboxes}{$name};
# Line 245 | Line 361 | sub arch {
361   }
362  
363   sub scramobjectinterface {
364 <        my $self=shift;
365 <        my $class=shift;
364 >        my $self=shift;
365 >        my $class=shift;
366  
367 <        my $file;
368 <        ($file=$class."\.pm")=~s/::/\//g;
369 <        $file=$ENV{TOOL_HOME}."/".$file;
367 >        my $file;
368 >        ($file=$class."\.pm")=~s/::/\//g;
369 >        $file=$ENV{TOOL_HOME}."/".$file;
370  
371 <        if ( ! -f $file ) {
372 <          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});    
373 <        }
374 <        print "--------------------- $class ------------------\n";
375 <        my $fh=FileHandle->new();
371 >        if ( ! -f $file ) {
372 >          $self->error("Unable to find $class in ".$ENV{TOOL_HOME});
373 >        }
374 >        print "--------------------- $class ------------------\n";
375 >        my $fh=FileHandle->new();
376          $fh->open("<$file");
377          while ( <$fh> ) {
378             if ( $_=~/#\s*Interface/g ) {
# Line 280 | Line 396 | sub scramobjectinterface {
396             }
397          }
398          print "\n";
399 <        undef $fh;
399 >        undef $fh;
400   }
401  
402   # -------------- Support Routines ------------------------------
# Line 293 | Line 409 | sub _allprojectinitsearcher {
409             $search->addproject($$proj[0],$$proj[1]);
410            }
411          }
412 +        return $self->{projsearcher};
413   }
414  
415   sub _projsearcher {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines