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; |
72 |
|
$self->{tool}=shift; |
73 |
|
} |
74 |
|
|
75 |
+ |
sub toolsearcher { |
76 |
+ |
my $self=shift; |
77 |
+ |
if ( @_ ) { |
78 |
+ |
$self->{toolboxsearcher}=shift; |
79 |
+ |
} |
80 |
+ |
return $self->{toolboxsearcher}; |
81 |
+ |
} |
82 |
+ |
|
83 |
|
sub setup { |
84 |
|
my $self=shift; |
85 |
|
my $file=shift; |
217 |
|
|
218 |
|
} |
219 |
|
|
220 |
+ |
# |
221 |
+ |
# Propgate through the searcher collecting matching tools |
222 |
+ |
# |
223 |
+ |
sub _searchtools { |
224 |
+ |
my $self=shift; |
225 |
+ |
my $tool=shift; |
226 |
+ |
|
227 |
+ |
my @tools=(); |
228 |
+ |
my $area; |
229 |
+ |
my $rtool; |
230 |
+ |
if ( defined $self->{toolboxsearcher} ) { |
231 |
+ |
my $it=$self->{toolboxsearcher}->newiterator(); |
232 |
+ |
while ( ! $it->last() ) { |
233 |
+ |
$area=$it->next(); |
234 |
+ |
if ( defined $area ) { |
235 |
+ |
$self->verbose("Searching for ".$tool->name()." ". |
236 |
+ |
$tool->version()." in ".$area->location()); |
237 |
+ |
$rtool=$area->toolbox()->gettool($tool->name(),$tool->version()); |
238 |
+ |
if ( (defined $rtool) && $rtool->equals($tool) ) { |
239 |
+ |
push @tools,$rtool; |
240 |
+ |
} |
241 |
+ |
} |
242 |
+ |
} |
243 |
+ |
} |
244 |
+ |
return @tools; |
245 |
+ |
} |
246 |
+ |
|
247 |
+ |
# search toolboxes for a nice list |
248 |
+ |
# |
249 |
+ |
sub _toolparamcopy { |
250 |
+ |
my $self=shift; |
251 |
+ |
my $tool=shift; |
252 |
+ |
my $param=shift; |
253 |
+ |
|
254 |
+ |
my $rv=0; |
255 |
+ |
$self->verbose("Check Other Projects for tool"); |
256 |
+ |
my @validtools=$self->_searchtools($tool); |
257 |
+ |
if ( ! $self->interactive() ) { |
258 |
+ |
if ( $#validtools >=0 ) { |
259 |
+ |
my @params=$validtools[0]->getfeature($param); |
260 |
+ |
if ( $#params >=0 ) { |
261 |
+ |
$self->verbose("Extracting Feature $param from tool". |
262 |
+ |
" (= @params )\n"); |
263 |
+ |
$tool->setfeature($param,@params); |
264 |
+ |
$rv=1; |
265 |
+ |
} |
266 |
+ |
} |
267 |
+ |
} |
268 |
+ |
return $rv; |
269 |
+ |
} |
270 |
+ |
|
271 |
|
# -- Tag Routines |
272 |
|
|
273 |
|
sub Client_start { |
343 |
|
$self->{Envvalue}=$$hashref{'value'}; |
344 |
|
} |
345 |
|
elsif ( ! $self->interactive() ) { |
346 |
< |
# check the environment |
347 |
< |
if ( defined $ENV{$$hashref{'name'}} ) { |
348 |
< |
$self->{Envvalue}=$ENV{$$hashref{'name'}}; |
346 |
> |
# check other installed copies of the tool |
347 |
> |
if ( $self->_toolparamcopy($self->{tool},$$hashref{'name'}) ) { |
348 |
> |
my @tmp=$self->{tool}->getfeature($$hashref{'name'}); |
349 |
> |
$self->{Envvalue}=$tmp[0]; # assume single val parameter! |
350 |
> |
} |
351 |
> |
elsif ( defined $ENV{$$hashref{'name'}} ) { |
352 |
> |
# check the environment |
353 |
> |
$self->{Envvalue}=$ENV{$$hashref{'name'}}; |
354 |
|
} |
355 |
|
elsif ( $self->_checkdefault($hashref) ) { |
356 |
< |
$self->{Envvalue}=$$hashref{'default'}; |
356 |
> |
$self->{Envvalue}=$$hashref{'default'}; |
357 |
|
} |
358 |
|
} |
359 |
|
} |