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.1.2.4.2.6 by williamc, Mon Aug 21 18:41:03 2000 UTC vs.
Revision 1.1.2.4.2.7 by williamc, Tue Aug 22 14:35:09 2000 UTC

# Line 5 | Line 5
5   # new(url,URLcache,ObjectStore)     : new requirements doc
6   # setup(toolbox): set up the requirements into the specified toolbox object
7   # download(toolbox)    : download description files (into toolbox cache)
8 < # tools()       : Return list of requirements (ordered)
8 > # tools()       : Return list of ALL requirements (ordered)
9 > # selectedtools() : Return list of only those tools selected
10   # version(tool) : return the version of a given tool
11   # url(tool)     : return the url of a given tool
12  
# Line 35 | Line 36 | sub setup {
36          my $toolbox=shift;
37  
38          my $tool;
39 <        foreach $tool ( $self->tools() ) {
39 >        foreach $tool ( $self->selectedtools() ) {
40            $self->verbose("Setting Up Tool $tool");
41            $toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
42          }
# Line 46 | Line 47 | sub tools {
47          return @{$self->{tools}};
48   }
49  
50 + sub selectedtools {
51 +        my $self=shift;
52 +        my @toollist=();
53 +        foreach $tool (  @{$self->{tools}} ) {
54 +          if ( $self->{selected}{$tool} == 1 ) {
55 +                push @toollist, $tool;
56 +          }
57 +        }
58 +        return @toollist;
59 + }
60 +
61   sub version {
62          my $self=shift;
63          my $tool=shift;
# Line 71 | Line 83 | sub init {
83                                          \&Arch_Start,$self,
84                                          "", $self,
85                                          \&Arch_End, $self);
86 +        $switch->addtag("ordering","Restrict",
87 +                                        \&Restrict_start,$self,
88 +                                        "", $self,
89 +                                        \&Restrict_end, $self);
90 +        $switch->addtag("ordering","deselect",
91 +                                        \&deselect_start,$self,
92 +                                        "", $self,
93 +                                        "", $self);
94 +        $switch->addtag("ordering","select",
95 +                                        \&select_start,$self,
96 +                                        "", $self,
97 +                                        "", $self);
98          $switch->grouptag("Architecture","ordering");
99          $switch->addtag("ordering","require",
100                                          \&require_start,$self,
101                                          "", $self,
102 <                                        "", $self);
102 >                                        \&require_end, $self);
103  
104 +        $self->{reqcontext}=0;
105          $self->{switch}=$switch;
106 +        undef $self->{restrictstack};
107          @{$self->{tools}}=();
108          
109          my($doctype,$docversion)=$switch->doctype();
# Line 104 | Line 130 | sub download {
130          }
131   }
132  
133 + sub _autoselect {
134 +        my $self=shift;
135 +        if ( @_ ) {
136 +          $self->{autoselect}=shift;
137 +        }
138 +        # -- default is true
139 +        return ((defined $self->{autoselect})?$self->{autoselect}:1);
140 + }
141 +
142   # ---- Tag routines
143  
144 + sub Restrict_start {
145 +        my $self=shift;
146 +        my $name=shift;
147 +        my $hashref=shift;
148 +
149 +        $self->{switch}->checktag( $name, $hashref, 'autoselect');
150 +        if ( $self->{Arch} ) {
151 +        # -- create selection state stack
152 +        push @{$self->{restrictstack}}, $self->_autoselect();
153 +        $self->_autoselect(
154 +                (($$hashref{'autoselect'}=~/true/i)?1:0));
155 +        }
156 + }
157 +
158 + sub Restrict_end {
159 +        my $self=shift;
160 +        my $name=shift;
161 +
162 +        if ( $self->{Arch} ) {
163 +        if ( $#{$self->{restrictstack}} >= 0 ) {
164 +          $self->_autoselect(pop @{$self->{restrictstack}});
165 +        }
166 +        else {
167 +          $self->{switch}->parseerror("Unmatched </$name>");
168 +        }
169 +        }
170 + }
171 +
172   sub require_start {
173          my $self=shift;
174          my $name=shift;
# Line 114 | Line 177 | sub require_start {
177          $self->{switch}->checktag( $name, $hashref, 'version');
178          $self->{switch}->checktag( $name, $hashref, 'name');
179          $self->{switch}->checktag( $name, $hashref, 'url');
180 +        if ( $self->{reqcontext} == 1 ) {
181 +          $self->{switch}->parseerror(
182 +                "Open new $name conext without previous </$name>");
183 +        }
184 +        $self->{reqcontext}=1;
185          if ( $self->{Arch} ) {
186 +          $$hashref{'name'}=~tr[A-Z][a-z];
187            push @{$self->{tools}}, $$hashref{'name'};
188            $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
189            # -- make sure the full url is taken
190            my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
191            $self->{url}{$$hashref{'name'}}=$urlobj->url();
192 +          if ( $self->_autoselect() ) {
193 +             $self->{selected}{$$hashref{'name'}}=1;
194 +          }
195 +          else {
196 +             $self->{selected}{$$hashref{'name'}}=0;
197 +          }
198 +        }
199 + }
200 +
201 + sub require_end {
202 +        my $self=shift;
203 +        my $name=shift;
204 +
205 +        if ( $self->{reqcontext} != 1 ) {
206 +          $self->{switch}->parseerror("No matching tag for </$name>");
207 +        }
208 +        else {
209 +          $self->{reqcontext}=0;
210 +        }
211 + }
212 +
213 + sub select_start {
214 +        my $self=shift;
215 +        my $name=shift;
216 +        my $hashref=shift;
217 +
218 +        $self->{switch}->checktag( $name, $hashref, 'name');
219 +        if ( $self->{Arch} ) {
220 +           $$hashref{'name'}=~tr[A-Z][a-z];
221 +           $self->{selected}{$$hashref{'name'}}=1;
222 +        }
223 + }
224 +
225 + sub deselect_start {
226 +        my $self=shift;
227 +        my $name=shift;
228 +        my $hashref=shift;
229 +
230 +        $self->{switch}->checktag( $name, $hashref, 'name');
231 +        if ( $self->{Arch} ) {
232 +           $$hashref{'name'}=~tr[A-Z][a-z];
233 +           $self->{selected}{$$hashref{'name'}}=0;
234          }
235   }
236  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines