11 |
|
# --------- |
12 |
|
# new() : A new ToolDoc object |
13 |
|
# tool(toolobj) : set the tool object for the class |
14 |
+ |
# toolsearcher(searcher) : set the searcher for finding reference tools |
15 |
|
# setup(file,$name,$version) : setup a tool object from the specified file |
16 |
|
# return 0 for OK 1 for cancel |
17 |
|
# interactive([0|1]) : set the interactive node 0=off 1=on |
19 |
|
package BuildSystem::ToolDoc; |
20 |
|
require 5.004; |
21 |
|
use ActiveDoc::SimpleDoc; |
22 |
+ |
use Utilities::Verbose; |
23 |
+ |
@ISA=qw(Utilities::Verbose); |
24 |
|
|
25 |
|
sub new { |
26 |
|
my $class=shift; |
27 |
|
$self={}; |
28 |
|
bless $self, $class; |
29 |
+ |
$self->{cache}=shift; |
30 |
+ |
$self->{mydoctype}="BuildSystem::ToolDoc"; |
31 |
+ |
$self->{mydocversion}="1.0"; |
32 |
|
$self->init(); |
33 |
|
return $self; |
34 |
|
} |
75 |
|
$self->{tool}=shift; |
76 |
|
} |
77 |
|
|
78 |
+ |
sub toolsearcher { |
79 |
+ |
my $self=shift; |
80 |
+ |
if ( @_ ) { |
81 |
+ |
my $searcher=shift; |
82 |
+ |
if ( ! defined $searcher ) { |
83 |
+ |
$self->error("Undefined Value passed as a Searcher". |
84 |
+ |
" in ToolDoc::toolsearcher"); |
85 |
+ |
} |
86 |
+ |
$self->{toolboxsearcher}=$searcher; |
87 |
+ |
} |
88 |
+ |
return $self->{toolboxsearcher}; |
89 |
+ |
} |
90 |
+ |
|
91 |
|
sub setup { |
92 |
|
my $self=shift; |
93 |
|
my $file=shift; |
103 |
|
$self->{tool}->version($version); |
104 |
|
$self->{switch}->filetoparse($file); |
105 |
|
$self->{toolfound}=1; |
106 |
+ |
# -- check the type of document - can we parse it? |
107 |
+ |
my($doctype,$docversion)=$self->{switch}->doctype(); |
108 |
+ |
if ( ($doctype ne $self->{mydoctype}) || |
109 |
+ |
($self->{mydocversion} ne $docversion) ) { |
110 |
+ |
$self->error("Unable to Parse Document of type $doctype $docversion". |
111 |
+ |
"\n(Only ".$self->{mydoctype}." ". $self->{mydocversion}.")"); |
112 |
+ |
} |
113 |
|
$self->{switch}->parse("setup"); |
114 |
|
return $self->{toolfound}; |
115 |
|
} |
232 |
|
|
233 |
|
} |
234 |
|
|
235 |
+ |
# |
236 |
+ |
# Propgate through the searcher collecting matching tools |
237 |
+ |
# |
238 |
+ |
sub _searchtools { |
239 |
+ |
my $self=shift; |
240 |
+ |
my $tool=shift; |
241 |
+ |
|
242 |
+ |
my @tools=(); |
243 |
+ |
my $area; |
244 |
+ |
my $rtool; |
245 |
+ |
if ( defined $self->{toolboxsearcher} ) { |
246 |
+ |
my $it=$self->{toolboxsearcher}->newiterator(); |
247 |
+ |
while ( ! $it->last() ) { |
248 |
+ |
$area=$it->next(); |
249 |
+ |
if ( defined $area ) { |
250 |
+ |
$self->verbose("Searching for ".$tool->name()." ". |
251 |
+ |
$tool->version()." in ".$area->location()); |
252 |
+ |
$rtool=$area->toolbox()->gettool($tool->name(),$tool->version()); |
253 |
+ |
if ( (defined $rtool) && $rtool->equals($tool) ) { |
254 |
+ |
push @tools,$rtool; |
255 |
+ |
} |
256 |
+ |
} |
257 |
+ |
} |
258 |
+ |
} |
259 |
+ |
return @tools; |
260 |
+ |
} |
261 |
+ |
|
262 |
+ |
# search toolboxes for a nice list |
263 |
+ |
# |
264 |
+ |
sub _toolparamcopy { |
265 |
+ |
my $self=shift; |
266 |
+ |
my $tool=shift; |
267 |
+ |
my $param=shift; |
268 |
+ |
|
269 |
+ |
my $rv=0; |
270 |
+ |
my @params=(); |
271 |
+ |
$self->verbose("Check Other Projects for tool"); |
272 |
+ |
my @validtools=$self->_searchtools($tool); |
273 |
+ |
if ( ! $self->interactive() ) { |
274 |
+ |
if ( $#validtools >=0 ) { |
275 |
+ |
@params=$validtools[0]->getfeature($param); |
276 |
+ |
if ( $#params >=0 ) { |
277 |
+ |
$self->verbose("Extracting Feature $param from tool". |
278 |
+ |
" (= @params )\n"); |
279 |
+ |
#$tool->setfeature($param,@params); |
280 |
+ |
$rv=1; |
281 |
+ |
} |
282 |
+ |
} |
283 |
+ |
} |
284 |
+ |
return ($rv,@params); |
285 |
+ |
} |
286 |
+ |
|
287 |
|
# -- Tag Routines |
288 |
|
|
289 |
|
sub Client_start { |
359 |
|
$self->{Envvalue}=$$hashref{'value'}; |
360 |
|
} |
361 |
|
elsif ( ! $self->interactive() ) { |
362 |
< |
# check the environment |
363 |
< |
if ( defined $ENV{$$hashref{'name'}} ) { |
364 |
< |
$self->{Envvalue}=$ENV{$$hashref{'name'}}; |
362 |
> |
# check other installed copies of the tool |
363 |
> |
my ($rv,@params)= |
364 |
> |
$self->_toolparamcopy($self->{tool},$$hashref{'name'}); |
365 |
> |
if ( $rv && ($#params == 0)) { #dont use multivalued params! |
366 |
> |
$self->{Envvalue}=$params[0]; # single val parameter |
367 |
> |
} |
368 |
> |
elsif ( defined $ENV{$$hashref{'name'}} ) { |
369 |
> |
# check the environment |
370 |
> |
$self->{Envvalue}=$ENV{$$hashref{'name'}}; |
371 |
|
} |
372 |
|
elsif ( $self->_checkdefault($hashref) ) { |
373 |
< |
$self->{Envvalue}=$$hashref{'default'}; |
373 |
> |
$self->{Envvalue}=$$hashref{'default'}; |
374 |
|
} |
375 |
|
} |
376 |
|
} |