1 |
williamc |
1.2 |
#
|
2 |
|
|
# ScramFunctions.pm
|
3 |
|
|
#
|
4 |
|
|
# Written by Christopher Williams
|
5 |
|
|
#
|
6 |
|
|
# Description
|
7 |
|
|
#
|
8 |
|
|
# Interface
|
9 |
|
|
# ---------
|
10 |
|
|
# new() : A new ScramCommands object
|
11 |
|
|
# project(urlstring,dir[,areaname]): Create a project from the given url file
|
12 |
|
|
# return the area
|
13 |
|
|
# satellite(name,version,installdirectory[,areaname]): create a satellite
|
14 |
|
|
# project from the specified name version
|
15 |
|
|
# addareatoDB(ConfigArea[,name[,version]]) : add area to the db
|
16 |
|
|
# globalcache([cachedirectory])) : return the global cache object/set at dir.
|
17 |
|
|
# scramprojectdb() : return the scram project DB object
|
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 |
williamc |
1.6 |
# scramobjectinterface(Class) : print out the interface of a scram class
|
22 |
williamc |
1.10 |
# webget(area,url) : get the url into the cache of the specified area
|
23 |
williamc |
1.8 |
# getversion() : return the current scram version
|
24 |
|
|
# spawnversion(version,@args) : spawn the scram version with the given args
|
25 |
williamc |
1.10 |
# classverbose(classstring,setting) : Set the class verbosity level
|
26 |
|
|
# toolruntime(ConfigArea): Get a runtime object withthe settings from
|
27 |
|
|
# the specified toolbox
|
28 |
williamc |
1.2 |
|
29 |
|
|
package Scram::ScramFunctions;
|
30 |
|
|
use URL::URLcache;
|
31 |
|
|
use Utilities::Verbose;
|
32 |
sashby |
1.22 |
use Utilities::IndexedFileStore;
|
33 |
|
|
|
34 |
williamc |
1.2 |
require 5.004;
|
35 |
|
|
|
36 |
|
|
@ISA=qw(Utilities::Verbose);
|
37 |
|
|
|
38 |
sashby |
1.11 |
sub new
|
39 |
|
|
{
|
40 |
|
|
my $class=shift;
|
41 |
|
|
$self={};
|
42 |
|
|
bless $self, $class;
|
43 |
|
|
# -- default settings
|
44 |
|
|
$self->{cachedir}=$ENV{HOME}."/.scramrc/globalcache";
|
45 |
|
|
$self->{scramprojectsdbdir}=$ENV{SCRAM_LOOKUPDB};
|
46 |
|
|
($self->{scram_top})=( $ENV{SCRAM_HOME}=~/(.*)\//) ;
|
47 |
|
|
|
48 |
|
|
return $self;
|
49 |
|
|
}
|
50 |
williamc |
1.2 |
|
51 |
williamc |
1.10 |
sub classverbose {
|
52 |
|
|
my $self=shift;
|
53 |
|
|
my $class=shift;
|
54 |
|
|
my $val=shift;
|
55 |
|
|
|
56 |
|
|
$ENV{"VERBOSE_".$class}=$val;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
williamc |
1.2 |
sub project {
|
60 |
|
|
my $self=shift;
|
61 |
|
|
my $url=shift;
|
62 |
|
|
my $installarea=shift;
|
63 |
|
|
|
64 |
|
|
my $areaname="";
|
65 |
|
|
if ( @_ ) {
|
66 |
|
|
$areaname=shift;
|
67 |
|
|
}
|
68 |
|
|
require Configuration::BootStrapProject;
|
69 |
|
|
my $bs=Configuration::BootStrapProject->
|
70 |
|
|
new($self->globalcache(),$installarea);
|
71 |
|
|
$self->verbose("BootStrapping $url");
|
72 |
|
|
my $area=$bs->boot($url,$areaname);
|
73 |
|
|
if ( ! defined $area ) {
|
74 |
|
|
$self->error("Unable to create project area");
|
75 |
|
|
}
|
76 |
|
|
$area->archname($self->arch());
|
77 |
|
|
|
78 |
|
|
# -- download all tool description files
|
79 |
|
|
my $req=$self->arearequirements($area);
|
80 |
sashby |
1.22 |
$area->toolboxversion($req->{configversion});
|
81 |
|
|
|
82 |
williamc |
1.2 |
if ( defined $req ) {
|
83 |
|
|
$req->download($self->areatoolbox($area));
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
return $area;
|
87 |
|
|
}
|
88 |
|
|
|
89 |
sashby |
1.18 |
sub setuptoolsinarea
|
90 |
|
|
{
|
91 |
|
|
my $self=shift;
|
92 |
|
|
my $area=shift;
|
93 |
sashby |
1.19 |
|
94 |
sashby |
1.18 |
# -- initialise
|
95 |
|
|
print "Initialising setup procedure......","\n";
|
96 |
|
|
$self->_allprojectinitsearcher();
|
97 |
|
|
|
98 |
|
|
# -- create a new toolbox object
|
99 |
|
|
my $toolbox=$self->areatoolbox($area);
|
100 |
|
|
$toolbox->searcher($self->_allprojectinitsearcher());
|
101 |
|
|
|
102 |
|
|
if ( @_ )
|
103 |
|
|
{
|
104 |
|
|
# -- specific tool specified
|
105 |
|
|
if ( my $rv=$toolbox->toolsetup(@_) )
|
106 |
|
|
{
|
107 |
|
|
if ( $rv eq 1 )
|
108 |
|
|
{
|
109 |
|
|
print "Unknown tool $toolname @ARGV\n";
|
110 |
|
|
exit 1;
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
else
|
115 |
|
|
{
|
116 |
|
|
# -- setup all tools specified in the requirements doc
|
117 |
|
|
print "Going to set up all tools....","\n\n";
|
118 |
|
|
my $reqs=$self->arearequirements($area);
|
119 |
|
|
$self->verbose("Setup ToolBox from Requirements doc ($reqs)");
|
120 |
|
|
# reqs is a BuildSystem::Requirements object:
|
121 |
|
|
$reqs->setup($toolbox);
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
williamc |
1.2 |
|
125 |
sashby |
1.22 |
sub updatetoolsinarea
|
126 |
|
|
{
|
127 |
|
|
my $self=shift;
|
128 |
|
|
my $area=shift;
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
my $toolbox=$self->areatoolbox($area);
|
132 |
|
|
|
133 |
|
|
print "Going to refresh the setup of tools....","\n\n";
|
134 |
|
|
my $currenttag = $area->toolboxversion();
|
135 |
|
|
|
136 |
|
|
# Get rid of the current cache:
|
137 |
|
|
my $cachename = $area->cache()->location();
|
138 |
|
|
system("mv","$cachename","$cachename".".$currenttag");
|
139 |
|
|
# Create a new one:
|
140 |
|
|
$area->_newcache();
|
141 |
|
|
my $reqs=$self->arearequirements($area);
|
142 |
|
|
$reqs->download();
|
143 |
|
|
$reqs->setup($toolbox);
|
144 |
|
|
print "Previous configuration tag : ",$currenttag,"\n";
|
145 |
|
|
$area->toolboxversion($reqs->{configversion});
|
146 |
|
|
print "Current configuration tag : ",$area->toolboxversion(),"\n\n";
|
147 |
|
|
$area->save();
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
sub satellite
|
151 |
|
|
{
|
152 |
|
|
#
|
153 |
|
|
# Modified to suit new structure
|
154 |
|
|
#
|
155 |
|
|
my $self=shift;
|
156 |
|
|
my $name=shift;
|
157 |
|
|
my $version=shift;
|
158 |
|
|
my $installarea=shift; # Where to install (-dir option in project cmd);
|
159 |
|
|
my $areaname=undef; # Name of the area (comes from -name option in project cmd);
|
160 |
|
|
|
161 |
|
|
if ( @_ )
|
162 |
|
|
{
|
163 |
|
|
$areaname=shift;
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
# Get location from SCRAMDB:
|
167 |
|
|
my $relarea=$self->_lookupareaindb($name,$version);
|
168 |
williamc |
1.2 |
|
169 |
sashby |
1.22 |
if ( ! defined $relarea )
|
170 |
|
|
{
|
171 |
|
|
$self->error("Unable to Find Project $name $version");
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
# Create a satellite area:
|
175 |
|
|
my $area=$relarea->satellite($installarea,$areaname);
|
176 |
|
|
$area->archname($self->arch());
|
177 |
williamc |
1.2 |
|
178 |
sashby |
1.23 |
# Copy the admin dir (and with it, the ToolCache):
|
179 |
|
|
$relarea->copywithskip($area->location(),'ProjectCache.db');
|
180 |
williamc |
1.4 |
|
181 |
sashby |
1.22 |
# Copy configuration directory contents:
|
182 |
|
|
if ( ! -d $area->location()."/".$area->configurationdir() )
|
183 |
|
|
{
|
184 |
|
|
use Utilities::AddDir;
|
185 |
|
|
AddDir::copydir($relarea->location()."/".$relarea->configurationdir(),
|
186 |
|
|
$area->location()."/".$area->configurationdir() );
|
187 |
|
|
}
|
188 |
williamc |
1.2 |
|
189 |
sashby |
1.22 |
# Make sourcecode dir:
|
190 |
|
|
if ( ! -d $area->location()."/".$area->sourcedir() )
|
191 |
|
|
{
|
192 |
|
|
use Utilities::AddDir;
|
193 |
|
|
AddDir::adddir($area->location()."/".$area->sourcedir());
|
194 |
|
|
}
|
195 |
williamc |
1.2 |
|
196 |
sashby |
1.22 |
# Copy RequirementsDoc:
|
197 |
|
|
if ( ! -f $area->requirementsdoc() )
|
198 |
|
|
{
|
199 |
|
|
use File::Copy;
|
200 |
|
|
copy( $relarea->requirementsdoc() , $area->requirementsdoc());
|
201 |
|
|
}
|
202 |
williamc |
1.2 |
|
203 |
sashby |
1.22 |
return $area;
|
204 |
|
|
}
|
205 |
williamc |
1.7 |
|
206 |
williamc |
1.10 |
sub toolruntime {
|
207 |
williamc |
1.7 |
my $self=shift;
|
208 |
|
|
my $area=shift;
|
209 |
sashby |
1.22 |
my $ld_lib_path="";
|
210 |
|
|
my $bin_path="";
|
211 |
williamc |
1.7 |
|
212 |
williamc |
1.10 |
my $name=$area->location();
|
213 |
sashby |
1.22 |
|
214 |
|
|
if ( ! defined $self->{toolruntime}{$name} )
|
215 |
|
|
{
|
216 |
|
|
require Runtime;
|
217 |
|
|
my $toolbox=$self->areatoolbox($area);
|
218 |
|
|
$self->{toolruntime}{$name}=Runtime->new();
|
219 |
|
|
|
220 |
|
|
# Test for SCRAM_ARCH/lib order:
|
221 |
|
|
if ( -d $area->location()."/".$self->arch())
|
222 |
|
|
{
|
223 |
|
|
$ld_lib_path = $area->location()."/".$self->arch()."/lib"
|
224 |
|
|
unless ( ! -d $area->location()."/".$self->arch()."/lib");
|
225 |
|
|
$bin_path = $area->location()."/".$self->arch()."/bin"
|
226 |
|
|
unless ( ! -d $area->location()."/".$self->arch()."/bin");
|
227 |
|
|
}
|
228 |
|
|
# Other way around:
|
229 |
|
|
elsif ( -d $area->location()."/lib/".$self->arch())
|
230 |
|
|
{
|
231 |
|
|
$ld_lib_path = $area->location()."/lib/".$self->arch()
|
232 |
|
|
unless ( ! -d $area->location()."/lib/".$self->arch());
|
233 |
|
|
$bin_path = $area->location()."/bin/".$self->arch()
|
234 |
|
|
unless ( ! -d $area->location()."/bin/".$self->arch());
|
235 |
|
|
}
|
236 |
|
|
else
|
237 |
|
|
# Assume no arch so just use lib and bin:
|
238 |
|
|
{
|
239 |
|
|
$ld_lib_path = $area->location()."/lib";
|
240 |
|
|
$bin_path = $area->location()."/bin";
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
# -- Now set the scram area specific runtimes accordingly:
|
244 |
|
|
$self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",$ld_lib_path,"path");
|
245 |
|
|
$self->{toolruntime}{$name}->addvar("PATH",$bin_path,"path");
|
246 |
|
|
|
247 |
|
|
# Check for a linked area:
|
248 |
|
|
if ( defined $area->linkarea() )
|
249 |
|
|
{
|
250 |
|
|
my $relarea=$area->linkarea();
|
251 |
|
|
# Now do the checks for the release area:
|
252 |
|
|
if ( -d $relarea->location()."/".$self->arch())
|
253 |
|
|
{
|
254 |
|
|
$ld_lib_path = $relarea->location()."/".$self->arch()."/lib"
|
255 |
|
|
unless ( ! -d $relarea->location()."/".$self->arch()."/lib");
|
256 |
|
|
$bin_path = $relarea->location()."/".$self->arch()."/bin"
|
257 |
|
|
unless ( ! -d $relarea->location()."/".$self->arch()."/bin");
|
258 |
|
|
}
|
259 |
|
|
# Other way around:
|
260 |
|
|
elsif ( -d $relarea->location()."/lib/".$self->arch())
|
261 |
|
|
{
|
262 |
|
|
$ld_lib_path = $relarea->location()."/lib/".$self->arch()
|
263 |
|
|
unless ( ! -d $relarea->location()."/lib/".$self->arch());
|
264 |
|
|
$bin_path = $relarea->location()."/bin/".$self->arch()
|
265 |
|
|
unless ( ! -d $relarea->location()."/bin/".$self->arch());
|
266 |
|
|
}
|
267 |
|
|
else
|
268 |
|
|
# Assume no arch so just use lib and bin:
|
269 |
|
|
{
|
270 |
|
|
$ld_lib_path = $relarea->location()."/lib";
|
271 |
|
|
$bin_path = $relarea->location()."/bin";
|
272 |
|
|
}
|
273 |
|
|
# Add the release paths:
|
274 |
|
|
$self->{toolruntime}{$name}->addvar("LD_LIBRARY_PATH",$ld_lib_path,"path");
|
275 |
|
|
$self->{toolruntime}{$name}->addvar("PATH",$bin_path,"path");
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
# -- get the runtime environment from all the tools
|
279 |
|
|
my $tool;
|
280 |
|
|
foreach $toolname ( $toolbox->tools() )
|
281 |
|
|
{
|
282 |
|
|
$tool=$toolbox->gettool($toolname);
|
283 |
|
|
if ( defined $tool )
|
284 |
|
|
{
|
285 |
|
|
# -- get runtime paths
|
286 |
|
|
foreach $f ( $tool->listtype("runtime_path"))
|
287 |
|
|
{
|
288 |
|
|
foreach $val ( $tool->getfeature($f) )
|
289 |
|
|
{
|
290 |
|
|
$self->{toolruntime}{$name}->addvar($f,$val,"path");
|
291 |
|
|
}
|
292 |
|
|
}
|
293 |
|
|
# -- get runtime vars
|
294 |
|
|
foreach $f ( $tool->listtype("runtime"))
|
295 |
|
|
{
|
296 |
|
|
foreach $val ( $tool->getfeature($f) )
|
297 |
|
|
{
|
298 |
|
|
$self->{toolruntime}{$name}->addvar($f,$val);
|
299 |
|
|
}
|
300 |
|
|
}
|
301 |
|
|
}
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
# -- Get the project level environment
|
305 |
|
|
my $runtimefile=$area->location()."/".$area->configurationdir()."/Runtime";
|
306 |
|
|
|
307 |
|
|
if ( -f $runtimefile )
|
308 |
|
|
{
|
309 |
|
|
$self->{toolruntime}{$name}->file($runtimefile);
|
310 |
|
|
}
|
311 |
|
|
}
|
312 |
|
|
return $self->{toolruntime}{$name};
|
313 |
williamc |
1.10 |
}
|
314 |
|
|
|
315 |
|
|
sub webget {
|
316 |
|
|
my $self=shift;
|
317 |
|
|
my $area=shift;
|
318 |
|
|
my $url=shift;
|
319 |
|
|
|
320 |
|
|
require URL::URLhandler;
|
321 |
|
|
my $handler=URL::URLhandler->new($area->cache());
|
322 |
|
|
return ($handler->download($url));
|
323 |
williamc |
1.2 |
}
|
324 |
|
|
|
325 |
|
|
sub addareatoDB {
|
326 |
|
|
my $self=shift;
|
327 |
sashby |
1.22 |
my $flag=shift;
|
328 |
williamc |
1.2 |
my $area=shift;
|
329 |
|
|
my $tagname=shift;
|
330 |
|
|
my $version=shift;
|
331 |
|
|
|
332 |
|
|
# -- create defaults if necessary
|
333 |
|
|
if ( (! defined $version) || ( $version eq "") ) {
|
334 |
|
|
$version=$area->version();
|
335 |
|
|
}
|
336 |
|
|
if ( (! defined $tagname) || ( $tagname eq "") ) {
|
337 |
|
|
$tagname=$area->name();
|
338 |
|
|
}
|
339 |
|
|
# -- Add to the DB
|
340 |
sashby |
1.22 |
$self->scramprojectdb()->addarea($flag,$tagname,$version,$area);
|
341 |
williamc |
1.2 |
}
|
342 |
|
|
|
343 |
sashby |
1.13 |
|
344 |
|
|
sub removeareafromDB
|
345 |
|
|
{
|
346 |
|
|
###############################################################
|
347 |
|
|
# removearefromDB() #
|
348 |
|
|
###############################################################
|
349 |
|
|
# modified : Thu Jun 14 10:46:22 2001 / SFA #
|
350 |
|
|
# params : projectname, projectversion #
|
351 |
|
|
# : #
|
352 |
|
|
# : #
|
353 |
|
|
# : #
|
354 |
|
|
# function : Remove project <projectname> from DB file. #
|
355 |
|
|
# : #
|
356 |
|
|
# : #
|
357 |
|
|
###############################################################
|
358 |
|
|
my $self=shift;
|
359 |
sashby |
1.22 |
my $flag=shift;
|
360 |
sashby |
1.13 |
my $projname=shift;
|
361 |
|
|
my $version=shift;
|
362 |
|
|
|
363 |
|
|
# -- Remove from the DB:
|
364 |
sashby |
1.22 |
$self->scramprojectdb()->removearea($flag,$projname,$version);
|
365 |
sashby |
1.13 |
}
|
366 |
|
|
|
367 |
|
|
|
368 |
sashby |
1.12 |
sub spawnversion
|
369 |
|
|
{
|
370 |
sashby |
1.15 |
###############################################################
|
371 |
|
|
# spawnversion #
|
372 |
|
|
###############################################################
|
373 |
|
|
# modified : Fri Aug 10 15:42:08 2001 / SFA #
|
374 |
|
|
# params : #
|
375 |
|
|
# : #
|
376 |
|
|
# : #
|
377 |
|
|
# : #
|
378 |
|
|
# function : Check for version of scram to run, and run it. #
|
379 |
|
|
# : #
|
380 |
|
|
# : #
|
381 |
|
|
###############################################################
|
382 |
|
|
|
383 |
sashby |
1.12 |
my $self=shift;
|
384 |
|
|
my $version=shift;
|
385 |
|
|
my $rv=0;
|
386 |
|
|
|
387 |
|
|
my $thisversion=$self->getversion();
|
388 |
williamc |
1.8 |
|
389 |
sashby |
1.12 |
if ( defined $version )
|
390 |
|
|
{
|
391 |
|
|
if ( $version ne $thisversion )
|
392 |
|
|
{
|
393 |
|
|
# first try to use the correct version
|
394 |
|
|
if ( -d $self->{scram_top}."/".$version )
|
395 |
|
|
{
|
396 |
|
|
$ENV{SCRAM_HOME}=$self->{scram_top}."/".$version;
|
397 |
sashby |
1.22 |
$ENV{SCRAM_TOOL_HOME}="$ENV{SCRAM_HOME}/src";
|
398 |
sashby |
1.12 |
$self->verbose("Spawning SCRAM version $version");
|
399 |
sashby |
1.22 |
my $rv=system($ENV{SCRAM_HOME}."/src/main/scram.pl", @_)/256;
|
400 |
sashby |
1.12 |
exit $rv;
|
401 |
|
|
}
|
402 |
|
|
else
|
403 |
sashby |
1.21 |
{
|
404 |
|
|
# if not then simply warn. Send output to STDERR:
|
405 |
|
|
if ( -t STDERR )
|
406 |
|
|
{
|
407 |
|
|
print STDERR "******* Warning : scram version inconsistent ********\n";
|
408 |
|
|
print STDERR "This version: $thisversion; Required version: $version\n";
|
409 |
|
|
print STDERR "*****************************************************\n";
|
410 |
|
|
print STDERR "\n";
|
411 |
|
|
}
|
412 |
sashby |
1.12 |
}
|
413 |
|
|
}
|
414 |
|
|
}
|
415 |
|
|
else
|
416 |
|
|
{
|
417 |
|
|
$self->error("Undefined value for version requested");
|
418 |
|
|
$rv=1;
|
419 |
|
|
}
|
420 |
|
|
return $rv;
|
421 |
|
|
}
|
422 |
williamc |
1.8 |
|
423 |
williamc |
1.2 |
sub globalcache {
|
424 |
|
|
my $self=shift;
|
425 |
|
|
if ( @_ ) {
|
426 |
|
|
$self->{cachedir}=shift;
|
427 |
|
|
}
|
428 |
|
|
if ( ! defined $self->{globalcache} ) {
|
429 |
|
|
$self->{globalcache}=URL::URLcache->new($self->{cachedir});
|
430 |
|
|
}
|
431 |
|
|
return $self->{globalcache};
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
|
435 |
|
|
sub scramprojectdb {
|
436 |
|
|
my $self=shift;
|
437 |
|
|
if ( @_ ) {
|
438 |
|
|
$self->{scramprojectsdbdir}=shift;
|
439 |
|
|
}
|
440 |
|
|
if ( ! defined $self->{scramprojectsdb} ) {
|
441 |
|
|
require Scram::ScramProjectDB;
|
442 |
|
|
$self->{scramprojectsdb}=Scram::ScramProjectDB->new(
|
443 |
|
|
$self->{scramprojectsdbdir} );
|
444 |
|
|
$self->{scramprojectsdb}->verbosity($self->verbosity());
|
445 |
|
|
}
|
446 |
|
|
return $self->{scramprojectsdb};
|
447 |
|
|
}
|
448 |
williamc |
1.8 |
|
449 |
|
|
sub getversion {
|
450 |
|
|
my $self=shift;
|
451 |
|
|
|
452 |
|
|
my $thisversion;
|
453 |
|
|
($thisversion=$ENV{SCRAM_HOME})=~s/(.*)\///;
|
454 |
|
|
my $scram_top=$1;
|
455 |
|
|
my $scram_version=$thisversion;
|
456 |
|
|
# deal with links
|
457 |
|
|
my $version=readlink $ENV{SCRAM_HOME};
|
458 |
|
|
if ( defined $version) {
|
459 |
|
|
$scram_version=$version;
|
460 |
|
|
}
|
461 |
|
|
return $scram_version;
|
462 |
|
|
}
|
463 |
williamc |
1.2 |
|
464 |
|
|
sub areatoolbox {
|
465 |
|
|
my $self=shift;
|
466 |
|
|
my $area=shift;
|
467 |
|
|
|
468 |
|
|
my $name=$area->location();
|
469 |
|
|
if ( ! defined $self->{toolboxes}{$name} ) {
|
470 |
|
|
# -- create a new toolbox object
|
471 |
|
|
require BuildSystem::ToolBox;
|
472 |
williamc |
1.8 |
$self->{toolboxes}{$name}=BuildSystem::ToolBox->new($area,
|
473 |
|
|
$self->arch());
|
474 |
williamc |
1.2 |
$self->{toolboxes}{$name}->verbosity($self->verbosity());
|
475 |
|
|
}
|
476 |
|
|
return $self->{toolboxes}{$name};
|
477 |
|
|
}
|
478 |
|
|
|
479 |
sashby |
1.22 |
sub areatoolmanager
|
480 |
|
|
{
|
481 |
|
|
my $self=shift;
|
482 |
|
|
my $area=shift;
|
483 |
|
|
|
484 |
|
|
my $name=$area->location();
|
485 |
|
|
|
486 |
|
|
if ( ! defined $self->{toolmanagers}{$name} )
|
487 |
|
|
{
|
488 |
|
|
use BuildSystem::ToolManager;
|
489 |
|
|
$self->{toolmanagers}{$name}=ToolManager->new($area,$self->arch());
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
return $self->{toolmanagers}{$name};
|
493 |
|
|
}
|
494 |
|
|
|
495 |
williamc |
1.2 |
sub arearequirements {
|
496 |
|
|
my $self=shift;
|
497 |
|
|
my $area=shift;
|
498 |
|
|
|
499 |
|
|
my $name=$area->location();
|
500 |
|
|
if ( ! defined $self->{requirements}{$name} ) {
|
501 |
|
|
# -- create a new toolbox object
|
502 |
|
|
require BuildSystem::Requirements;
|
503 |
|
|
my $doc=$area->requirementsdoc();
|
504 |
|
|
my $cache=$area->cache();
|
505 |
|
|
my $db=$area->objectstore();
|
506 |
|
|
require ActiveDoc::ActiveStore;
|
507 |
|
|
my $astore=ActiveDoc::ActiveStore->new($db,$cache);
|
508 |
|
|
$self->{requirements}{$name}=
|
509 |
|
|
BuildSystem::Requirements->new($astore,"file:".$doc,
|
510 |
|
|
$ENV{SCRAM_ARCH});
|
511 |
|
|
$self->{requirements}{$name}->verbosity($self->verbosity());
|
512 |
|
|
$self->verbose("Requirements Doc (".$self->{requirements}{$name}.
|
513 |
|
|
") for area :\n $name\n initiated from $doc");
|
514 |
|
|
}
|
515 |
|
|
else {
|
516 |
|
|
$self->verbose("Requirements Doc (".$self->{requirements}{$name}.")");
|
517 |
|
|
}
|
518 |
|
|
return $self->{requirements}{$name};
|
519 |
|
|
}
|
520 |
|
|
|
521 |
|
|
sub arch {
|
522 |
|
|
my $self=shift;
|
523 |
|
|
|
524 |
|
|
@_?$self->{arch}=shift
|
525 |
|
|
:$self->{arch};
|
526 |
williamc |
1.6 |
}
|
527 |
|
|
|
528 |
|
|
sub scramobjectinterface {
|
529 |
williamc |
1.10 |
my $self=shift;
|
530 |
|
|
my $class=shift;
|
531 |
williamc |
1.6 |
|
532 |
williamc |
1.10 |
my $file;
|
533 |
|
|
($file=$class."\.pm")=~s/::/\//g;
|
534 |
sashby |
1.22 |
$file=$ENV{SCRAM_TOOL_HOME}."/".$file;
|
535 |
williamc |
1.6 |
|
536 |
williamc |
1.10 |
if ( ! -f $file ) {
|
537 |
sashby |
1.22 |
$self->error("Unable to find $class in ".$ENV{SCRAM_TOOL_HOME});
|
538 |
williamc |
1.10 |
}
|
539 |
|
|
print "--------------------- $class ------------------\n";
|
540 |
|
|
my $fh=FileHandle->new();
|
541 |
williamc |
1.6 |
$fh->open("<$file");
|
542 |
|
|
while ( <$fh> ) {
|
543 |
|
|
if ( $_=~/#\s*Interface/g ) {
|
544 |
|
|
$intregion=1;
|
545 |
|
|
next;
|
546 |
|
|
}
|
547 |
|
|
if ( $intregion ) { # if we are in the interface documentation
|
548 |
|
|
if ( ( $_!~/^#/ ) || ( $_=~/^#\s?-{40}/ ) ) { #moving out of Int doc
|
549 |
|
|
$intregion=0;
|
550 |
|
|
next;
|
551 |
|
|
}
|
552 |
|
|
print $_;
|
553 |
|
|
if ( $_=~/^#\s*(.*)\((.*)\)?:(.*)/ ) {
|
554 |
|
|
$interface=$1;
|
555 |
|
|
$args=$2;
|
556 |
|
|
$rest=$3;
|
557 |
|
|
next if ($interface eq "");
|
558 |
|
|
push @interfaces,$interface;
|
559 |
|
|
$interfaceargs{$interface}=$args;
|
560 |
|
|
}
|
561 |
|
|
}
|
562 |
|
|
}
|
563 |
|
|
print "\n";
|
564 |
williamc |
1.10 |
undef $fh;
|
565 |
williamc |
1.2 |
}
|
566 |
|
|
|
567 |
|
|
# -------------- Support Routines ------------------------------
|
568 |
|
|
|
569 |
|
|
|
570 |
|
|
sub _allprojectinitsearcher {
|
571 |
|
|
if ( ! defined $self->{projsearcher} ) {
|
572 |
|
|
my $search=_projsearcher();
|
573 |
|
|
foreach $proj ( $self->scramprojectdb()->list() ) {
|
574 |
|
|
$search->addproject($$proj[0],$$proj[1]);
|
575 |
|
|
}
|
576 |
|
|
}
|
577 |
williamc |
1.10 |
return $self->{projsearcher};
|
578 |
williamc |
1.2 |
}
|
579 |
|
|
|
580 |
|
|
sub _projsearcher {
|
581 |
|
|
if ( ! defined $self->{projsearcher} ) {
|
582 |
|
|
require Scram::ProjectSearcher;
|
583 |
|
|
$self->{projsearcher}=Scram::ProjectSearcher->new(
|
584 |
|
|
$self->scramprojectdb());
|
585 |
|
|
}
|
586 |
|
|
return $self->{projsearcher};
|
587 |
|
|
}
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
sub _lookupareaindb {
|
591 |
|
|
my $self=shift;
|
592 |
|
|
|
593 |
|
|
my $area=undef;
|
594 |
|
|
# -- Look up the area in the databse
|
595 |
|
|
my @areas=$self->scramprojectdb()->getarea(@_);
|
596 |
|
|
if ( $#areas > 0 ) { #ambigous
|
597 |
|
|
# could ask user - for now just error
|
598 |
|
|
$self->error("Ambigous request - please be more specific");
|
599 |
|
|
}
|
600 |
|
|
elsif ( $#areas != 0 ) { #not found
|
601 |
|
|
$self->error("The project requested has not been found");
|
602 |
|
|
}
|
603 |
|
|
else {
|
604 |
|
|
$area=$areas[0];
|
605 |
|
|
}
|
606 |
|
|
return $area;
|
607 |
|
|
}
|