ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildSystem/Requirements.pm (file contents):
Revision 1.3 by williamc, Tue Nov 28 16:12:21 2000 UTC vs.
Revision 1.15 by sashby, Tue Oct 15 15:56:21 2002 UTC

# Line 47 | Line 47 | sub url {
47          return $self->{file}
48   }
49  
50 < sub setup {
51 <        my $self=shift;
52 <        my $toolbox=shift;
53 <
54 <        my $tool;
55 <        foreach $tool ( $self->selectedtools() ) {
56 <          $self->verbose("Setting Up Tool $tool");
57 <          $toolbox->toolsetup($tool, $self->version($tool), $self->toolurl($tool));
58 <        }
59 < }
50 > sub setup
51 >   {
52 >   my $self=shift;
53 >   my $toolbox=shift;
54 >   my $tool;
55 >
56 >   foreach $tool ( $self->selectedtools() )
57 >      {
58 >      $self->verbose("Setting Up Tool $tool");
59 >      $toolbox->toolsetup($tool, $self->version($tool), $self->toolurl($tool));
60 >      }
61 >   }
62  
63   sub tools {
64          my $self=shift;
65          return @{$self->{tools}};
66   }
67  
68 < sub selectedtools {
69 <        my $self=shift;
70 <        my @toollist=();
71 <        foreach $tool (  @{$self->{tools}} ) {
72 <          if ( $self->{selected}{$tool} == 1 ) {
73 <                push @toollist, $tool;
74 <          }
75 <        }
76 <        return @toollist;
77 < }
68 >
69 > sub selectedtools
70 >   {
71 >   ###############################################################
72 >   # selectedtools()                                             #
73 >   ###############################################################
74 >   # modified : Wed Dec  5 15:39:39 2001 / SFA                   #
75 >   # params   :                                                  #
76 >   #          :                                                  #
77 >   #          :                                                  #
78 >   #          :                                                  #
79 >   # function : New version of routine. Return a list of tools   #
80 >   #          : that were selected after parsing RequirementsDoc #
81 >   #          :                                                  #
82 >   #          :                                                  #
83 >   ###############################################################
84 >   my $self=shift;
85 >   my @toolarray = ();
86 >  
87 >   # Grab the arrays of tools:
88 >   my ($toolref,$deseltoolref,$unseltoolref) = $self->grabtools();
89 >  
90 >   my @tools = @{$toolref};
91 >   my @deseltools = @{$deseltoolref};
92 >   my @unseltools = @{$unseltoolref};
93 >  
94 >   if ($#tools == -1)
95 >      {
96 >      $self->verbose(">> No tools SELECTED. Checking for DESELECTED tools");
97 >      
98 >      # No tools "SELECTED". We return the tools that were "UNSELECTED"
99 >      # (these are the tools that remain after unwanted tools are deselected):
100 >      if ($#unseltools != -1)
101 >         {
102 >         $self->verbose(">> Using the tools remaining after DESELECTION ops");
103 >         # The array has elements:
104 >         return @unseltools;
105 >         }
106 >      else
107 >         {
108 >         $self->verbose(">> No UNSELECTED tools.....");
109 >         }
110 >      }
111 >   else
112 >      {
113 >      # We will return the selected tools but only after checking
114 >      # for subsequently deselected tools (unlikely but...):
115 >      foreach $selected (@tools)
116 >         {
117 >         # If the tool exists in the deselected tool array, pass.
118 >         if ( ! grep /$selected/, @deseltools)
119 >            {
120 >            push @toolarray, $selected;  
121 >            }
122 >         else
123 >            {
124 >            $self->verbose(">> Tool $selected was subsequently deselected.");
125 >            }
126 >         }
127 >      }
128 >   return @toolarray;
129 >   }
130 >
131 >
132 > sub grabtools
133 >   {
134 >   ###############################################################
135 >   # grabtools()                                                 #
136 >   ###############################################################
137 >   # modified : Wed Dec  5 14:41:56 2001 / SFA                   #
138 >   # params   :                                                  #
139 >   #          :                                                  #
140 >   #          :                                                  #
141 >   #          :                                                  #
142 >   # function : Loop over the tools read from RequirementsDoc    #
143 >   #          : and fill arrays for selected, deselected and     #
144 >   #          : unselected tools.                                #
145 >   #          :                                                  #
146 >   ###############################################################
147 >   my $self=shift;
148 >   my @toollist=();
149 >   my @deseltoollist=();
150 >   my @unseltoollist=();
151 >  
152 >   foreach $tool (  @{$self->{tools}} )
153 >      {
154 >      if ( $self->{selected}{$tool} eq "SELECTED" )
155 >         {
156 >         push @toollist, $tool;
157 >         }
158 >      elsif ( $self->{selected}{$tool} eq "DESELECTED" )
159 >         {
160 >         push @deseltoollist, $tool;
161 >         }
162 >      elsif ( $self->{selected}{$tool} eq "UNSELECTED" )
163 >         {
164 >         push @unseltoollist, $tool;
165 >         }
166 >      else
167 >         {
168 >         $self->verbose(">> Looks like an unknown sel flag for tool ".$tool." ");
169 >         }
170 >      }
171 >   return \(@toollist, @deseltoollist, @unseltoollist);
172 >   }
173 >
174  
175   sub toolcomment {
176          my $self=shift;
# Line 156 | Line 254 | sub init {
254          }
255          else {
256            $self->verbose("wrong doc type - not parsing");
159          #print "wrong doc version - not parsing\n";
257          }
258   }
259  
260   sub arch {
261          my $self=shift;
262 +        # $self->arch is the SCRAM_ARCH value:
263          if ( @_ ) {
264            $self->{arch}=shift
265          }
# Line 191 | Line 289 | sub getreqforarch {
289   }
290  
291  
292 < sub download {
293 <        my $self=shift;
294 <
295 <        my $tool;
296 <        foreach $tool ( $self->tools() ) {
297 <          $self->verbose("Downloading ".$self->toolurl($tool));
298 <          # get into the cache
299 <          $self->{switch}->urlget($self->toolurl($tool));
300 <        }
301 < }
292 > sub download
293 >   {
294 >   my $self=shift;
295 >   my $tool;
296 >   $| = 1; # Unbuffer the output
297 >
298 >   print  "Downloading tool descriptions....","\n";
299 >   print  " ";
300 >   foreach $tool ( $self->tools() )
301 >      {
302 >      print "#";
303 >      $self->verbose("Downloading ".$self->toolurl($tool));
304 >      # get into the cache
305 >      $self->{switch}->urlget($self->toolurl($tool));
306 >      }
307 >   print "\nDone.","\n","\n";
308 >   }
309  
310   sub _autoselect {
311          my $self=shift;
# Line 230 | Line 335 | sub Restrict_start {
335   sub Restrict_end {
336          my $self=shift;
337          my $name=shift;
338 <
338 >        
339          if ( $self->{Arch} ) {
340          if ( $#{$self->{restrictstack}} >= 0 ) {
341            $self->_autoselect(pop @{$self->{restrictstack}});
# Line 249 | Line 354 | sub require_start {
354          $self->{switch}->checktag( $name, $hashref, 'version');
355          $self->{switch}->checktag( $name, $hashref, 'name');
356          $self->{switch}->checktag( $name, $hashref, 'url');
357 <
357 >        
358          if ( $self->{reqcontext} == 1 ) {
359            $self->{switch}->parseerror(
360 <                "Open new $name conext without previous </$name>");
360 >                "Open new $name context without previous </$name>");
361          }
362          $self->{reqcontext}=1;
363          $$hashref{'name'}=~tr[A-Z][a-z];
364 +
365 +        # Add tool to the tool array:
366          push @{$self->{tools}}, $$hashref{'name'};
367 +        # Also add its' version:
368          $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
369 +
370          # -- make sure the full url is taken
371          my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
372          $self->{url}{$$hashref{'name'}}=$urlobj->url();
373  
374 <        # -- selection
375 <        if ( $self->{Arch} ) {
376 <          if ( $self->_autoselect() ) {
377 <             $self->{selected}{$$hashref{'name'}}=1;
378 <          }
379 <          else {
380 <             $self->{selected}{$$hashref{'name'}}=0;
381 <          }
382 <        }
374 >        # Disable the auto select mechanism. Now, we start with
375 >        # all tools having a flag "UNSELECTED". Then we choose
376 >        # which we wish to select:
377 >        if ( $self->{Arch} )
378 >           {
379 >            $self->{selected}{$$hashref{'name'}}="UNSELECTED";
380 >           }
381 >        # Output the tool name here with the value
382 >        # of its' select flag:
383 >        $self->verbose(">> Tool name: ".$$hashref{'name'}." sel/desel flag value: ".
384 >                       $self->{selected}{$$hashref{'name'}} ." ");
385 >
386          $self->{creqtool}=$$hashref{'name'};
387          $self->{creqversion}=$$hashref{'version'};
388          $self->{reqtext}{$self->{creqtool}}{$self->{creqversion}}="";
# Line 300 | Line 412 | sub require_end {
412          }
413   }
414  
415 < sub select_start {
416 <        my $self=shift;
417 <        my $name=shift;
418 <        my $hashref=shift;
419 <
420 <        $self->{switch}->checktag( $name, $hashref, 'name');
421 <        $$hashref{'name'}=~tr[A-Z][a-z];
422 <        if ( $self->{Arch} ) {
423 <           $self->verbose("Selecting ".$$hashref{'name'});
424 <           $self->{selected}{$$hashref{'name'}}=1;
425 <        }
426 < }
427 <
428 < sub deselect_start {
429 <        my $self=shift;
430 <        my $name=shift;
431 <        my $hashref=shift;
432 <
433 <        $self->{switch}->checktag( $name, $hashref, 'name');
434 <        $$hashref{'name'}=~tr[A-Z][a-z];
435 <        if ( $self->{Arch} ) {
436 <           $self->verbose("Deselecting ".$$hashref{'name'});
437 <           $self->{selected}{$$hashref{'name'}}=0;
438 <        }
439 < }
440 <
441 < sub Arch_Start {
442 <        my $self=shift;
443 <        my $name=shift;
444 <        my $hashref=shift;
445 <
446 <        $self->{switch}->checktag($name, $hashref,'name');
447 <        
448 <        ( ($self->arch()=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
449 <                                                : ($self->{Arch}=0);
450 <        $self->verbose(($self->{Arch}?"OK":"skipping")." ".$$hashref{name});
451 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
452 <        push @{$self->{ArchStack}}, $$hashref{'name'};
453 < }
415 > sub select_start
416 >   {
417 >   my $self=shift;
418 >   my $name=shift;
419 >   my $hashref=shift;
420 >
421 >   $self->{switch}->checktag( $name, $hashref, 'name');
422 >   $$hashref{'name'}=~tr[A-Z][a-z];
423 >   if ( $self->{Arch} )
424 >      {
425 >      $self->verbose("Selecting ".$$hashref{'name'});
426 >      $self->{selected}{$$hashref{'name'}} = "SELECTED";
427 >      $self->verbose(">> Tool select flag = ".$self->{selected}{$$hashref{'name'}}."\n");
428 >      }
429 >   }
430 >
431 > sub deselect_start
432 >   {
433 >   my $self=shift;
434 >   my $name=shift;
435 >   my $hashref=shift;
436 >  
437 >   $self->{switch}->checktag( $name, $hashref, 'name');
438 >   $$hashref{'name'}=~tr[A-Z][a-z];
439 >   if ( $self->{Arch} )
440 >      {
441 >      $self->verbose("Deselecting ".$$hashref{'name'});
442 >      $self->{selected}{$$hashref{'name'}} = "DESELECTED";
443 >      $self->verbose(">> Tool select flag = ".$self->{selected}{$$hashref{'name'}}."\n");
444 >      }
445 >   }
446 >
447 > sub Arch_Start
448 >   {
449 >   my $self=shift;
450 >   my $name=shift;
451 >   my $hashref=shift;
452 >   # Check the architecture tag:
453 >   $self->{switch}->checktag($name, $hashref,'name');
454 >   # Look for a match between the architecture flag read
455 >   # from the RequirementsDoc ($$hashref{name}) and scram arch:
456 >   #if ($self->arch() =~ /$$hashref{name}.*/)
457 >   #   {
458 >      
459 >    #  }
460 >   #elsif ($self->arch() =~ /$$hashref{name}/)
461 >   #   {
462 >   #   }
463 >   #else
464 >   #   {
465 >   #   }
466 >   ( ($self->arch()=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
467 >      : ($self->{Arch}=0);
468 > #   ( ($self->arch()=~/$$hashref{name}[BLAH]/) )? ($self->{Arch}=1)
469 > #      : ($self->{Arch}=0);
470 >
471 >  
472 >   $self->verbose(($self->{Arch}?"OK":"skipping")." ".$$hashref{name});
473 >   push @{$self->{ARCHBLOCK}}, $self->{Arch};
474 >   push @{$self->{ArchStack}}, $$hashref{'name'};
475 >   }
476  
477   sub Arch_End {
478          my $self=shift;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines