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 |
+ |
# 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; |
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 |
34 |
< |
$self->{cachedir}=$ENV{HOME}."/.SCRAM/globalcache"; |
35 |
< |
$self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB}; |
36 |
< |
return $self; |
52 |
> |
my $val=shift; |
53 |
> |
|
54 |
> |
$ENV{"VERBOSE_".$class}=$val; |
55 |
|
} |
56 |
|
|
57 |
|
sub project { |
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 |
116 |
|
my $version=shift; |
117 |
|
my $installarea=shift; |
118 |
|
|
119 |
< |
my $areaname=""; |
119 |
> |
my $areaname=undef; |
120 |
|
if ( @_ ) { |
121 |
|
$areaname=shift; |
122 |
|
} |
127 |
|
$self->error("Unable to Find Project $name $version"); |
128 |
|
} |
129 |
|
|
130 |
+ |
# -- fix for old broken areas |
131 |
+ |
if ( (! defined $relarea->version()) || ($relarea->version() eq "") ) { |
132 |
+ |
$relarea->version($version); |
133 |
+ |
} |
134 |
+ |
|
135 |
|
# -- create satellite |
136 |
|
my $area=$relarea->satellite($installarea,$areaname); |
137 |
|
$area->archname($self->arch()); |
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; |
241 |
|
$self->scramprojectdb()->addarea($tagname,$version,$area); |
242 |
|
} |
243 |
|
|
244 |
+ |
|
245 |
+ |
sub removeareafromDB |
246 |
+ |
{ |
247 |
+ |
############################################################### |
248 |
+ |
# removearefromDB() # |
249 |
+ |
############################################################### |
250 |
+ |
# modified : Thu Jun 14 10:46:22 2001 / SFA # |
251 |
+ |
# params : projectname, projectversion # |
252 |
+ |
# : # |
253 |
+ |
# : # |
254 |
+ |
# : # |
255 |
+ |
# function : Remove project <projectname> from DB file. # |
256 |
+ |
# : # |
257 |
+ |
# : # |
258 |
+ |
############################################################### |
259 |
+ |
my $self=shift; |
260 |
+ |
my $projname=shift; |
261 |
+ |
my $version=shift; |
262 |
+ |
|
263 |
+ |
# -- Remove from the DB: |
264 |
+ |
$self->scramprojectdb()->removearea($projname,$version); |
265 |
+ |
} |
266 |
+ |
|
267 |
+ |
|
268 |
+ |
sub spawnversion |
269 |
+ |
{ |
270 |
+ |
my $self=shift; |
271 |
+ |
my $version=shift; |
272 |
+ |
my $rv=0; |
273 |
+ |
|
274 |
+ |
my $thisversion=$self->getversion(); |
275 |
+ |
|
276 |
+ |
if ( defined $version ) |
277 |
+ |
{ |
278 |
+ |
if ( $version ne $thisversion ) |
279 |
+ |
{ |
280 |
+ |
# first try to use the correct version |
281 |
+ |
if ( -d $self->{scram_top}."/".$version ) |
282 |
+ |
{ |
283 |
+ |
$ENV{SCRAM_HOME}=$self->{scram_top}."/".$version; |
284 |
+ |
$ENV{TOOL_HOME}="$ENV{SCRAM_HOME}/src"; |
285 |
+ |
$self->verbose("Spawning SCRAM version $version"); |
286 |
+ |
my $rv=system("scram", @_)/256; |
287 |
+ |
exit $rv; |
288 |
+ |
} |
289 |
+ |
else |
290 |
+ |
{ # if not then simply warn |
291 |
+ |
print "******* Warning : scram version inconsistent ********\n"; |
292 |
+ |
print "This version: $thisversion; Required version: $version\n"; |
293 |
+ |
print "*****************************************************\n"; |
294 |
+ |
print "\n"; |
295 |
+ |
} |
296 |
+ |
} |
297 |
+ |
} |
298 |
+ |
else |
299 |
+ |
{ |
300 |
+ |
$self->error("Undefined value for version requested"); |
301 |
+ |
$rv=1; |
302 |
+ |
} |
303 |
+ |
return $rv; |
304 |
+ |
} |
305 |
+ |
|
306 |
|
sub globalcache { |
307 |
|
my $self=shift; |
308 |
|
if ( @_ ) { |
328 |
|
} |
329 |
|
return $self->{scramprojectsdb}; |
330 |
|
} |
331 |
+ |
|
332 |
+ |
sub getversion { |
333 |
+ |
my $self=shift; |
334 |
+ |
|
335 |
+ |
my $thisversion; |
336 |
+ |
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///; |
337 |
+ |
my $scram_top=$1; |
338 |
+ |
my $scram_version=$thisversion; |
339 |
+ |
# deal with links |
340 |
+ |
my $version=readlink $ENV{SCRAM_HOME}; |
341 |
+ |
if ( defined $version) { |
342 |
+ |
$scram_version=$version; |
343 |
+ |
} |
344 |
+ |
return $scram_version; |
345 |
+ |
} |
346 |
|
|
347 |
|
sub areatoolbox { |
348 |
|
my $self=shift; |
352 |
|
if ( ! defined $self->{toolboxes}{$name} ) { |
353 |
|
# -- create a new toolbox object |
354 |
|
require BuildSystem::ToolBox; |
355 |
< |
$self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area); |
355 |
> |
$self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area, |
356 |
> |
$self->arch()); |
357 |
|
$self->{toolboxes}{$name}->verbosity($self->verbosity()); |
358 |
|
} |
359 |
|
return $self->{toolboxes}{$name}; |
392 |
|
:$self->{arch}; |
393 |
|
} |
394 |
|
|
395 |
+ |
sub scramobjectinterface { |
396 |
+ |
my $self=shift; |
397 |
+ |
my $class=shift; |
398 |
+ |
|
399 |
+ |
my $file; |
400 |
+ |
($file=$class."\.pm")=~s/::/\//g; |
401 |
+ |
$file=$ENV{TOOL_HOME}."/".$file; |
402 |
+ |
|
403 |
+ |
if ( ! -f $file ) { |
404 |
+ |
$self->error("Unable to find $class in ".$ENV{TOOL_HOME}); |
405 |
+ |
} |
406 |
+ |
print "--------------------- $class ------------------\n"; |
407 |
+ |
my $fh=FileHandle->new(); |
408 |
+ |
$fh->open("<$file"); |
409 |
+ |
while ( <$fh> ) { |
410 |
+ |
if ( $_=~/#\s*Interface/g ) { |
411 |
+ |
$intregion=1; |
412 |
+ |
next; |
413 |
+ |
} |
414 |
+ |
if ( $intregion ) { # if we are in the interface documentation |
415 |
+ |
if ( ( $_!~/^#/ ) || ( $_=~/^#\s?-{40}/ ) ) { #moving out of Int doc |
416 |
+ |
$intregion=0; |
417 |
+ |
next; |
418 |
+ |
} |
419 |
+ |
print $_; |
420 |
+ |
if ( $_=~/^#\s*(.*)\((.*)\)?:(.*)/ ) { |
421 |
+ |
$interface=$1; |
422 |
+ |
$args=$2; |
423 |
+ |
$rest=$3; |
424 |
+ |
next if ($interface eq ""); |
425 |
+ |
push @interfaces,$interface; |
426 |
+ |
$interfaceargs{$interface}=$args; |
427 |
+ |
} |
428 |
+ |
} |
429 |
+ |
} |
430 |
+ |
print "\n"; |
431 |
+ |
undef $fh; |
432 |
+ |
} |
433 |
+ |
|
434 |
|
# -------------- Support Routines ------------------------------ |
435 |
|
|
436 |
|
|
441 |
|
$search->addproject($$proj[0],$$proj[1]); |
442 |
|
} |
443 |
|
} |
444 |
+ |
return $self->{projsearcher}; |
445 |
|
} |
446 |
|
|
447 |
|
sub _projsearcher { |