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 by williamc, Thu May 4 15:45:07 2000 UTC vs.
Revision 1.1.2.4.2.8 by williamc, Thu Aug 24 09:49:51 2000 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(file)     : new requirements doc
5 > # new(ActiveStore,url)     : 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
11 > # toolurl(tool)     : return the url of a given tool
12 > # htmlinfo()    : output requiremnts doc in html format
13  
14   package BuildSystem::Requirements;
15 < use ActiveDoc::SimpleDoc;
15 > use ActiveDoc::ActiveDoc;
16   use Utilities::Verbose;
17  
18   require 5.004;
# Line 20 | Line 22 | sub new {
22          my $class=shift;
23          my $self={};
24          bless $self, $class;
25 +        $self->{dbstore}=shift;
26          $self->{file}=shift;
27 +        $self->{cache}=$self->{dbstore}->cache();
28 +        $self->{mydocversion}="2.0";
29          $self->{Arch}=1;
30          push @{$self->{ARCHBLOCK}}, $self->{Arch};
31          $self->init($self->{file});
# Line 32 | Line 37 | sub setup {
37          my $toolbox=shift;
38  
39          my $tool;
40 <        foreach $tool ( $self->tools() ) {
41 <          $toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
40 >        foreach $tool ( $self->selectedtools() ) {
41 >          $self->verbose("Setting Up Tool $tool");
42 >          $toolbox->toolsetup($tool, $self->version($tool), $self->toolurl($tool));
43          }
44   }
45  
# Line 42 | Line 48 | sub tools {
48          return @{$self->{tools}};
49   }
50  
51 + sub selectedtools {
52 +        my $self=shift;
53 +        my @toollist=();
54 +        foreach $tool (  @{$self->{tools}} ) {
55 +          if ( $self->{selected}{$tool} == 1 ) {
56 +                push @toollist, $tool;
57 +          }
58 +        }
59 +        return @toollist;
60 + }
61 +
62   sub version {
63          my $self=shift;
64          my $tool=shift;
65          return $self->{'version'}{$tool};
66   }
67  
68 < sub url {
68 > sub toolurl {
69          my $self=shift;
70          my $tool=shift;
71          return $self->{'url'}{$tool};
# Line 56 | Line 73 | sub url {
73  
74   sub init {
75          my $self=shift;
76 <        my $file=shift;
76 >        my $url=shift;
77  
78 <        my $switch=ActiveDoc::SimpleDoc->new();
79 <        $switch->filetoparse($file);
80 <        $switch->newparse("doc");
64 <        $switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self);
78 >        my $switch=ActiveDoc::ActiveDoc->new($self->{dbstore});
79 >        $switch->verbosity($self->verbosity());
80 >        $switch->url($url);
81          $switch->newparse("ordering");
82 +        $switch->addbasetags("ordering");
83          $switch->addtag("ordering","Architecture",
84                                          \&Arch_Start,$self,
85                                          "", $self,
86                                          \&Arch_End, $self);
87 +        $switch->addtag("ordering","Restrict",
88 +                                        \&Restrict_start,$self,
89 +                                        "", $self,
90 +                                        \&Restrict_end, $self);
91 +        $switch->addtag("ordering","deselect",
92 +                                        \&deselect_start,$self,
93 +                                        "", $self,
94 +                                        "", $self);
95 +        $switch->addtag("ordering","select",
96 +                                        \&select_start,$self,
97 +                                        "", $self,
98 +                                        "", $self);
99          $switch->grouptag("Architecture","ordering");
100          $switch->addtag("ordering","require",
101                                          \&require_start,$self,
102                                          "", $self,
103 <                                        "", $self);
103 >                                        \&require_end, $self);
104 >
105 >        $self->{reqcontext}=0;
106          $self->{switch}=$switch;
107 +        undef $self->{restrictstack};
108          @{$self->{tools}}=();
109          
110 <        $self->{switch}->parse("doc");
110 >        my($doctype,$docversion)=$switch->doctype();
111          # -- for backwards compatability only parse if we have a docversion
112          #    defined
113 <        if ( defined $self->{docversion} ) {
114 <          $self->{switch}->parse("ordering");
113 >        if ( defined $docversion ) {
114 >          if ( $docversion eq $self->{mydocversion} ) {
115 >            $self->{switch}->parse("ordering");
116 >          }
117          }
118 +        else {
119 +          #print "wrong doc version - not parsing\n";
120 +        }
121 + }
122 +
123 + sub htmlinfo {
124 +        my $self=shift;
125 +        print "Hello\n";
126   }
127  
128   sub download {
129          my $self=shift;
88        my $toolbox=shift;
130  
131          my $tool;
132          foreach $tool ( $self->tools() ) {
133 <          $self->verbose("Downloading ".$self->url($tool));
134 <          $toolbox->_download($self->url($tool));
133 >          $self->verbose("Downloading ".$self->toolurl($tool));
134 >          # get into the cache
135 >          $self->{switch}->urlget($self->toolurl($tool));
136 >        }
137 > }
138 >
139 > sub _autoselect {
140 >        my $self=shift;
141 >        if ( @_ ) {
142 >          $self->{autoselect}=shift;
143          }
144 +        # -- default is true
145 +        return ((defined $self->{autoselect})?$self->{autoselect}:1);
146   }
147  
148   # ---- Tag routines
149  
150 < sub Doc_start {
150 > sub Restrict_start {
151          my $self=shift;
152          my $name=shift;
153 <        my $hashref=shift;
153 >        my $hashref=shift;
154  
155 <        $self->{switch}->checktag( $name, $hashref, 'type');
156 <        $self->{switch}->checktag( $name, $hashref, 'version');
155 >        $self->{switch}->checktag( $name, $hashref, 'autoselect');
156 >        if ( $self->{Arch} ) {
157 >        # -- create selection state stack
158 >        push @{$self->{restrictstack}}, $self->_autoselect();
159 >        $self->_autoselect(
160 >                (($$hashref{'autoselect'}=~/true/i)?1:0));
161 >        }
162 > }
163  
164 <        $self->{docversion}=$$hashref{'version'};
164 > sub Restrict_end {
165 >        my $self=shift;
166 >        my $name=shift;
167 >
168 >        if ( $self->{Arch} ) {
169 >        if ( $#{$self->{restrictstack}} >= 0 ) {
170 >          $self->_autoselect(pop @{$self->{restrictstack}});
171 >        }
172 >        else {
173 >          $self->{switch}->parseerror("Unmatched </$name>");
174 >        }
175 >        }
176   }
177  
178   sub require_start {
# Line 114 | Line 182 | sub require_start {
182          
183          $self->{switch}->checktag( $name, $hashref, 'version');
184          $self->{switch}->checktag( $name, $hashref, 'name');
185 <        $self->{switch}->checktag( $name, $hashref, 'file');
185 >        $self->{switch}->checktag( $name, $hashref, 'url');
186 >        if ( $self->{reqcontext} == 1 ) {
187 >          $self->{switch}->parseerror(
188 >                "Open new $name conext without previous </$name>");
189 >        }
190 >        $self->{reqcontext}=1;
191          if ( $self->{Arch} ) {
192 +          $$hashref{'name'}=~tr[A-Z][a-z];
193            push @{$self->{tools}}, $$hashref{'name'};
194            $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
195 <          $self->{url}{$$hashref{'name'}}=$$hashref{'file'};
195 >          # -- make sure the full url is taken
196 >          my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
197 >          $self->{url}{$$hashref{'name'}}=$urlobj->url();
198 >          if ( $self->_autoselect() ) {
199 >             $self->{selected}{$$hashref{'name'}}=1;
200 >          }
201 >          else {
202 >             $self->{selected}{$$hashref{'name'}}=0;
203 >          }
204 >        }
205 > }
206 >
207 > sub require_end {
208 >        my $self=shift;
209 >        my $name=shift;
210 >
211 >        if ( $self->{reqcontext} != 1 ) {
212 >          $self->{switch}->parseerror("No matching tag for </$name>");
213 >        }
214 >        else {
215 >          $self->{reqcontext}=0;
216 >        }
217 > }
218 >
219 > sub select_start {
220 >        my $self=shift;
221 >        my $name=shift;
222 >        my $hashref=shift;
223 >
224 >        $self->{switch}->checktag( $name, $hashref, 'name');
225 >        if ( $self->{Arch} ) {
226 >           $$hashref{'name'}=~tr[A-Z][a-z];
227 >           $self->{selected}{$$hashref{'name'}}=1;
228 >        }
229 > }
230 >
231 > sub deselect_start {
232 >        my $self=shift;
233 >        my $name=shift;
234 >        my $hashref=shift;
235 >
236 >        $self->{switch}->checktag( $name, $hashref, 'name');
237 >        if ( $self->{Arch} ) {
238 >           $$hashref{'name'}=~tr[A-Z][a-z];
239 >           $self->{selected}{$$hashref{'name'}}=0;
240          }
241   }
242  
# Line 140 | Line 258 | sub Arch_End {
258          pop @{$self->{ARCHBLOCK}};
259          $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
260   }
143

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines