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; |
56 |
|
"", $self, |
57 |
|
\&Arch_End,$self); |
58 |
|
$self->{Arch}=1; |
59 |
< |
push @{$self->{ARCHBLOCK}}, $Arch; |
59 |
> |
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
60 |
|
|
61 |
|
} |
62 |
|
|
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; |
93 |
|
$name=~tr[A-Z][a-z]; |
94 |
|
$self->{tool}->name($name); |
95 |
|
$self->{tool}->version($version); |
85 |
– |
$self->{tool}->url($file); |
96 |
|
$self->{switch}->filetoparse($file); |
97 |
+ |
$self->{toolfound}=1; |
98 |
|
$self->{switch}->parse("setup"); |
99 |
< |
return 0; |
99 |
> |
return $self->{toolfound}; |
100 |
|
} |
101 |
|
|
102 |
|
sub featuretext { |
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 { |
305 |
|
allowgroup("Toolactive",$self->{switch}->currentparsename()); |
306 |
|
$self->{ToolEnv}{'SCRAMtoolname'}=$$hashref{'name'}; |
307 |
|
$self->{ToolEnv}{'SCRAMtoolversion'}=$$hashref{'version'}; |
308 |
+ |
$self->{toolfound}=0; |
309 |
|
} |
310 |
|
else { |
311 |
|
$self->{switch}->disallowgroup("Toolactive", |
335 |
|
$self->{currentenvtext}=""; |
336 |
|
$self->{EnvContext}=$$hashref{'name'}; |
337 |
|
undef $self->{Envvalue}; |
338 |
< |
if ( exists $$hahsref{'type'} ) { |
339 |
< |
$self->{tool}->type($$hashref{'name'},$$hahsref{'type'}); |
338 |
> |
if ( exists $$hashref{'type'} ) { |
339 |
> |
$$hashref{'type'}=~tr[A-Z][a-z]; |
340 |
> |
$self->{tool}->type($$hashref{'name'},$$hashref{'type'}); |
341 |
|
} |
342 |
|
if ( exists $$hashref{'value'}) { |
343 |
|
$self->{Envvalue}=$$hashref{'value'}; |
344 |
|
} |
345 |
|
elsif ( ! $self->interactive() ) { |
346 |
< |
if ( $self->_checkdefault($hashref) ) { |
347 |
< |
$self->{Envvalue}=$$hashref{'default'}; |
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'}; |
357 |
|
} |
358 |
|
} |
359 |
|
} |
375 |
|
|
376 |
|
if ( $self->{Arch} ) { |
377 |
|
if ( ! defined $self->{EnvContext} ) { |
378 |
< |
$self->parseerror("</\$name> without an opening context"); |
378 |
> |
$self->{switch}->parseerror("</$name> without an opening context"); |
379 |
|
} |
380 |
|
# - set the help text |
381 |
|
$self->featuretext($self->{EnvContext},$self->{currentenvtext}); |
418 |
|
my $name=shift; |
419 |
|
my $hashref=shift; |
420 |
|
|
421 |
< |
$toolswitch->checktag($name, $hashref,'name'); |
421 |
> |
$self->{switch}->checktag($name, $hashref,'name'); |
422 |
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1) |
423 |
|
: ($self->{Arch}=0); |
424 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |