ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/ToolDoc.pm
Revision: 1.10
Committed: Tue Feb 19 17:43:28 2002 UTC (23 years, 2 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3
Branch point for: V0_19_4_B
Changes since 1.9: +14 -2 lines
Log Message:
Fixed couple of things: FNAL site probs with setup, general auto setup probs.

File Contents

# User Rev Content
1 williamc 1.2 #
2     # ToolDoc.pm
3     #
4     # Originally Written by Christopher Williams
5     #
6     # Description
7     # -----------
8     # SimpleDoc interface to initialise Tool objects
9     #
10     # Interface
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
18    
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 williamc 1.5 $self->{mydocversion}="1.1";
32 williamc 1.2 $self->init();
33     return $self;
34     }
35    
36     sub init {
37     my $self=shift;
38     $self->{switch}=ActiveDoc::SimpleDoc->new();
39 williamc 1.4 $self->{switch}->newparse("setupinit");
40     $self->{switch}->addtag("setupinit","Tool",\&Tool_Start, $self,
41     "", $self,
42     \&Tool_End, $self);
43     $self->{switch}->addtag("setupinit", "Architecture",
44     \&Arch_Start,$self,
45     "", $self,
46     \&Arch_End,$self);
47     $self->{switch}->addtag("setupinit","Environment",
48     \&Environment_init, $self,
49     "", $self,
50     "", $self);
51 williamc 1.5 $self->{switch}->grouptag("Tool","setupinit");
52    
53 williamc 1.2 $self->{switch}->newparse("setup");
54     $self->{switch}->addtag("setup","Tool",\&Tool_Start, $self,
55     "", $self,
56     \&Tool_End, $self);
57     $self->{switch}->addtag("setup","Lib",\&Lib, $self,
58     "", $self,
59     "", $self);
60     $self->{switch}->addtag("setup","External",\&External_Start, $self,
61     "", $self,
62     "", $self);
63     $self->{switch}->addtag("setup","Client",\&Client_start, $self,
64     "", $self,
65     \&Client_end, $self);
66     $self->{switch}->addtag("setup","Environment",
67     \&Environment_Start, $self,
68     \&Env_text, $self,
69     \&Environment_End, $self);
70 williamc 1.5 $self->{switch}->addtag("setup","Makefile",
71     \&Makefile_Start, $self,
72     \&Makefile_text, $self,
73     \&Makefile_end, $self);
74 williamc 1.2 $self->{switch}->grouptag("Tool","setup");
75     $self->{switch}->addtag("setup","Architecture",
76     \&Arch_Start,$self,
77     "", $self,
78     \&Arch_End,$self);
79     $self->{Arch}=1;
80     push @{$self->{ARCHBLOCK}}, $self->{Arch};
81    
82     }
83    
84     sub interactive {
85     my $self=shift;
86    
87     @_?$self->{interactive}=shift
88     :((defined $self->{interactive})?$self->{interactive}:0);
89     }
90    
91     sub tool {
92     my $self=shift;
93     $self->{tool}=shift;
94     }
95    
96     sub toolsearcher {
97     my $self=shift;
98 sashby 1.6
99 williamc 1.2 if ( @_ ) {
100     my $searcher=shift;
101     if ( ! defined $searcher ) {
102     $self->error("Undefined Value passed as a Searcher".
103     " in ToolDoc::toolsearcher");
104     }
105     $self->{toolboxsearcher}=$searcher;
106     }
107     return $self->{toolboxsearcher};
108     }
109    
110     sub setup {
111     my $self=shift;
112     my $file=shift;
113     my $name=shift;
114     my $version=shift;
115 williamc 1.5 my $toolbox=shift;
116 williamc 1.2
117     $self->{ToolEnv}{'SCRAMtoolname'}=$name;
118     $self->{ToolEnv}{'SCRAMtoolversion'}=$version;
119     $self->{ToolEnv}{'SCRAM_ARCH'}=$ENV{'SCRAM_ARCH'};
120    
121     $name=~tr[A-Z][a-z];
122     $self->{tool}->name($name);
123     $self->{tool}->version($version);
124     $self->{switch}->filetoparse($file);
125     $self->{toolfound}=1;
126     # -- check the type of document - can we parse it?
127     my($doctype,$docversion)=$self->{switch}->doctype();
128 williamc 1.5 if (($doctype ne $self->{mydoctype}) ||
129     (($self->{mydocversion} ne $docversion) && ($docversion ne "1.0")) ) {
130 williamc 1.2 $self->error("Unable to Parse Document of type $doctype $docversion".
131     "\n(Only ".$self->{mydoctype}." ". $self->{mydocversion}.")");
132     }
133 williamc 1.4 delete $self->{envcount};
134 williamc 1.5 $self->verbose("Pre-Parse");
135 williamc 1.4 $self->{switch}->parse("setupinit");
136 williamc 1.5 $self->{toolmakefile}=$toolbox->toolmakefile($name,$version);
137     $self->verbose("Setup Parse");
138 williamc 1.2 $self->{switch}->parse("setup");
139 williamc 1.5 undef $self->{toolmakefilefh};
140 sashby 1.7
141 williamc 1.2 return $self->{toolfound};
142     }
143    
144     sub featuretext {
145     my $self=shift;
146     my $feature=shift;
147    
148     if ( @_ ) {
149     $self->{featuretext}{$feature}=shift;
150     }
151     else {
152     return ($self->{featuretext}{$feature});
153     }
154     }
155    
156     sub _checkdefault {
157     my $self=shift;
158     my $hashref=shift;
159    
160     if ( defined $$hashref{'default'} ) { #check default
161     my $default;
162     foreach $default ( split /:/, $$hashref{'default'} ) {
163     $default=~s/\"//;
164     if ($self->_testlocation($default,
165     [ $self->{tool}->getfeature($$hashref{'type'})] )) { return 1; }
166     }
167     }
168     return 0;
169     }
170    
171 sashby 1.7 sub _testlocation
172     {
173     my $self=shift;
174     my $default=shift;
175     my $testfiles=shift;
176     my $OK='false';
177     my $file;
178 sashby 1.8 my $statusgood = $main::bold."OK".$main::normal;
179     my $statusbad = $main::bold."Not found".$main::normal;
180 sashby 1.7
181     chomp $default;
182     $default=$self->_expandvars($default);
183     $self->verbose("Testing location");
184    
185     if ( -f $default )
186     {
187     $OK="true";
188     $self->verbose("File OK");
189     }
190     else
191     {
192     my $dh=DirHandle->new();
193    
194     opendir $dh, $default or do
195     {
196 sashby 1.8 printf ("\nTrying %-s ...... >> %s <<\n",$default,$main::bold.$!.$main::normal);
197 sashby 1.7 return 0;
198     };
199    
200     ($#{$testfiles}==-1) ? $OK='false' : $OK='true';
201 sashby 1.8
202 sashby 1.7 my @files=readdir $dh;
203     undef $dh;
204    
205     foreach $file ( @$testfiles )
206     {
207     # now check that the required files are actually there
208     if ( ( $number = grep /\Q$file\L/, @files) == 0 )
209     {
210     $OK='false';
211 sashby 1.8 $status = $statusbad;
212 sashby 1.7 last;
213     }
214 sashby 1.8 $status = $statusgood;
215    
216     printf ("\t\tChecking for %-22s............ [%s]\n",$file,$status);
217 sashby 1.7 }
218     print "\n";
219     }
220    
221     if ( $OK eq 'true' )
222     {
223 sashby 1.8 printf ("Existence check for %-30s ............ [%s]\n",$default.":",$statusgood);
224 sashby 1.7 return 1;
225     }
226    
227     return 0;
228     }
229 williamc 1.2
230     sub _expandvars {
231     my $self=shift;
232     my $string=shift;
233    
234     return "" , if ( ! defined $string );
235     $string=~s{
236     \$\((\w+)\)
237     }{
238     if (defined $self->{ToolEnv}{$1}) {
239     $self->_expandvars($self->{ToolEnv}{$1});
240     } else {
241     "\$$1";
242     }
243     }egx;
244     $string=~s{
245     \$(\w+)
246     }{
247     if (defined $self->{ToolEnv}{$1}) {
248     $self->_expandvars($self->{ToolEnv}{$1});
249     } else {
250     "\$$1";
251     }
252     }egx;
253     return $string;
254     }
255    
256 williamc 1.3 sub _askusermenu {
257     my $self=shift;
258     my $querystring=shift;
259     my @items=@_;
260 sashby 1.8
261 williamc 1.3 my $path=-1;
262 williamc 1.4 my $n;
263     while ( ($path!~/^\d+$/) || ($path > ($#items+1)) || ($path < 1) ) {
264 williamc 1.3 for (my $i=0; $i<=$#items; $i++ ) {
265 williamc 1.4 $n=$i+1;
266     print $n.") ".$items[$i]."\n";
267 williamc 1.3 }
268     print "\n".$querystring;
269     $path=<STDIN>;
270     chomp $path;
271     }
272 williamc 1.4 $path--;
273 williamc 1.3 return $path;
274     }
275 williamc 1.2
276 sashby 1.8 sub _askuser
277     {
278 sashby 1.9 ###############################################################
279     # _askuser() #
280     ###############################################################
281     # modified : Mon Nov 19 15:51:01 2001 / SFA #
282     # params : #
283     # : #
284     # : #
285     # : #
286     # function : Looks for valid path to tool, either using a #
287     # : default path, or by using the lookup table. #
288     # : #
289     # : #
290     ###############################################################
291 sashby 1.8 my $self=shift;
292 sashby 1.9
293     # First, check for interactive flag. If "on", call the original
294     # version of this routine:
295     if ( $self->{interactive} )
296     {
297     my $ipath=$self->_askuseri(@_);
298     return $ipath;
299     }
300    
301 sashby 1.8 my $querystring=shift;
302     my $varname=shift;
303     my $lookupdb = $main::lookupobject;
304     my $type=$self->{tool}->type($varname);
305     my $path;
306     my $oldpath;
307     my $defaultpath = $lookupdb->lhcxxPath();
308    
309     # Print the feature info:
310     print $self->featuretext($self->{EnvContext});
311 williamc 1.2
312 sashby 1.8 # Check if tool is listed in the lookupdb:
313     if ($lookupdb->checkTool(${$self->{tool}}{name}))
314     {
315 sashby 1.9 $self->verbose(">> Tool ${$self->{tool}}{name} exists in DB...");
316 sashby 1.8 # Check if $varname is a tag that's listed in our lookup table for this tool:
317     if ($lookupdb->lookupTag(${$self->{tool}}{name},$varname))
318     {
319 sashby 1.9 $self->verbose(">> Tag $varname is defined for tool ${$self->{tool}}{name}");
320 sashby 1.8 # Get the value for this tag:
321     $path = $lookupdb->lookupTag(${$self->{tool}}{name},$varname);
322     }
323     else
324     # No known tag for this tool so try the default path:
325     {
326     $path = $defaultpath;
327     }
328     }
329     # If the defaultpath is valid then try that:
330     elsif ( -d $defaultpath)
331     {
332     $path = $defaultpath;
333     }
334     # We'll have to ask the user:
335     else
336     {
337     # Infinite loop while there isn't a valid path:
338     for (;;)
339     {
340     print "\n".$querystring." (RETURN to log as missing)\nset $varname = ";
341     $path=<STDIN>;
342     chomp $path;
343 williamc 1.4 $oldpath=$path;
344 sashby 1.8
345     if ( $path ne "" )
346     {
347     ($path)=$self->_validateparam($type,$path);
348     # If the path is not defined, print
349     # a message and repeat the prompt:
350     if ( ! defined $path )
351     {
352     print "Error : ".$oldpath." is not valid.\n";
353     next;
354     }
355     }
356     return $path;
357 williamc 1.2 }
358 sashby 1.8 }
359     return $path;
360     }
361 sashby 1.9
362    
363     sub _askuseri
364     {
365     ###############################################################
366     # _askuseri() #
367     ###############################################################
368     # modified : Mon Nov 19 15:46:36 2001 / SFA #
369     # params : #
370     # : #
371     # : #
372     # : #
373     # function : Interactive version of askuser routine. Called #
374     # : when "-i" flag set in scramcli. #
375     # : #
376     # : #
377     ###############################################################
378     my $self = shift;
379     my $querystring = shift;
380     my $varname = shift;
381    
382     my $type=$self->{tool}->type($varname);
383     my $path;
384     my $oldpath;
385    
386     print $self->featuretext($self->{EnvContext});
387    
388     for ( ;; )
389     {
390     print "\n".$querystring." (RETURN to log as missing)\nset $varname = ";
391     $path=<STDIN>;
392     chomp $path;
393     $oldpath=$path;
394    
395     if ( $path ne "" )
396     {
397     ($path)=$self->_validateparam($type,$path);
398     if ( ! defined $path )
399     {
400     print "Error : ".$oldpath." is not valid.\n";
401     next;
402     }
403     }
404     return $path;
405     }
406     }
407    
408 williamc 1.2
409 williamc 1.4 sub _validateparam {
410     my $self=shift;
411     my $type=shift;
412     my @params=@_;
413    
414     my @newparams=();
415     foreach $param ( @params ) {
416     if ( defined $self->{'client'}) { # must be a location
417     if ( $self->_testlocation($param ,
418     [ $self->{tool}->getfeature($type)] )) {
419     $self->verbose("$param passed validation");
420     push @newparams,$param;
421     }
422     else {
423     $self->verbose("$param failed validation");
424     }
425     }
426     else {
427     # --- no other tests to pass so it must be OK
428     push @newparams,$param;
429     }
430     }
431     return @newparams;
432     }
433    
434 williamc 1.2 #
435     # Propgate through the searcher collecting matching tools
436     #
437     sub _searchtools {
438     my $self=shift;
439     my $tool=shift;
440 williamc 1.4 my $searcher=shift;
441 williamc 1.2
442     my @tools=();
443     my $area;
444     my $rtool;
445 williamc 1.4 my $it=$searcher->newiterator();
446 sashby 1.6
447 williamc 1.4 while ( ! $it->last() ) {
448 williamc 1.2 $area=$it->next();
449     if ( defined $area ) {
450     $self->verbose("Searching for ".$tool->name()." ".
451     $tool->version()." in ".$area->location());
452     $rtool=$area->toolbox()->gettool($tool->name(),$tool->version());
453 williamc 1.3 if ( defined $rtool ) {
454     if ( $rtool->equals($tool) ) {
455     $self->verbose("Found matching tool");
456 williamc 1.2 push @tools,$rtool;
457 williamc 1.3 }
458     else {
459     $self->verbose("Rejected tool ".$rtool->name()." "
460     .$rtool->version());
461     }
462 williamc 1.2 }
463 williamc 1.4 else {
464     $self->verbose("Tool Passed as Undefined");
465     }
466 williamc 1.2 }
467 williamc 1.3 else {
468     $self->verbose("Area passed is not defined");
469     }
470 williamc 1.2 }
471     return @tools;
472     }
473    
474     # search toolboxes for a nice list
475     #
476     sub _toolparamcopy {
477     my $self=shift;
478     my $tool=shift;
479     my $param=shift;
480    
481     my $rv=0;
482     my @params=();
483 sashby 1.10
484 williamc 1.2 $self->verbose("Check Other Projects for tool");
485 williamc 1.4 my @validtools=();
486     if ( defined $self->{toolboxsearcher} ) {
487     @validtools=$self->_searchtools($tool,$self->{toolboxsearcher});
488     }
489     if ( $#validtools >=0 ) {
490     if ( ! $self->interactive() ) {
491 williamc 1.2 @params=$validtools[0]->getfeature($param);
492     if ( $#params >=0 ) {
493     $self->verbose("Extracting Feature $param from tool".
494     " (= @params )\n");
495     $rv=1;
496     }
497     }
498     }
499     return ($rv,@params);
500     }
501    
502 williamc 1.4 sub _getparamsets {
503     my $self=shift;
504     my $tool=shift;
505     my $param=shift;
506    
507     my @paramlist=();
508     my @params=();
509 sashby 1.10
510     # Check for an override of the searcher. If the
511     # variable SEARCHOVRD is set, we return an empty array:
512     if ( $ENV{'SEARCHOVRD'} eq 'true' )
513     {
514     $self->verbose("Searching for tool settings from other projects OVERRIDDEN");
515     # This bypasses the menu option presented to the user when there is more than one
516     # choice for the tool location:
517     return @paramlist;
518     }
519     # Otherwise we proceed as normal:
520 williamc 1.4 $self->verbose("Searching for parameter settings in other tools");
521     my @validtools=();
522     if ( defined $self->{toolboxsearcher} ) {
523 sashby 1.10 @validtools=$self->_searchtools($tool,$self->{toolboxsearcher});
524     }
525 williamc 1.4 else {
526     $self->verbose("No tool searcher available");
527     }
528     if ( $#validtools >=0 ) {
529     foreach $t ( @validtools ) {
530     @params=$t->getfeature($param);
531     if ( $#params >=0 ) {
532     push @paramlist, [ @params ];
533     $self->verbose("Found @params");
534     }
535     }
536     }
537     return @paramlist;
538     }
539    
540 williamc 1.2 # -- Tag Routines
541    
542     sub Client_start {
543     my $self=shift;
544     my $name=shift;
545     my $hashref=shift;
546    
547     if ( $self->{Arch} ) {
548     $self->{'client'}=1;
549     }
550     }
551    
552     sub Client_end {
553     my $self=shift;
554     if ( $self->{Arch} ) {
555     undef $self->{'client'};
556     }
557     }
558    
559     sub Tool_Start {
560     my $self=shift;
561     my $name=shift;
562     my $hashref=shift;
563    
564     $self->{switch}->checktag($name, $hashref, 'name');
565     $self->{switch}->checktag($name, $hashref, 'version');
566     $self->{switch}->opengroup("Toolactive");
567    
568     # lower case the name
569     $$hashref{'name'}=~tr[A-Z][a-z];
570     # make sure we only pick up the tool requested
571     if ( ( $self->{tool}->name() eq $$hashref{'name'} ) &&
572     ($self->{tool}->version() eq $$hashref{'version'})) {
573     $self->{switch}->
574     allowgroup("Toolactive",$self->{switch}->currentparsename());
575     $self->{ToolEnv}{'SCRAMtoolname'}=$$hashref{'name'};
576     $self->{ToolEnv}{'SCRAMtoolversion'}=$$hashref{'version'};
577     $self->{toolfound}=0;
578     }
579     else {
580     $self->{switch}->disallowgroup("Toolactive",
581     $self->{switch}->currentparsename());
582     }
583     }
584    
585     sub Tool_End {
586     my $self=shift;
587     my $name=shift;
588     my $hashref=shift;
589    
590     $self->{switch}->closegroup("Toolactive");
591 williamc 1.5 }
592    
593     sub Makefile_Start {
594     my $self=shift;
595     my $name=shift;
596     my $hashref=shift;
597    
598     if ( $self->{Arch} ) {
599     if ( ! defined $self->{toolmakefilefh} ) {
600     $self->{toolmakefilefh}=FileHandle->new();
601     $self->{toolmakefilefh}->open(">".$self->{toolmakefile});
602     }
603     }
604     }
605    
606     sub Makefile_text {
607     my $self=shift;
608     my $name=shift;
609     my $string=shift;
610    
611     if ( $self->{Arch} ) {
612     print {$self->{toolmakefilefh}} $string;
613     }
614     }
615    
616     sub Makefile_end {
617     my $self=shift;
618     my $name=shift;
619     my $hashref=shift;
620    
621     if ( $self->{Arch} ) {
622     print {$self->{toolmakefilefh}} "\n";
623     }
624 williamc 1.2 }
625    
626 williamc 1.4 # -- collect number of variables of the same name - need to know how many
627     # before main setup processing
628     sub Environment_init {
629     my $self=shift;
630     my $name=shift;
631     my $hashref=shift;
632    
633     $self->{switch}->checktag($name, $hashref, 'name');
634     if ( $self->{Arch} ) {
635     if ( exists $self->{envcount}{$$hashref{'name'}} ) {
636     $self->{envcount}{$$hashref{'name'}}++;
637     }
638     else {
639     $self->{envcount}{$$hashref{'name'}}=0;
640     }
641     }
642     }
643    
644 sashby 1.8 sub Environment_Start
645     {
646     my $self=shift;
647     my $name=shift;
648     my $hashref=shift;
649 sashby 1.6
650 sashby 1.8 $self->{switch}->checktag($name, $hashref, 'name');
651    
652     if ( $self->{Arch} )
653     {
654     my $val=undef;
655     if ( defined $self->{EnvContext} )
656     {
657     $self->parserror(" Attempted to open new <$name> context".
658     " without closing the previous one");
659     }
660     # -- keep a counter of the number of times we see this variable
661     if ( exists $self->{EnvironmentCount}{$$hashref{'name'}} )
662     {
663     $self->{EnvironmentCount}{$$hashref{'name'}}++;
664     }
665     else
666     {
667     $self->{EnvironmentCount}{$$hashref{'name'}}=0;
668     }
669    
670     $self->{currentenvtext}="";
671     $self->{EnvContext}=$$hashref{'name'};
672     undef $self->{Envvalue};
673 williamc 1.4
674 sashby 1.8 if ( exists $$hashref{'type'} )
675     {
676     $$hashref{'type'}=~tr[A-Z][a-z];
677     $self->{tool}->type($$hashref{'name'},$$hashref{'type'});
678     }
679     # check other installed copies of the tool
680     # -- construct a menu of options
681     my @menulist=();
682     # -- a value is fixed - unless interactive switch is on
683     if ( exists $$hashref{'value'})
684     {
685     $val=$$hashref{'value'};
686     if ( $self->interactive() )
687     {
688     unshift @menulist,$$hashref{'value'};
689     }
690     }
691     # -- add any default values to the selection
692     if ( ! defined $val )
693     {
694     if ( $self->_checkdefault($hashref) )
695     {
696     my $var=$self->_expandvars($$hashref{'default'});
697     if ( !grep { $_ eq $var } @menulist )
698     {
699     unshift @menulist, $var;
700     }
701     }
702     # -- check the environment
703     if ( defined $ENV{$$hashref{'name'}} )
704     {
705     if ( !grep { $_ eq $ENV{$$hashref{'name'}}} @menulist )
706     {
707     unshift @menulist, $ENV{$$hashref{'name'}};
708     }
709     }
710     my @paramlist=$self->_getparamsets($self->{tool},
711     $$hashref{'name'});
712     foreach $p ( @paramlist )
713     {
714     # -- only add them if there are the same number of variables
715     if ( $#{$p} == $self->{envcount}{$$hashref{'name'}} )
716     {
717     if ( !grep {$_ eq $$p[$self->{EnvironmentCount}
718     {$$hashref{'name'}}] } @menulist)
719     {
720     push @menulist,$$p[$self->{EnvironmentCount}
721     {$$hashref{'name'}}];
722     }
723     }
724     else
725     {
726     $self->verbose("Ignoring tool params - not the same number".
727     " defined (".$#{$p}." != ".
728     $self->{envcount}{$$hashref{'name'}}.")");
729     }
730 williamc 1.4 }
731 sashby 1.8 if ( $#menulist >=0 )
732     {
733 sashby 1.7 print "Validating Values for Variable: ".$$hashref{'name'}."\n";
734 williamc 1.4 @menulist=$self->_validateparam($$hashref{'type'},@menulist);
735 sashby 1.8 }
736     print "\n";
737     # -- If theres only one option take it without asking
738     if ( $#menulist == 0 && ( ! $self->interactive() ))
739     {
740     $val=$menulist[0];
741     }
742     elsif ( $#menulist > 0 )
743     {
744     my $in=$self->_askusermenu(
745     "Multiple possibilities found for ".
746     $$hashref{'name'}." ( occurrance ".
747     ($self->{EnvironmentCount}{$$hashref{'name'}}+1)." ) ".
748     "\nPlease Choose: ",
749     (@menulist,"Other"));
750     if ( $in <=$#menulist )
751     {
752     $val=$menulist[$in];
753     }
754     else
755     {
756     undef $val;
757     }
758     }
759     }
760     $self->{Envvalue}=$val; # single val parameter
761     }
762     }
763 williamc 1.2
764     sub Env_text {
765     my $self=shift;
766     my $name=shift;
767     my $string=shift;
768    
769     if ( $self->{Arch} ) {
770     $self->{currentenvtext}=$self->{currentenvtext}.$string;
771     }
772     }
773    
774 sashby 1.8 sub Environment_End
775     {
776     my $self=shift;
777     my $name=shift;
778    
779     if ( $self->{Arch} )
780     {
781     if ( ! defined $self->{EnvContext} )
782     {
783     $self->{switch}->parseerror("</$name> without an opening context");
784     }
785     # - set the help text
786     $self->featuretext($self->{EnvContext},$self->{currentenvtext});
787    
788     if ( ! defined $self->{Envvalue} )
789     {
790     $self->{Envvalue}=$self->_askuser("Please Enter the Value Below:",
791     $self->{EnvContext});
792     }
793    
794     $self->{Envvalue}=$self->_expandvars($self->{Envvalue});
795     $self->{tool}->addfeature($self->{EnvContext}, $self->{Envvalue});
796     $self->{ToolEnv}{$self->{EnvContext}}=$self->{Envvalue};
797    
798     # Undefine in time for next pass:
799     undef $self->{EnvContext};
800     undef $self->{Envvalue};
801     }
802     }
803 williamc 1.2
804     sub Lib {
805     my $self=shift;
806     my $name=shift;
807     my $hashref=shift;
808    
809     $self->{switch}->checktag($name, $hashref, 'name');
810     if ( $self->{Arch} ) {
811     $self->{tool}->addfeature("lib",$$hashref{'name'});
812     }
813     }
814    
815     sub External_Start {
816     my $self=shift;
817     my $name=shift;
818     my $hashref=shift;
819    
820     $self->{switch}->checktag($name, $hashref,'ref');
821     if ( $self->{Arch} ) {
822     $self->{tool}->addfeature("_externals",$$hashref{'ref'});
823     }
824     }
825    
826     sub Arch_Start {
827     my $self=shift;
828     my $name=shift;
829     my $hashref=shift;
830    
831     $self->{switch}->checktag($name, $hashref,'name');
832     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
833     : ($self->{Arch}=0);
834     push @{$self->{ARCHBLOCK}}, $self->{Arch};
835     }
836    
837     sub Arch_End {
838     my $self=shift;
839     my $name=shift;
840    
841     pop @{$self->{ARCHBLOCK}};
842     $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
843     }