48 |
|
$self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools"; |
49 |
|
$self->{datastore}=$self->{topdir}."/.SCRAM"; |
50 |
|
$self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH}; |
51 |
+ |
$self->{tooltimestamp}="timestamps"; |
52 |
|
|
53 |
|
# Make sure our tool download dir exists: |
54 |
|
AddDir::adddir($self->{toolfiledir}); |
128 |
|
# want to pick up everything from any scram-managed projects): |
129 |
|
if ($setupopt == 1) # We're booting from scratch |
130 |
|
{ |
130 |
– |
# Check to see if there are any SCRAM-managed projects in our local requirements: |
131 |
– |
my $scramprojects = $::scram->_loadscramdb(); |
132 |
– |
|
131 |
|
# Look for a match in the scram db: |
132 |
|
foreach my $S (@$selected) |
133 |
|
{ |
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 |
– |
{ |
134 |
|
# Store other tools in ReqDoc in separate array. We will set up these tools later: |
135 |
|
push(@localtools,$S); |
165 |
– |
} |
136 |
|
} |
137 |
|
|
138 |
|
# Set up extra tools required in this project, in addition to |
186 |
|
if ($toolcheck != 1 || $force == 1) |
187 |
|
{ |
188 |
|
$toolparser = BuildSystem::ToolParser->new(); |
189 |
+ |
$toolparser->filehead('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">'); |
190 |
+ |
$toolparser->filetail('</doc>'); |
191 |
|
# We only want to store the stuff relevant for one particular version: |
192 |
|
$toolparser->parse($toolname, $toolversion, $toolfile); |
193 |
|
# Store the ToolParser object in the cache: |
212 |
|
$self->scram_compiler($supported_language[0],$toolname,$compilername[0]); |
213 |
|
} |
214 |
|
|
215 |
< |
# Store the ToolData object in the cache: |
215 |
> |
# Store the ToolData object in the cache: |
216 |
|
$self->storeincache($toolparser->toolname(),$store); |
217 |
|
return $self; |
218 |
|
} |
361 |
|
my ($location)=@_; |
362 |
|
# Process the file "Self" in local config directory. This is used to |
363 |
|
# set all the paths/runtime settings for this project: |
364 |
< |
my $filename=$location."/config/Self"; |
364 |
> |
my $filename=$location."/config/Self.xml"; |
365 |
|
|
366 |
|
if ( -f $filename ) |
367 |
|
{ |
369 |
|
print $::bold."Setting up SELF:".$::normal,"\n"; |
370 |
|
# Self file exists so process it: |
371 |
|
$selfparser = BuildSystem::ToolParser->new(); |
372 |
+ |
$selfparser->filehead ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">'); |
373 |
+ |
$selfparser->filehead ('</doc>'); |
374 |
|
$selfparser->parse('self','SELF',$filename); |
375 |
|
|
376 |
|
# Next, set up the tool: |
390 |
|
else |
391 |
|
{ |
392 |
|
print "\n"; |
393 |
< |
print "SCRAM: No file config/Self...nothing to do."; |
393 |
> |
print "SCRAM: No file config/Self.xml...nothing to do."; |
394 |
|
print "\n"; |
395 |
|
return; |
396 |
|
} |
412 |
|
# Store ToolData object (for a set-up tool) in cache: |
413 |
|
if (ref($dataobject) eq 'BuildSystem::ToolData') |
414 |
|
{ |
415 |
+ |
$self->updatetooltimestamp($dataobject, $toolname); |
416 |
|
$self->{SETUP}->{$toolname} = $dataobject; |
417 |
|
} |
418 |
|
else |
526 |
|
} |
527 |
|
|
528 |
|
$self->{SETUP} = $newtlist; |
529 |
< |
|
529 |
> |
$self->updatetooltimestamp ("", $toolname); |
530 |
|
# Now remove from the RAW tool list: |
531 |
|
$self->cleanup_raw($toolname); |
532 |
|
print "ToolManager: Updating tool cache.","\n"; |
579 |
|
# the desired name: |
580 |
|
if ($obj->toolname() eq $name) |
581 |
|
{ |
582 |
+ |
$self->updatetooltimestamp ($obj, $name); |
583 |
|
print "ToolManager: Updating the cached copy of ".$name."\n"; |
584 |
|
delete $self->{SETUP}->{$name}; |
585 |
|
$self->{SETUP}->{$name} = $obj; |
597 |
|
} |
598 |
|
} |
599 |
|
|
600 |
+ |
sub check_compatibility() |
601 |
+ |
{ |
602 |
+ |
my $self=shift; |
603 |
+ |
my ($itoolmgr)=@_; |
604 |
+ |
# Get the version of the toolmanager. If the project fails to return a version |
605 |
+ |
# string we return 0 for no compatibility (in which case, all tools will be set |
606 |
+ |
# up in the traditional way): |
607 |
+ |
my $itm_configversion = $itoolmgr->configversion(); |
608 |
+ |
if ($itm_configversion) |
609 |
+ |
{ |
610 |
+ |
# The configurations won't be identical. We must compare the digits: |
611 |
+ |
my ($numeric_version) = ($itm_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/); |
612 |
+ |
my $current_configversion = $self->configversion(); |
613 |
+ |
my ($current_numeric_version) = ($current_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/); |
614 |
+ |
($current_numeric_version == $numeric_version) && return 1; # OK, compatible; |
615 |
+ |
} |
616 |
+ |
# Project does not define configuration version so just return: |
617 |
+ |
return 0; |
618 |
+ |
} |
619 |
+ |
|
620 |
+ |
sub configversion() |
621 |
+ |
{ |
622 |
+ |
my $self=shift; |
623 |
+ |
@_ ? $self->{CONFIGVERSION} = shift |
624 |
+ |
: $self->{CONFIGVERSION}; |
625 |
+ |
} |
626 |
+ |
|
627 |
+ |
sub updatetooltimestamp () |
628 |
+ |
{ |
629 |
+ |
my $self=shift; |
630 |
+ |
my $obj=shift; |
631 |
+ |
my $toolname=shift; |
632 |
+ |
my $samevalues=0; |
633 |
+ |
my $stampdir = $self->{archstore}."/timestamps"; |
634 |
+ |
my $stampfile="${stampdir}/${toolname}"; |
635 |
+ |
if (exists $self->{SETUP}->{$toolname}) |
636 |
+ |
{ |
637 |
+ |
$samevalues=$self->comparetoolsdata($self->{SETUP}->{$toolname},$obj); |
638 |
+ |
} |
639 |
+ |
if ((!$samevalues) || (!-f $stampfile)) |
640 |
+ |
{ |
641 |
+ |
if (!-d $stampdir) |
642 |
+ |
{ |
643 |
+ |
AddDir::adddir($stampdir); |
644 |
+ |
} |
645 |
+ |
open(TIMESTAMPFILE,">$stampfile"); |
646 |
+ |
close(TIMESTAMPFILE); |
647 |
+ |
} |
648 |
+ |
} |
649 |
+ |
|
650 |
+ |
sub comparetoolsdata () |
651 |
+ |
{ |
652 |
+ |
my $self=shift; |
653 |
+ |
my $data1=shift || (); |
654 |
+ |
my $data2=shift || (); |
655 |
+ |
|
656 |
+ |
my $ref1=ref($data1); |
657 |
+ |
my $ref2=ref($data2); |
658 |
+ |
|
659 |
+ |
if ($ref1 ne $ref2) |
660 |
+ |
{ |
661 |
+ |
return 0; |
662 |
+ |
} |
663 |
+ |
elsif ($ref1 eq "CODE") |
664 |
+ |
{ |
665 |
+ |
return 1; |
666 |
+ |
} |
667 |
+ |
elsif(($ref1 eq "SCALAR") || ($ref1 eq "")) |
668 |
+ |
{ |
669 |
+ |
if ($data1 eq $data2) |
670 |
+ |
{ |
671 |
+ |
return 1; |
672 |
+ |
} |
673 |
+ |
return 0; |
674 |
+ |
} |
675 |
+ |
elsif ($ref1 eq "ARRAY") |
676 |
+ |
{ |
677 |
+ |
my $count = scalar(@$data1); |
678 |
+ |
if ($count != scalar(@$data2)) |
679 |
+ |
{ |
680 |
+ |
return 0; |
681 |
+ |
} |
682 |
+ |
for (my $i=0; $i<$count; $i++) |
683 |
+ |
{ |
684 |
+ |
if (! $self->comparetoolsdata($data1->[$i],$data2->[$i])) |
685 |
+ |
{ |
686 |
+ |
return 0; |
687 |
+ |
} |
688 |
+ |
} |
689 |
+ |
return 1; |
690 |
+ |
} |
691 |
+ |
else |
692 |
+ |
{ |
693 |
+ |
foreach my $k (keys %{$data1}) |
694 |
+ |
{ |
695 |
+ |
if (! exists $data2->{$k}) |
696 |
+ |
{ |
697 |
+ |
return 0; |
698 |
+ |
} |
699 |
+ |
} |
700 |
+ |
foreach my $k (keys %{$data2}) |
701 |
+ |
{ |
702 |
+ |
if (! exists $data1->{$k}) |
703 |
+ |
{ |
704 |
+ |
return 0; |
705 |
+ |
} |
706 |
+ |
} |
707 |
+ |
foreach my $k (keys %{$data2}) |
708 |
+ |
{ |
709 |
+ |
if (! $self->comparetoolsdata($data1->{$k},$data2->{$k})) |
710 |
+ |
{ |
711 |
+ |
return 0; |
712 |
+ |
} |
713 |
+ |
} |
714 |
+ |
return 1; |
715 |
+ |
} |
716 |
+ |
} |
717 |
+ |
|
718 |
|
1; |