3 |
|
#____________________________________________________________________ |
4 |
|
# |
5 |
|
# Author: Shaun Ashby <Shaun.Ashby@cern.ch> |
6 |
– |
# Update: 2003-11-12 15:04:16+0100 |
7 |
– |
# Revision: $Id$ |
8 |
– |
# |
6 |
|
# Copyright: 2003 (C) Shaun Ashby |
7 |
|
# |
8 |
|
#-------------------------------------------------------------------- |
13 |
|
use BuildSystem::ToolCache; |
14 |
|
use BuildSystem::ToolParser; |
15 |
|
use Utilities::AddDir; |
19 |
– |
use URL::URLhandler; |
16 |
|
use Utilities::Verbose; |
17 |
+ |
use SCRAM::MsgLog; |
18 |
|
|
19 |
|
@ISA=qw(BuildSystem::ToolCache Utilities::Verbose); |
20 |
|
@EXPORT_OK=qw( ); |
21 |
|
# |
22 |
< |
# |
22 |
> |
|
23 |
|
sub new |
27 |
– |
############################################################### |
28 |
– |
# new # |
29 |
– |
############################################################### |
30 |
– |
# modified : Wed Nov 12 10:34:10 2003 / SFA # |
31 |
– |
# params : # |
32 |
– |
# : # |
33 |
– |
# function : # |
34 |
– |
# : # |
35 |
– |
############################################################### |
24 |
|
{ |
25 |
|
my $proto=shift; |
26 |
|
my $class=ref($proto) || $proto; |
27 |
|
my $self=$class->SUPER::new(); # Inherit from ToolCache |
40 |
– |
my $projectarea=shift; |
41 |
– |
|
28 |
|
bless $self,$class; |
29 |
< |
|
44 |
< |
$self->{arch}=shift; |
45 |
< |
$self->{topdir}=$projectarea->location(); |
46 |
< |
$self->{configdir}=$self->{topdir}."/".$projectarea->configurationdir(); |
47 |
< |
$self->{cache}=$projectarea->cache(); # Download tool cache |
48 |
< |
$self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools"; |
49 |
< |
$self->{datastore}=$self->{topdir}."/.SCRAM"; |
50 |
< |
$self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
51 |
< |
|
52 |
< |
# Make sure our tool download dir exists: |
53 |
< |
AddDir::adddir($self->{toolfiledir}); |
54 |
< |
AddDir::adddir($self->{archstore}); |
55 |
< |
|
56 |
< |
# Set the tool cache file to read/write: |
57 |
< |
$self->name($projectarea->toolcachename()); |
58 |
< |
|
59 |
< |
# Check for the downloaded tools cache: |
60 |
< |
if (exists($self->{cache})) |
61 |
< |
{ |
62 |
< |
$self->{urlhandler}=URL::URLhandler->new($self->{cache}); |
63 |
< |
} |
64 |
< |
|
29 |
> |
$self->init (shift); |
30 |
|
return $self; |
31 |
|
} |
32 |
|
|
33 |
< |
sub clone() |
33 |
> |
sub init () |
34 |
|
{ |
35 |
|
my $self=shift; |
36 |
|
my $projectarea=shift; |
72 |
– |
|
73 |
– |
# Change cache settings to reflect the new location: |
37 |
|
$self->{topdir}=$projectarea->location(); |
75 |
– |
|
38 |
|
$self->{configdir}=$self->{topdir}."/".$projectarea->configurationdir(); |
39 |
< |
$self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools"; |
40 |
< |
$self->{datastore}=$self->{topdir}."/.SCRAM"; |
79 |
< |
$self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
80 |
< |
|
81 |
< |
# Change the cache name: |
39 |
> |
$self->{archstore}=$projectarea->archdir(); |
40 |
> |
$self->{toolcache}=$self->{configdir}."/toolbox/$ENV{SCRAM_ARCH}/tools"; |
41 |
|
$self->name($projectarea->toolcachename()); |
42 |
< |
$self->cloned_tm(1); |
84 |
< |
|
85 |
< |
return $self; |
42 |
> |
$self->dirty(); |
43 |
|
} |
44 |
< |
|
88 |
< |
sub arch_change_after_copy() |
89 |
< |
{ |
90 |
< |
my $self=shift; |
91 |
< |
my ($newarch, $cachename)=@_; |
92 |
< |
# Make changes to arch-specific settings when copying tool manager |
93 |
< |
# object to another arch during setup: |
94 |
< |
$self->{arch} = $newarch; |
95 |
< |
$self->{archstore} = $self->{topdir}."/.SCRAM/".$newarch; |
96 |
< |
# Change the name of the cache to reflect new (arch-specific) location: |
97 |
< |
$self->name($cachename); |
98 |
< |
} |
99 |
< |
|
100 |
< |
sub interactive() |
101 |
< |
{ |
102 |
< |
my $self=shift; |
103 |
< |
# Interactive mode on/off: |
104 |
< |
@_ ? $self->{interactive} = shift |
105 |
< |
: ((defined $self->{interactive}) ? $self->{interactive} : 0); |
106 |
< |
} |
107 |
< |
|
44 |
> |
|
45 |
|
sub setupalltools() |
46 |
|
{ |
47 |
|
my $self = shift; |
48 |
< |
my ($arealocation,$setupopt) = @_; |
49 |
< |
my (@localtools); |
50 |
< |
my $selected; |
114 |
< |
|
115 |
< |
# Get the selected tool list. Handle the case where there might not be |
116 |
< |
# any selected tools: //FIXME: need to handle case where there are no |
117 |
< |
# selected tools (not very often but a possibility): |
118 |
< |
my $sel = $self->selected(); |
119 |
< |
|
120 |
< |
if (defined ($sel)) |
121 |
< |
{ |
122 |
< |
$selected = [ keys %{$sel} ]; |
123 |
< |
} |
124 |
< |
|
125 |
< |
# Setup option "setupopt" directs the setup: 1 is for booting from |
126 |
< |
# scratch, 0 is when just doing "scram setup" (in this case we don't |
127 |
< |
# want to pick up everything from any scram-managed projects): |
128 |
< |
if ($setupopt == 1) # We're booting from scratch |
129 |
< |
{ |
130 |
< |
# Check to see if there are any SCRAM-managed projects in our local requirements: |
131 |
< |
my $scramprojects = $::scram->_loadscramdb(); |
132 |
< |
|
133 |
< |
# Look for a match in the scram db: |
134 |
< |
foreach my $S (@$selected) |
135 |
< |
{ |
136 |
< |
if (exists ($scramprojects->{$S})) |
137 |
< |
{ |
138 |
< |
# Now check the version required exists in |
139 |
< |
# list of scram projects with this name: |
140 |
< |
while (my ($pdata,$plocation) = each %{$scramprojects->{$S}}) |
141 |
< |
{ |
142 |
< |
# Split the $pdata string to get the real name and the version: |
143 |
< |
my ($pname,$pversion) = split(":",$pdata); |
144 |
< |
if ($pversion eq $self->defaultversion($S)) |
145 |
< |
{ |
146 |
< |
# Get the tool manager for the scram project: |
147 |
< |
my $sa=$::scram->scramfunctions()->scramprojectdb()->getarea($pname,$pversion); |
148 |
< |
# Load the tool cache: |
149 |
< |
if ( -r $sa->toolcachename()) |
150 |
< |
{ |
151 |
< |
use Cache::CacheUtilities; |
152 |
< |
my $satoolmanager=&Cache::CacheUtilities::read($sa->toolcachename()); |
153 |
< |
# Copy needed content from toolmanager for scram-managed project: |
154 |
< |
$self->inheritcontent($satoolmanager); |
155 |
< |
} |
156 |
< |
} |
157 |
< |
} |
158 |
< |
# Also add this scram-managed project to list of tools to set up: |
159 |
< |
push(@localtools,$S); |
160 |
< |
} |
161 |
< |
else |
162 |
< |
{ |
163 |
< |
# Store other tools in ReqDoc in separate array. We will set up these tools later: |
164 |
< |
push(@localtools,$S); |
165 |
< |
} |
166 |
< |
} |
167 |
< |
|
168 |
< |
# Set up extra tools required in this project, in addition to |
169 |
< |
# any scram-managed projects |
170 |
< |
foreach my $localtool (@localtools) |
171 |
< |
{ |
172 |
< |
# First check to see if it's already set up (i.e., was contained |
173 |
< |
# in list of requirements for scram project): |
174 |
< |
if (! $self->definedtool($localtool)) |
175 |
< |
{ |
176 |
< |
$self->toolsetup($arealocation,$localtool,$self->defaultversion($localtool)); |
177 |
< |
$self->addtoselected($localtool); |
178 |
< |
} |
179 |
< |
else |
180 |
< |
{ |
181 |
< |
print $localtool," already set up.","\n",if ($ENV{SCRAM_DEBUG}); |
182 |
< |
} |
183 |
< |
} |
184 |
< |
} |
185 |
< |
else |
48 |
> |
my @selected=(); |
49 |
> |
my $tooldir=$self->{toolcache}."/selected"; |
50 |
> |
foreach my $tool (@{&getfileslist($tooldir)}) |
51 |
|
{ |
52 |
< |
# Just loop over all tools and setup again: |
188 |
< |
foreach my $localtool (@{$selected}) |
189 |
< |
{ |
190 |
< |
$self->toolsetup($arealocation,$localtool,$self->defaultversion($localtool)); |
191 |
< |
} |
52 |
> |
if ($tool=~/^(.+)\.xml$/) {push @selected,$1;} |
53 |
|
} |
54 |
< |
|
55 |
< |
print "\n"; |
54 |
> |
foreach my $tool (@selected){$self->coresetup("${tooldir}/${tool}.xml");} |
55 |
> |
scramlogmsg("\n"); |
56 |
|
} |
57 |
|
|
58 |
|
sub coresetup() |
59 |
|
{ |
60 |
|
my $self=shift; |
61 |
< |
my ($toolname, $toolversion, $toolfile) = @_; |
201 |
< |
my ($toolcheck, $toolparser); |
61 |
> |
my ($toolfile) = @_; |
62 |
|
|
63 |
< |
print "\n"; |
64 |
< |
print $::bold."Setting up ",$toolname," version ",$toolversion,": ".$::normal,"\n"; |
65 |
< |
|
66 |
< |
# New ToolParser object for this tool if there isn't one already. |
67 |
< |
# Look in array of raw tools to see if this tool has a ToolParser object: |
68 |
< |
$toolcheck=0; |
69 |
< |
|
210 |
< |
map |
211 |
< |
{ |
212 |
< |
if ($_->toolname() eq $toolname) {$toolcheck = 1; $toolparser = $_;} |
213 |
< |
} $self->rawtools(); |
214 |
< |
|
215 |
< |
# Tool not known so we create a new ToolParser object and parse it: |
216 |
< |
if ($toolcheck != 1) |
217 |
< |
{ |
218 |
< |
$toolparser = BuildSystem::ToolParser->new(); |
219 |
< |
# We only want to store the stuff relevant for one particular version: |
220 |
< |
$toolparser->parse($toolname, $toolversion, $toolfile); |
221 |
< |
# Store the ToolParser object in the cache: |
222 |
< |
$self->store($toolparser); |
223 |
< |
} |
63 |
> |
my $toolparser = BuildSystem::ToolParser->new(); |
64 |
> |
$toolparser->filehead('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">'); |
65 |
> |
$toolparser->filetail('</doc>'); |
66 |
> |
$toolparser->parse($toolfile); |
67 |
> |
my $toolname = $toolparser->toolname(); |
68 |
> |
my $toolversion = $toolparser->toolversion(); |
69 |
> |
scramlogmsg("\n",$::bold."Setting up ",$toolname," version ",$toolversion,": ".$::normal,"\n"); |
70 |
|
|
71 |
|
# Next, set up the tool: |
72 |
< |
my $store = $toolparser->processrawtool($self->interactive()); |
227 |
< |
# Make sure that we have this tool in the list of selected tools (just in case this tool was |
228 |
< |
# set up by hand afterwards): |
229 |
< |
$self->addtoselected($toolname); |
230 |
< |
|
231 |
< |
# Check to see if this tool is a compiler. If so, store it. |
232 |
< |
# Also store the language that this compiler supprots, and a |
233 |
< |
# compiler name (e.g. gcc323) which, in conjunction with a stem |
234 |
< |
# architecture name like slc3_ia32_, can be used to build a complete arch string: |
235 |
< |
if ($store->scram_compiler() == 1) |
236 |
< |
{ |
237 |
< |
my @supported_language = $store->flags("SCRAM_LANGUAGE_TYPE"); |
238 |
< |
my @compilername = $store->flags("SCRAM_COMPILER_NAME"); |
239 |
< |
$self->scram_compiler($supported_language[0],$toolname,$compilername[0]); |
240 |
< |
} |
241 |
< |
|
242 |
< |
# Store the ToolData object in the cache: |
243 |
< |
$self->storeincache($toolparser->toolname(),$store); |
244 |
< |
return $self; |
245 |
< |
} |
72 |
> |
my $store = $toolparser->processrawtool(); |
73 |
|
|
74 |
< |
sub toolsetup() |
75 |
< |
{ |
76 |
< |
my $self=shift; |
77 |
< |
my ($arealocation, $toolname, $toolversion, $toolurl) = @_; |
78 |
< |
my ($urlcache, $url, $filename, $tfname); |
79 |
< |
my $toolfile; |
80 |
< |
|
81 |
< |
$toolname =~ tr[A-Z][a-z]; |
82 |
< |
$toolversion ||= $self->defaultversion($toolname); |
83 |
< |
$urlcache=URL::URLcache->new($arealocation."/.SCRAM/cache"); # Download tool cache |
84 |
< |
|
85 |
< |
# Check for the downloaded tools cache: |
259 |
< |
if (defined($urlcache)) |
260 |
< |
{ |
261 |
< |
$self->{urlhandler}=URL::URLhandler->new($urlcache); |
262 |
< |
} |
263 |
< |
|
264 |
< |
$url = $self->toolurls()->{$toolname}; |
265 |
< |
$filename = $self->{toolfiledir}."/".$toolname; |
266 |
< |
|
267 |
< |
# If .SCRAM/InstalledTools doesn't exist, create it: |
268 |
< |
if (! -d $self->{toolfiledir}) |
269 |
< |
{ |
270 |
< |
AddDir::adddir($self->{toolfiledir}); |
271 |
< |
} |
272 |
< |
|
273 |
< |
# First, check to see if there was a tool URL given. If so, we might need to read |
274 |
< |
# from http or from a file: type URL: |
275 |
< |
if (my ($proto, $urlv) = ($toolurl =~ /(.*):(.*)/)) |
276 |
< |
{ |
277 |
< |
# See what kind of URL (file:, http:, cvs:, svn:, .. ): |
278 |
< |
if ($proto eq 'file') |
279 |
< |
{ |
280 |
< |
# If the tool url is a file and the file exists, |
281 |
< |
# copy it to .SCRAM/InstalledTools and set the |
282 |
< |
# filename accordingly: |
283 |
< |
if ( -f $urlv) |
284 |
< |
{ |
285 |
< |
use File::Copy; |
286 |
< |
copy($urlv, $filename); |
287 |
< |
my $mode = 0644; chmod $mode, $filename; |
288 |
< |
$toolfile=$filename; |
289 |
< |
} |
290 |
< |
else |
291 |
< |
{ |
292 |
< |
$::scram->scramerror("Unable to set up $toolname from URL $toolurl-- $urlv does not exist!"); |
293 |
< |
} |
294 |
< |
} |
295 |
< |
elsif ($proto eq 'http') |
296 |
< |
{ |
297 |
< |
print "SCRAM: downloading $toolname from $toolurl","\n"; |
298 |
< |
# Download from WWW first: |
299 |
< |
use LWP::Simple qw(&getstore); |
300 |
< |
my $http_response_val = &getstore($toolurl, $filename); |
301 |
< |
|
302 |
< |
# Check the HTTP status. If doc not found, exit: |
303 |
< |
if ($http_response_val != 200) |
304 |
< |
{ |
305 |
< |
my ($server,$doc) = ($urlv =~ m|//(.*?)/(.*)|); |
306 |
< |
$::scram->scramerror("Unable to set up $toolname: $doc not found on $server!"); |
307 |
< |
} |
308 |
< |
else |
309 |
< |
{ |
310 |
< |
$toolfile=$filename; |
311 |
< |
} |
312 |
< |
} |
313 |
< |
elsif ($proto eq 'cvs') |
314 |
< |
{ |
315 |
< |
print "SCRAM: downloading $toolname from $urlv using protocol $proto.","\n"; |
316 |
< |
print "[ not yet supported ]","\n"; |
317 |
< |
exit(0); |
318 |
< |
} |
319 |
< |
elsif ($proto eq 'svn') |
320 |
< |
{ |
321 |
< |
print "SCRAM: downloading $toolname from $urlv using protocol $proto.","\n"; |
322 |
< |
print "[ not yet supported ]","\n"; |
323 |
< |
exit(0); |
324 |
< |
} |
325 |
< |
else |
326 |
< |
{ |
327 |
< |
$::scram->scramerror("Unable to download $urlv! Unknown protocol \"$proto\". Bye."); |
328 |
< |
} |
329 |
< |
} |
330 |
< |
else |
331 |
< |
{ |
332 |
< |
# Copy the downloaded tool file to InstalledTools directory: |
333 |
< |
if ( ! -f $filename ) |
334 |
< |
{ |
335 |
< |
# If the URL is empty, the chances are that this tool was not downloaded to .SCRAM/InstalledTools. |
336 |
< |
# We signal an error and exit: |
337 |
< |
if ($url eq '') |
338 |
< |
{ |
339 |
< |
$::scram->scramerror("$toolname was selected in project requirements but is not in the configuration!"); |
340 |
< |
} |
341 |
< |
else |
342 |
< |
{ |
343 |
< |
# Otherwise, we try to download it: |
344 |
< |
$self->verbose("Attempting Download of $url"); |
345 |
< |
# Get file from download cache: |
346 |
< |
($url,$filename)=$self->{urlhandler}->get($url); |
347 |
< |
use File::Copy; |
348 |
< |
$tfname=$self->{toolfiledir}."/".$toolname; |
349 |
< |
copy($filename, $tfname); |
350 |
< |
my $mode = 0644; chmod $mode, $tfname; |
351 |
< |
$toolfile=$tfname; |
352 |
< |
} |
353 |
< |
} |
354 |
< |
else |
355 |
< |
{ |
356 |
< |
# File already exists in the .SCRAM/InstallTools directory: |
357 |
< |
$toolfile=$filename; |
74 |
> |
# Store the ToolData object in the cache: |
75 |
> |
$self->storeincache($toolname,$store); |
76 |
> |
my $srcfile=Utilities::AddDir::fixpath($toolfile); |
77 |
> |
my $desfile=Utilities::AddDir::fixpath($self->{toolcache}."/selected/${toolname}.xml"); |
78 |
> |
use File::Copy; |
79 |
> |
if ($srcfile ne $desfile) |
80 |
> |
{ |
81 |
> |
use File::Copy; |
82 |
> |
my $desfile1=Utilities::AddDir::fixpath($self->{toolcache}."/available/${toolname}.xml"); |
83 |
> |
if ($srcfile ne $desfile1) |
84 |
> |
{ |
85 |
> |
copy($srcfile,$desfile1); |
86 |
|
} |
87 |
+ |
if (-e $desfile) { unlink($desfile);} |
88 |
+ |
symlink("../available/${toolname}.xml",$desfile); |
89 |
|
} |
90 |
< |
|
361 |
< |
# Run the core setup routine: |
362 |
< |
$self->coresetup($toolname, $toolversion, $toolfile); |
90 |
> |
scramlogclean(); |
91 |
|
return $self; |
92 |
|
} |
93 |
|
|
94 |
|
sub setupself() |
95 |
|
{ |
96 |
|
my $self=shift; |
369 |
– |
my ($location)=@_; |
97 |
|
# Process the file "Self" in local config directory. This is used to |
98 |
|
# set all the paths/runtime settings for this project: |
99 |
< |
my $filename=$location."/config/Self"; |
99 |
> |
my $filename=$self->{configdir}."/Self.xml"; |
100 |
|
|
101 |
|
if ( -f $filename ) |
102 |
|
{ |
103 |
< |
print "\n"; |
377 |
< |
print $::bold."Setting up SELF:".$::normal,"\n"; |
103 |
> |
scramlogmsg("\n",$::bold."Setting up SELF:".$::normal,"\n"); |
104 |
|
# Self file exists so process it: |
105 |
|
$selfparser = BuildSystem::ToolParser->new(); |
106 |
< |
$selfparser->parse('self','SELF',$filename); |
106 |
> |
$selfparser->filehead ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">'); |
107 |
> |
$selfparser->filehead ('</doc>'); |
108 |
> |
$selfparser->parse($filename); |
109 |
|
|
110 |
|
# Next, set up the tool: |
111 |
< |
$store = $selfparser->processrawtool($self->interactive()); |
112 |
< |
|
111 |
> |
$store = $selfparser->processrawtool(); |
112 |
> |
|
113 |
|
# If we are in a developer area, also add RELEASETOP paths: |
114 |
|
if (exists($ENV{RELEASETOP})) |
115 |
|
{ |
119 |
|
|
120 |
|
# Store the ToolData object in the cache: |
121 |
|
$self->storeincache($selfparser->toolname(),$store); |
122 |
< |
print "\n"; |
122 |
> |
scramlogmsg("\n"); |
123 |
|
} |
124 |
|
else |
125 |
|
{ |
126 |
< |
print "\n"; |
127 |
< |
print "SCRAM: No file config/Self...nothing to do."; |
128 |
< |
print "\n"; |
126 |
> |
scramlogdump(); |
127 |
> |
print STDERR "\n"; |
128 |
> |
print STDERR "SCRAM: No file config/Self.xml...nothing to do."; |
129 |
> |
print STDERR "\n"; |
130 |
|
return; |
131 |
|
} |
132 |
|
} |
133 |
|
|
134 |
< |
sub defaultversion() |
134 |
> |
sub update() |
135 |
|
{ |
136 |
< |
my $self = shift; |
137 |
< |
my ($tool) = @_; |
138 |
< |
# Return default versions as taken from configuration: |
139 |
< |
return (%{$self->defaultversions()}->{$tool}); |
136 |
> |
my $self=shift; |
137 |
> |
my $area=shift; |
138 |
> |
$self->init($area); |
139 |
> |
$self->setupself(); |
140 |
> |
$self->dirty () |
141 |
|
} |
142 |
< |
|
142 |
> |
|
143 |
|
sub storeincache() |
144 |
|
{ |
145 |
|
my $self=shift; |
148 |
|
# Store ToolData object (for a set-up tool) in cache: |
149 |
|
if (ref($dataobject) eq 'BuildSystem::ToolData') |
150 |
|
{ |
151 |
+ |
$self->updatetooltimestamp($dataobject, $toolname); |
152 |
+ |
delete $self->{SETUP}->{$toolname}; |
153 |
|
$self->{SETUP}->{$toolname} = $dataobject; |
154 |
|
} |
155 |
|
else |
179 |
|
{ |
180 |
|
my $self = shift; |
181 |
|
my $tooldata = []; |
182 |
< |
my $rawsel = $self->selected(); |
183 |
< |
|
184 |
< |
foreach my $tool ( sort { %{$rawsel}->{$a} |
453 |
< |
<=> %{$rawsel}->{$b}} |
454 |
< |
keys %{$rawsel} ) |
182 |
> |
$self->{internal}{donetools}={}; |
183 |
> |
$self->{internal}{scram_tools}={}; |
184 |
> |
foreach my $tool (sort keys %{$self->{SETUP}}) |
185 |
|
{ |
186 |
< |
# Return tool data objects of all set-up tools, skipping the tool "self": |
187 |
< |
if ($_ ne "self") |
186 |
> |
if ($self->{SETUP}{$tool}->scram_project()) {$self->{internal}{scram_tools}{$tool}=1;} |
187 |
> |
elsif ($tool ne "self") |
188 |
|
{ |
189 |
< |
# Keep only tools that have really been set up: |
190 |
< |
if (exists $self->{SETUP}->{$tool}) |
189 |
> |
$self->_toolsdata($tool,$tooldata); |
190 |
> |
} |
191 |
> |
} |
192 |
> |
foreach my $tool (keys %{$self->{internal}{scram_tools}}) |
193 |
> |
{ |
194 |
> |
$self->_toolsdata_scram($tool,$tooldata); |
195 |
> |
} |
196 |
> |
delete $self->{internal}{donetools}; |
197 |
> |
delete $self->{internal}{scram_tools}; |
198 |
> |
my $data=[]; |
199 |
> |
foreach my $d (@$tooldata) |
200 |
> |
{ |
201 |
> |
if (ref($d) eq "ARRAY") |
202 |
> |
{ |
203 |
> |
foreach my $t (@$d) {push @$data,$t;} |
204 |
> |
} |
205 |
> |
} |
206 |
> |
return $data; |
207 |
> |
} |
208 |
> |
|
209 |
> |
sub _toolsdata() |
210 |
> |
{ |
211 |
> |
my $self = shift; |
212 |
> |
my $tool=shift; |
213 |
> |
my $data=shift || []; |
214 |
> |
my $order=-1; |
215 |
> |
if(exists $self->{internal}{donetools}{$tool}){return $self->{internal}{donetools}{$tool};} |
216 |
> |
$self->{internal}{donetools}{$tool}=$order; |
217 |
> |
if (exists $self->{SETUP}{$tool}) |
218 |
> |
{ |
219 |
> |
if (exists $self->{SETUP}{$tool}{USE}) |
220 |
> |
{ |
221 |
> |
foreach my $use (@{$self->{SETUP}{$tool}{USE}}) |
222 |
|
{ |
223 |
< |
push(@tooldata,$self->{SETUP}->{$tool}); |
223 |
> |
my $o=$self->_toolsdata(lc($use),$data); |
224 |
> |
if ($o>$order){$order=$o;} |
225 |
|
} |
226 |
|
} |
227 |
+ |
$order++; |
228 |
+ |
if(!defined $data->[$order]){$data->[$order]=[];} |
229 |
+ |
push @{$data->[$order]},$self->{SETUP}{$tool}; |
230 |
+ |
$self->{internal}{donetools}{$tool}=$order; |
231 |
|
} |
232 |
< |
|
467 |
< |
# Return the array of tools, in order that they appear in RequirementsDoc: |
468 |
< |
return @tooldata; |
232 |
> |
return $order; |
233 |
|
} |
234 |
|
|
235 |
< |
sub definedtool() |
235 |
> |
sub _toolsdata_scram() |
236 |
|
{ |
237 |
< |
my $self=shift; |
238 |
< |
my ($tool)=@_; |
239 |
< |
|
240 |
< |
# Check to see if tool X is an external tool: |
241 |
< |
grep ($_ eq $tool, keys %{$self->{SETUP}}) ? return 1 |
242 |
< |
: return 0; |
237 |
> |
my $self = shift; |
238 |
> |
my $tool=shift; |
239 |
> |
my $data=shift || []; |
240 |
> |
my $order=-1; |
241 |
> |
if(exists $self->{internal}{donetools}{$tool}){return $self->{internal}{donetools}{$tool};} |
242 |
> |
$self->{internal}{donetools}{$tool}=$order; |
243 |
> |
if(!exists $self->{internal}{scram_tools}{$tool}){return $order;} |
244 |
> |
use Configuration::ConfigArea; |
245 |
> |
use Cache::CacheUtilities; |
246 |
> |
my $cache=uc($tool)."_BASE"; |
247 |
> |
$cache=$self->{SETUP}{$tool}{$cache}; |
248 |
> |
if (!-d $cache) |
249 |
> |
{ |
250 |
> |
print STDERR "ERROR: Release area \"$cache\" for \"$tool\" is not available.\n"; |
251 |
> |
return $order; |
252 |
> |
} |
253 |
> |
my $area=Configuration::ConfigArea->new(); |
254 |
> |
$area->location($cache); |
255 |
> |
my $cachefile=$area->toolcachename(); |
256 |
> |
if (!-f $cachefile) |
257 |
> |
{ |
258 |
> |
print STDERR "ERROR: Tools cache file for release area \"$cache\" is not available.\n"; |
259 |
> |
return $order; |
260 |
> |
} |
261 |
> |
$cache=&Cache::CacheUtilities::read($cachefile); |
262 |
> |
my $tools=$cache->setup(); |
263 |
> |
$order=scalar(@$data)-1; |
264 |
> |
foreach my $use (keys %$tools) |
265 |
> |
{ |
266 |
> |
if ($tools->{$use}->scram_project() == 1) |
267 |
> |
{ |
268 |
> |
my $o=$self->_toolsdata_scram($use,$data); |
269 |
> |
if ($o>$order){$order=$o;} |
270 |
> |
} |
271 |
> |
} |
272 |
> |
$order++; |
273 |
> |
if(!defined $data->[$order]){$data->[$order]=[];} |
274 |
> |
push @{$data->[$order]},$self->{SETUP}{$tool}; |
275 |
> |
$self->{internal}{donetools}{$tool}=$order; |
276 |
> |
return $order; |
277 |
|
} |
278 |
< |
|
278 |
> |
|
279 |
|
sub checkifsetup() |
280 |
|
{ |
281 |
|
my $self=shift; |
285 |
|
: return undef; |
286 |
|
} |
287 |
|
|
490 |
– |
sub cloned_tm() |
491 |
– |
{ |
492 |
– |
my $self=shift; |
493 |
– |
# Has this area already been cloned and brought in-line with current location: |
494 |
– |
@_ ? $self->{CLONED} = $_[0] |
495 |
– |
: $self->{CLONED}; |
496 |
– |
} |
497 |
– |
|
288 |
|
sub remove_tool() |
289 |
|
{ |
290 |
|
my $self=shift; |
291 |
|
my ($toolname)=@_; |
292 |
< |
my $tools = $self->{SETUP}; |
293 |
< |
my $newtlist = {}; |
294 |
< |
|
295 |
< |
while (my ($tool, $tooldata) = each %$tools) |
292 |
> |
delete $self->{SETUP}{$toolname}; |
293 |
> |
print "Deleting $toolname from cache.","\n"; |
294 |
> |
$self->updatetooltimestamp (undef, $toolname); |
295 |
> |
$self->writecache(); |
296 |
> |
my $file1=$self->{toolcache}."/selected/${toolname}.xml"; |
297 |
> |
my $file2=$self->{toolcache}."/available/${toolname}.xml"; |
298 |
> |
if ((!-f $file2) && (-f $file1)) |
299 |
|
{ |
300 |
< |
if ($tool ne $toolname) |
301 |
< |
{ |
509 |
< |
$newtlist->{$tool} = $tooldata; |
510 |
< |
} |
511 |
< |
else |
512 |
< |
{ |
513 |
< |
print "Deleting $toolname from cache.","\n"; |
514 |
< |
} |
300 |
> |
use File::Copy; |
301 |
> |
copy ($file1,$file2); |
302 |
|
} |
303 |
< |
|
517 |
< |
$self->{SETUP} = $newtlist; |
518 |
< |
|
519 |
< |
# Now remove from the RAW tool list: |
520 |
< |
$self->cleanup_raw($toolname); |
521 |
< |
|
522 |
< |
print "ToolManager: Updating tool cache.","\n"; |
523 |
< |
$self->writecache(); |
303 |
> |
unlink ($file1); |
304 |
|
} |
305 |
|
|
306 |
|
sub scram_projects() |
318 |
|
return $scram_projects; |
319 |
|
} |
320 |
|
|
321 |
< |
sub scram_compiler() |
321 |
> |
sub updatetooltimestamp () |
322 |
|
{ |
323 |
|
my $self=shift; |
324 |
< |
my ($langtype, $toolname, $compilername)=@_; |
324 |
> |
my $obj=shift; |
325 |
> |
my $toolname=shift; |
326 |
> |
my $samevalues=0; |
327 |
> |
my $stampdir = $self->{archstore}."/timestamps"; |
328 |
> |
my $stampfile="${stampdir}/${toolname}"; |
329 |
> |
if (exists $self->{SETUP}->{$toolname}) |
330 |
> |
{ |
331 |
> |
$samevalues=$self->comparetoolsdata($self->{SETUP}->{$toolname},$obj); |
332 |
> |
} |
333 |
> |
if ($toolname ne "self") |
334 |
> |
{ |
335 |
> |
my $instdir = $self->{archstore}."/InstalledTools"; |
336 |
> |
my $tfile = "${instdir}/${toolname}"; |
337 |
> |
if ((!defined $obj) && (-f $tfile)) {unlink $tfile;} |
338 |
> |
elsif ((defined $obj) && (!-f $tfile)) |
339 |
> |
{ |
340 |
> |
Utilities::AddDir::adddir($instdir); |
341 |
> |
my $ref; |
342 |
> |
open($ref,">$tfile"); |
343 |
> |
close($ref); |
344 |
> |
} |
345 |
> |
} |
346 |
> |
if ((!$samevalues) || (!-f $stampfile)) |
347 |
> |
{ |
348 |
> |
if (!-d $stampdir) |
349 |
> |
{ |
350 |
> |
Utilities::AddDir::adddir($stampdir); |
351 |
> |
} |
352 |
> |
my $ref; |
353 |
> |
open($ref,">$stampfile"); |
354 |
> |
close($ref); |
355 |
> |
if (!$samevalues){$self->dirty();} |
356 |
> |
} |
357 |
> |
} |
358 |
|
|
359 |
< |
if ($langtype) |
359 |
> |
sub comparetoolsdata () |
360 |
> |
{ |
361 |
> |
my $self=shift; |
362 |
> |
my $data1=shift || (); |
363 |
> |
my $data2=shift || (); |
364 |
> |
|
365 |
> |
my $ref1=ref($data1); |
366 |
> |
my $ref2=ref($data2); |
367 |
> |
|
368 |
> |
if ($ref1 ne $ref2) |
369 |
|
{ |
370 |
< |
# Store the compiler info according to supported |
371 |
< |
# language types. |
372 |
< |
# |
373 |
< |
# ---------------------- e.g C++ cxxcompiler gcc323 |
374 |
< |
$self->{SCRAM_COMPILER}->{$langtype}=[ $toolname, $compilername ]; |
370 |
> |
return 0; |
371 |
> |
} |
372 |
> |
elsif ($ref1 eq "CODE") |
373 |
> |
{ |
374 |
> |
return 1; |
375 |
> |
} |
376 |
> |
elsif(($ref1 eq "SCALAR") || ($ref1 eq "")) |
377 |
> |
{ |
378 |
> |
if ($data1 eq $data2) |
379 |
> |
{ |
380 |
> |
return 1; |
381 |
> |
} |
382 |
> |
return 0; |
383 |
> |
} |
384 |
> |
elsif ($ref1 eq "ARRAY") |
385 |
> |
{ |
386 |
> |
my $count = scalar(@$data1); |
387 |
> |
if ($count != scalar(@$data2)) |
388 |
> |
{ |
389 |
> |
return 0; |
390 |
> |
} |
391 |
> |
for (my $i=0; $i<$count; $i++) |
392 |
> |
{ |
393 |
> |
if (! $self->comparetoolsdata($data1->[$i],$data2->[$i])) |
394 |
> |
{ |
395 |
> |
return 0; |
396 |
> |
} |
397 |
> |
} |
398 |
> |
return 1; |
399 |
|
} |
400 |
|
else |
401 |
|
{ |
402 |
< |
return $self->{SCRAM_COMPILER}; |
402 |
> |
foreach my $k (keys %{$data1}) |
403 |
> |
{ |
404 |
> |
if (! exists $data2->{$k}) |
405 |
> |
{ |
406 |
> |
return 0; |
407 |
> |
} |
408 |
> |
} |
409 |
> |
foreach my $k (keys %{$data2}) |
410 |
> |
{ |
411 |
> |
if (! exists $data1->{$k}) |
412 |
> |
{ |
413 |
> |
return 0; |
414 |
> |
} |
415 |
> |
} |
416 |
> |
foreach my $k (keys %{$data2}) |
417 |
> |
{ |
418 |
> |
if (! $self->comparetoolsdata($data1->{$k},$data2->{$k})) |
419 |
> |
{ |
420 |
> |
return 0; |
421 |
> |
} |
422 |
> |
} |
423 |
> |
return 1; |
424 |
|
} |
425 |
|
} |
426 |
|
|