ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/ToolManager.pm
Revision: 1.19.2.2
Committed: Tue Feb 19 15:06:03 2008 UTC (17 years, 2 months ago) by muzaffar
Content type: text/plain
Branch: forBinLess_SCRAM
CVS Tags: V1_2_1b, V1_2_1a, V1_2_3, V1_2_2, V1_2_2_relcand2, V1_2_2_relcand1, V1_2_1, V1_2_0, V1_2_0-cand11, V1_2_0-cand10, V1_2_0-cand9, V1_2_0-cand8, V1_2_0-cand7, V1_2_0-cand6, V1_2_0-cand5, V1_2_0-cand4
Branch point for: SCRAM_V2_0
Changes since 1.19.2.1: +5 -5 lines
Log Message:
fully qualified packages names

File Contents

# User Rev Content
1 sashby 1.2 #____________________________________________________________________
2     # File: ToolManager.pm
3     #____________________________________________________________________
4     #
5     # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6     # Update: 2003-11-12 15:04:16+0100
7 muzaffar 1.19.2.2 # Revision: $Id: ToolManager.pm,v 1.19.2.1 2008/02/15 17:30:59 muzaffar Exp $
8 sashby 1.2 #
9     # Copyright: 2003 (C) Shaun Ashby
10     #
11     #--------------------------------------------------------------------
12     package BuildSystem::ToolManager;
13     require 5.004;
14    
15     use Exporter;
16     use BuildSystem::ToolCache;
17     use BuildSystem::ToolParser;
18     use Utilities::AddDir;
19     use URL::URLhandler;
20     use Utilities::Verbose;
21 muzaffar 1.19 use SCRAM::MsgLog;
22 sashby 1.2
23     @ISA=qw(BuildSystem::ToolCache Utilities::Verbose);
24     @EXPORT_OK=qw( );
25     #
26 sashby 1.9
27 sashby 1.2 sub new
28     ###############################################################
29     # new #
30     ###############################################################
31     # modified : Wed Nov 12 10:34:10 2003 / SFA #
32     # params : #
33     # : #
34     # function : #
35     # : #
36     ###############################################################
37     {
38     my $proto=shift;
39     my $class=ref($proto) || $proto;
40     my $self=$class->SUPER::new(); # Inherit from ToolCache
41     my $projectarea=shift;
42    
43     bless $self,$class;
44    
45     $self->{arch}=shift;
46     $self->{topdir}=$projectarea->location();
47     $self->{configdir}=$self->{topdir}."/".$projectarea->configurationdir();
48     $self->{cache}=$projectarea->cache(); # Download tool cache
49     $self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools";
50     $self->{datastore}=$self->{topdir}."/.SCRAM";
51     $self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH};
52 muzaffar 1.18 $self->{tooltimestamp}="timestamps";
53 sashby 1.2
54     # Make sure our tool download dir exists:
55 muzaffar 1.19.2.2 Utilities::AddDir::adddir($self->{toolfiledir});
56     Utilities::AddDir::adddir($self->{archstore});
57 sashby 1.2
58     # Set the tool cache file to read/write:
59     $self->name($projectarea->toolcachename());
60    
61     # Check for the downloaded tools cache:
62     if (exists($self->{cache}))
63     {
64     $self->{urlhandler}=URL::URLhandler->new($self->{cache});
65     }
66    
67     return $self;
68     }
69    
70     sub clone()
71     {
72     my $self=shift;
73     my $projectarea=shift;
74 sashby 1.3
75 sashby 1.2 # Change cache settings to reflect the new location:
76     $self->{topdir}=$projectarea->location();
77    
78     $self->{configdir}=$self->{topdir}."/".$projectarea->configurationdir();
79     $self->{toolfiledir}=$self->{topdir}."/.SCRAM/InstalledTools";
80     $self->{datastore}=$self->{topdir}."/.SCRAM";
81     $self->{archstore}=$self->{topdir}."/.SCRAM/".$ENV{SCRAM_ARCH};
82    
83     # Change the cache name:
84     $self->name($projectarea->toolcachename());
85     $self->cloned_tm(1);
86    
87     return $self;
88     }
89    
90     sub arch_change_after_copy()
91     {
92     my $self=shift;
93     my ($newarch, $cachename)=@_;
94     # Make changes to arch-specific settings when copying tool manager
95     # object to another arch during setup:
96     $self->{arch} = $newarch;
97     $self->{archstore} = $self->{topdir}."/.SCRAM/".$newarch;
98     # Change the name of the cache to reflect new (arch-specific) location:
99     $self->name($cachename);
100     }
101    
102     sub interactive()
103     {
104     my $self=shift;
105     # Interactive mode on/off:
106     @_ ? $self->{interactive} = shift
107     : ((defined $self->{interactive}) ? $self->{interactive} : 0);
108     }
109    
110     sub setupalltools()
111     {
112     my $self = shift;
113     my ($arealocation,$setupopt) = @_;
114     my (@localtools);
115     my $selected;
116    
117     # Get the selected tool list. Handle the case where there might not be
118     # any selected tools: //FIXME: need to handle case where there are no
119     # selected tools (not very often but a possibility):
120     my $sel = $self->selected();
121    
122     if (defined ($sel))
123     {
124     $selected = [ keys %{$sel} ];
125     }
126    
127     # Setup option "setupopt" directs the setup: 1 is for booting from
128     # scratch, 0 is when just doing "scram setup" (in this case we don't
129     # want to pick up everything from any scram-managed projects):
130     if ($setupopt == 1) # We're booting from scratch
131     {
132     # Look for a match in the scram db:
133 muzaffar 1.18 foreach my $S (@$selected)
134     {
135     # Store other tools in ReqDoc in separate array. We will set up these tools later:
136     push(@localtools,$S);
137     }
138 sashby 1.2
139     # Set up extra tools required in this project, in addition to
140     # any scram-managed projects
141     foreach my $localtool (@localtools)
142     {
143     # First check to see if it's already set up (i.e., was contained
144     # in list of requirements for scram project):
145     if (! $self->definedtool($localtool))
146     {
147     $self->toolsetup($arealocation,$localtool,$self->defaultversion($localtool));
148     $self->addtoselected($localtool);
149     }
150     else
151     {
152 muzaffar 1.19 scramlogmsg($localtool," already set up.","\n"),if ($ENV{SCRAM_DEBUG});
153 sashby 1.2 }
154     }
155     }
156     else
157     {
158     # Just loop over all tools and setup again:
159     foreach my $localtool (@{$selected})
160     {
161     $self->toolsetup($arealocation,$localtool,$self->defaultversion($localtool));
162     }
163     }
164    
165 muzaffar 1.19 scramlogmsg("\n");
166 sashby 1.2 }
167    
168     sub coresetup()
169     {
170     my $self=shift;
171 sashby 1.13 my ($toolname, $toolversion, $toolfile, $force) = @_;
172 sashby 1.2 my ($toolcheck, $toolparser);
173    
174 muzaffar 1.19 scramlogmsg("\n",$::bold."Setting up ",$toolname," version ",$toolversion,": ".$::normal,"\n");
175 sashby 1.2
176     # New ToolParser object for this tool if there isn't one already.
177     # Look in array of raw tools to see if this tool has a ToolParser object:
178     $toolcheck=0;
179    
180     map
181     {
182     if ($_->toolname() eq $toolname) {$toolcheck = 1; $toolparser = $_;}
183     } $self->rawtools();
184    
185     # Tool not known so we create a new ToolParser object and parse it:
186 sashby 1.13 if ($toolcheck != 1 || $force == 1)
187 sashby 1.2 {
188     $toolparser = BuildSystem::ToolParser->new();
189 muzaffar 1.18 $toolparser->filehead('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">');
190     $toolparser->filetail('</doc>');
191 sashby 1.2 # 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:
194     $self->store($toolparser);
195 sashby 1.13 print "\nFile $toolfile reparsed (modified)","\n",if ($ENV{SCRAM_DEBUG});
196 sashby 1.2 }
197    
198     # Next, set up the tool:
199     my $store = $toolparser->processrawtool($self->interactive());
200     # Make sure that we have this tool in the list of selected tools (just in case this tool was
201     # set up by hand afterwards):
202     $self->addtoselected($toolname);
203 sashby 1.8
204     # Check to see if this tool is a compiler. If so, store it.
205     # Also store the language that this compiler supprots, and a
206     # compiler name (e.g. gcc323) which, in conjunction with a stem
207     # architecture name like slc3_ia32_, can be used to build a complete arch string:
208     if ($store->scram_compiler() == 1)
209     {
210     my @supported_language = $store->flags("SCRAM_LANGUAGE_TYPE");
211     my @compilername = $store->flags("SCRAM_COMPILER_NAME");
212     $self->scram_compiler($supported_language[0],$toolname,$compilername[0]);
213     }
214    
215 sashby 1.16 # Store the ToolData object in the cache:
216 sashby 1.2 $self->storeincache($toolparser->toolname(),$store);
217     return $self;
218     }
219    
220     sub toolsetup()
221     {
222     my $self=shift;
223     my ($arealocation, $toolname, $toolversion, $toolurl) = @_;
224     my ($urlcache, $url, $filename, $tfname);
225     my $toolfile;
226 sashby 1.13 my $force = 0; # we may have to force a reparse of a tool file
227 sashby 1.6
228 sashby 1.2 $toolname =~ tr[A-Z][a-z];
229     $toolversion ||= $self->defaultversion($toolname);
230     $urlcache=URL::URLcache->new($arealocation."/.SCRAM/cache"); # Download tool cache
231 sashby 1.6
232 sashby 1.2 # Check for the downloaded tools cache:
233     if (defined($urlcache))
234     {
235     $self->{urlhandler}=URL::URLhandler->new($urlcache);
236     }
237 sashby 1.6
238 sashby 1.2 $url = $self->toolurls()->{$toolname};
239     $filename = $self->{toolfiledir}."/".$toolname;
240    
241 sashby 1.4 # If .SCRAM/InstalledTools doesn't exist, create it:
242     if (! -d $self->{toolfiledir})
243     {
244 muzaffar 1.19.2.2 Utilities::AddDir::adddir($self->{toolfiledir});
245 sashby 1.4 }
246    
247 sashby 1.2 # First, check to see if there was a tool URL given. If so, we might need to read
248 muzaffar 1.19.2.1 # from a file: type URL:
249 sashby 1.2 if (my ($proto, $urlv) = ($toolurl =~ /(.*):(.*)/))
250     {
251 muzaffar 1.19.2.1 # See what kind of URL (file:, cvs:, svn:, .. ):
252 sashby 1.2 if ($proto eq 'file')
253     {
254 sashby 1.10 # Check to see if there is a ~ and substitute the user
255 sashby 1.13 # home directory if there is (file:~/xyz):
256     if (my ($urlpath) = ($urlv =~ m|^\~/(.*)$|))
257     {
258     $urlv = $ENV{HOME}."/".$urlpath;
259     }
260     elsif (my ($urlpath) = ($urlv =~ m|^\./(.*)$|))
261     {
262     # Relative to current directory (file:./xyz):
263     use Cwd qw(&cwd);
264     $urlv = cwd()."/".$urlpath;
265     }
266    
267 sashby 1.2 # If the tool url is a file and the file exists,
268     # copy it to .SCRAM/InstalledTools and set the
269     # filename accordingly:
270     if ( -f $urlv)
271     {
272     use File::Copy;
273     copy($urlv, $filename);
274 sashby 1.5 my $mode = 0644; chmod $mode, $filename;
275 sashby 1.2 $toolfile=$filename;
276 sashby 1.13 # Here we must account for the fact that the file tool doc may be
277     # a modified version of an existing tool in the current config. we
278     # make sure that this file is reparsed, even if there is already a
279     # ToolParser object for the tool:
280     $force = 1;
281 sashby 1.2 }
282     else
283     {
284 sashby 1.13 $::scram->scramerror("Unable to set up $toolname from URL \"$toolurl\" - $urlv does not exist!");
285 sashby 1.2 }
286     }
287     elsif ($proto eq 'cvs')
288     {
289     print "SCRAM: downloading $toolname from $urlv using protocol $proto.","\n";
290     print "[ not yet supported ]","\n";
291     exit(0);
292     }
293     elsif ($proto eq 'svn')
294     {
295     print "SCRAM: downloading $toolname from $urlv using protocol $proto.","\n";
296     print "[ not yet supported ]","\n";
297     exit(0);
298     }
299     else
300     {
301     $::scram->scramerror("Unable to download $urlv! Unknown protocol \"$proto\". Bye.");
302     }
303     }
304     else
305     {
306     # Copy the downloaded tool file to InstalledTools directory:
307     if ( ! -f $filename )
308     {
309 sashby 1.7 # If the URL is empty, the chances are that this tool was not downloaded to .SCRAM/InstalledTools.
310     # We signal an error and exit:
311 sashby 1.6 if ($url eq '')
312     {
313 sashby 1.7 $::scram->scramerror("$toolname was selected in project requirements but is not in the configuration!");
314 sashby 1.6 }
315     else
316     {
317     # Otherwise, we try to download it:
318     $self->verbose("Attempting Download of $url");
319     # Get file from download cache:
320     ($url,$filename)=$self->{urlhandler}->get($url);
321     use File::Copy;
322     $tfname=$self->{toolfiledir}."/".$toolname;
323     copy($filename, $tfname);
324     my $mode = 0644; chmod $mode, $tfname;
325     $toolfile=$tfname;
326     }
327 sashby 1.2 }
328     else
329     {
330     # File already exists in the .SCRAM/InstallTools directory:
331     $toolfile=$filename;
332     }
333     }
334    
335     # Run the core setup routine:
336 sashby 1.13 $self->coresetup($toolname, $toolversion, $toolfile,$force);
337 sashby 1.2 return $self;
338     }
339    
340     sub setupself()
341     {
342     my $self=shift;
343     my ($location)=@_;
344     # Process the file "Self" in local config directory. This is used to
345     # set all the paths/runtime settings for this project:
346 sashby 1.16 my $filename=$location."/config/Self.xml";
347    
348 sashby 1.2 if ( -f $filename )
349     {
350 muzaffar 1.19 scramlogmsg("\n",$::bold."Setting up SELF:".$::normal,"\n");
351 sashby 1.2 # Self file exists so process it:
352     $selfparser = BuildSystem::ToolParser->new();
353 muzaffar 1.18 $selfparser->filehead ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::ToolDoc" version="1.0">');
354     $selfparser->filehead ('</doc>');
355 sashby 1.2 $selfparser->parse('self','SELF',$filename);
356    
357     # Next, set up the tool:
358     $store = $selfparser->processrawtool($self->interactive());
359 muzaffar 1.19
360 sashby 1.2 # If we are in a developer area, also add RELEASETOP paths:
361     if (exists($ENV{RELEASETOP}))
362     {
363     print "\nAdding RELEASE area settings to self....OK","\n", if ($ENV{SCRAM_DEBUG});
364     $store->addreleasetoself();
365     }
366    
367     # Store the ToolData object in the cache:
368     $self->storeincache($selfparser->toolname(),$store);
369 muzaffar 1.19 scramlogmsg("\n");
370 sashby 1.2 }
371     else
372     {
373 muzaffar 1.19 scramlogdump();
374 sashby 1.2 print "\n";
375 sashby 1.16 print "SCRAM: No file config/Self.xml...nothing to do.";
376 sashby 1.2 print "\n";
377     return;
378     }
379     }
380    
381     sub defaultversion()
382     {
383     my $self = shift;
384     my ($tool) = @_;
385     # Return default versions as taken from configuration:
386     return (%{$self->defaultversions()}->{$tool});
387     }
388    
389     sub storeincache()
390     {
391     my $self=shift;
392     my ($toolname,$dataobject)=@_;
393    
394     # Store ToolData object (for a set-up tool) in cache:
395     if (ref($dataobject) eq 'BuildSystem::ToolData')
396     {
397 sashby 1.16 $self->updatetooltimestamp($dataobject, $toolname);
398 sashby 1.2 $self->{SETUP}->{$toolname} = $dataobject;
399     }
400     else
401     {
402     $::scram->scramerror("ToolManager: BuildSystem::ToolData object reference expected.")
403     }
404     }
405    
406     sub tools()
407     {
408     my $self = shift;
409     my @tools;
410    
411     map
412     {
413     if ($_ ne "self")
414     {
415     push(@tools, $_);
416     }
417     } keys %{$self->{SETUP}};
418    
419     # Return list of set-up tools:
420     return @tools;
421     }
422    
423     sub toolsdata()
424     {
425     my $self = shift;
426     my $tooldata = [];
427     my $rawsel = $self->selected();
428    
429     foreach my $tool ( sort { %{$rawsel}->{$a}
430     <=> %{$rawsel}->{$b}}
431     keys %{$rawsel} )
432     {
433     # Return tool data objects of all set-up tools, skipping the tool "self":
434     if ($_ ne "self")
435     {
436     # Keep only tools that have really been set up:
437     if (exists $self->{SETUP}->{$tool})
438     {
439     push(@tooldata,$self->{SETUP}->{$tool});
440     }
441     }
442     }
443    
444     # Return the array of tools, in order that they appear in RequirementsDoc:
445     return @tooldata;
446     }
447    
448     sub definedtool()
449     {
450     my $self=shift;
451     my ($tool)=@_;
452    
453     # Check to see if tool X is an external tool:
454     grep ($_ eq $tool, keys %{$self->{SETUP}}) ? return 1
455     : return 0;
456     }
457    
458     sub checkifsetup()
459     {
460     my $self=shift;
461     my ($tool)=@_;
462     # Return the ToolData object if the tool has been set up:
463     (exists $self->{SETUP}->{$tool}) ? return ($self->{SETUP}->{$tool})
464     : return undef;
465     }
466    
467     sub cloned_tm()
468     {
469     my $self=shift;
470     # Has this area already been cloned and brought in-line with current location:
471     @_ ? $self->{CLONED} = $_[0]
472     : $self->{CLONED};
473     }
474    
475     sub remove_tool()
476     {
477     my $self=shift;
478     my ($toolname)=@_;
479     my $tools = $self->{SETUP};
480     my $newtlist = {};
481    
482     while (my ($tool, $tooldata) = each %$tools)
483     {
484     if ($tool ne $toolname)
485     {
486     $newtlist->{$tool} = $tooldata;
487     }
488     else
489     {
490 sashby 1.10 # Is this tool a compiler?
491     if ($tooldata->scram_compiler() == 1)
492     {
493     # Also remove this from the compiler info if there happens to be an entry:
494     while (my ($langtype, $ctool) = each %{$self->{SCRAM_COMPILER}})
495     {
496     if ($toolname eq $ctool->[0])
497     {
498     delete $self->{SCRAM_COMPILER}->{$langtype};
499     print "Deleting compiler $toolname from cache.","\n";
500     }
501     }
502     }
503     else
504     {
505     print "Deleting $toolname from cache.","\n";
506     }
507 sashby 1.2 }
508     }
509    
510     $self->{SETUP} = $newtlist;
511 sashby 1.16 $self->updatetooltimestamp ("", $toolname);
512 sashby 1.2 # Now remove from the RAW tool list:
513     $self->cleanup_raw($toolname);
514     print "ToolManager: Updating tool cache.","\n";
515     $self->writecache();
516     }
517    
518     sub scram_projects()
519     {
520     my $self=shift;
521     my $scram_projects={};
522    
523     foreach my $t ($self->tools())
524     {
525     # Get the ToolData object:
526     my $td=$self->{SETUP}->{$t};
527     $scram_projects->{$t}=$td->variable_data(uc($t)."_BASE"), if ($td->scram_project());
528     }
529    
530     return $scram_projects;
531     }
532    
533 sashby 1.8 sub scram_compiler()
534     {
535     my $self=shift;
536     my ($langtype, $toolname, $compilername)=@_;
537    
538     if ($langtype)
539     {
540     # Store the compiler info according to supported
541     # language types.
542     #
543     # ---------------------- e.g C++ cxxcompiler gcc323
544     $self->{SCRAM_COMPILER}->{$langtype}=[ $toolname, $compilername ];
545     }
546     else
547     {
548     return $self->{SCRAM_COMPILER};
549     }
550     }
551    
552 sashby 1.12 sub updatetool()
553 sashby 1.11 {
554     my $self=shift;
555 sashby 1.12 my ($name, $obj) = @_;
556 sashby 1.11
557     # Replace the existing copy of the tool with the new one:
558 sashby 1.12 if (exists $self->{SETUP}->{$name})
559 sashby 1.11 {
560     # Check to make sure that we were really passed a compiler with
561     # the desired name:
562 sashby 1.12 if ($obj->toolname() eq $name)
563 sashby 1.11 {
564 sashby 1.16 $self->updatetooltimestamp ($obj, $name);
565 sashby 1.12 print "ToolManager: Updating the cached copy of ".$name."\n";
566     delete $self->{SETUP}->{$name};
567     $self->{SETUP}->{$name} = $obj;
568 sashby 1.11 $self->writecache();
569     }
570     else
571     {
572 sashby 1.12 print "WARNING: Tool name (".$name.") and tool obj name (".$obj->toolname().") don't match!","\n";
573 sashby 1.11 print " Not making any changes.","\n";
574     }
575     }
576     else
577     {
578 sashby 1.12 print "WARNING: No entry in cache for ".$name.". Not making any updates.\n";
579 sashby 1.11 }
580     }
581    
582 sashby 1.14 sub check_compatibility()
583     {
584     my $self=shift;
585     my ($itoolmgr)=@_;
586     # Get the version of the toolmanager. If the project fails to return a version
587     # string we return 0 for no compatibility (in which case, all tools will be set
588     # up in the traditional way):
589     my $itm_configversion = $itoolmgr->configversion();
590     if ($itm_configversion)
591     {
592     # The configurations won't be identical. We must compare the digits:
593     my ($numeric_version) = ($itm_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
594     my $current_configversion = $self->configversion();
595     my ($current_numeric_version) = ($current_configversion =~ /[a-zA-Z]*\_([0-9a-z]*).*?/);
596     ($current_numeric_version == $numeric_version) && return 1; # OK, compatible;
597     }
598     # Project does not define configuration version so just return:
599     return 0;
600     }
601    
602     sub configversion()
603     {
604     my $self=shift;
605     @_ ? $self->{CONFIGVERSION} = shift
606     : $self->{CONFIGVERSION};
607     }
608    
609 sashby 1.16 sub updatetooltimestamp ()
610     {
611     my $self=shift;
612     my $obj=shift;
613     my $toolname=shift;
614     my $samevalues=0;
615 muzaffar 1.18 my $stampdir = $self->{archstore}."/timestamps";
616     my $stampfile="${stampdir}/${toolname}";
617 sashby 1.16 if (exists $self->{SETUP}->{$toolname})
618     {
619     $samevalues=$self->comparetoolsdata($self->{SETUP}->{$toolname},$obj);
620     }
621 muzaffar 1.18 if ((!$samevalues) || (!-f $stampfile))
622 sashby 1.16 {
623 muzaffar 1.18 if (!-d $stampdir)
624 sashby 1.16 {
625 muzaffar 1.19.2.2 Utilities::AddDir::adddir($stampdir);
626 sashby 1.16 }
627 muzaffar 1.18 open(TIMESTAMPFILE,">$stampfile");
628 sashby 1.16 close(TIMESTAMPFILE);
629     }
630     }
631    
632     sub comparetoolsdata ()
633     {
634     my $self=shift;
635     my $data1=shift || ();
636     my $data2=shift || ();
637    
638     my $ref1=ref($data1);
639     my $ref2=ref($data2);
640    
641     if ($ref1 ne $ref2)
642     {
643     return 0;
644     }
645     elsif ($ref1 eq "CODE")
646     {
647     return 1;
648     }
649     elsif(($ref1 eq "SCALAR") || ($ref1 eq ""))
650     {
651     if ($data1 eq $data2)
652     {
653     return 1;
654     }
655     return 0;
656     }
657     elsif ($ref1 eq "ARRAY")
658     {
659     my $count = scalar(@$data1);
660     if ($count != scalar(@$data2))
661     {
662     return 0;
663     }
664     for (my $i=0; $i<$count; $i++)
665     {
666     if (! $self->comparetoolsdata($data1->[$i],$data2->[$i]))
667     {
668     return 0;
669     }
670     }
671     return 1;
672     }
673     else
674     {
675     foreach my $k (keys %{$data1})
676     {
677     if (! exists $data2->{$k})
678     {
679     return 0;
680     }
681     }
682     foreach my $k (keys %{$data2})
683     {
684     if (! exists $data1->{$k})
685     {
686     return 0;
687     }
688     }
689     foreach my $k (keys %{$data2})
690     {
691     if (! $self->comparetoolsdata($data1->{$k},$data2->{$k}))
692     {
693     return 0;
694     }
695     }
696     return 1;
697     }
698     }
699    
700 sashby 1.2 1;