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.3 by williamc, Tue Apr 25 14:07:39 2000 UTC vs.
Revision 1.1.2.4.2.7 by williamc, Tue Aug 22 14:35:09 2000 UTC

# Line 2 | Line 2
2   #
3   # Interface
4   # ---------
5 < # new(file)     : new requirements doc
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  
13   package BuildSystem::Requirements;
14 < use ActiveDoc::SimpleDoc;
14 > use ActiveDoc::ActiveDoc;
15   use Utilities::Verbose;
16  
17   require 5.004;
# Line 21 | Line 22 | sub new {
22          my $self={};
23          bless $self, $class;
24          $self->{file}=shift;
25 +        $self->{cache}=shift;
26 +        $self->{dbstore}=shift;
27 +        $self->{mydocversion}="2.0";
28          $self->{Arch}=1;
29          push @{$self->{ARCHBLOCK}}, $self->{Arch};
30          $self->init($self->{file});
# Line 32 | 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          }
43   }
# Line 42 | 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 56 | Line 72 | sub url {
72  
73   sub init {
74          my $self=shift;
75 <        my $file=shift;
75 >        my $url=shift;
76  
77 <        my $switch=ActiveDoc::SimpleDoc->new();
78 <        $switch->filetoparse($file);
77 >        my $switch=ActiveDoc::ActiveDoc->new($self->{cache},$self->{dbstore});
78 >        $switch->verbosity($self->verbosity());
79 >        $switch->url($url);
80          $switch->newparse("ordering");
81 +        $switch->addbasetags("ordering");
82          $switch->addtag("ordering","Architecture",
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 <        $self->{switch}->parse("ordering");
108 >        
109 >        my($doctype,$docversion)=$switch->doctype();
110 >        # -- for backwards compatability only parse if we have a docversion
111 >        #    defined
112 >        if ( defined $docversion ) {
113 >          if ( $docversion eq $self->{mydocversion} ) {
114 >            $self->{switch}->parse("ordering");
115 >          }
116 >        }
117 >        else {
118 >          #print "wrong doc version - not parsing\n";
119 >        }
120   }
121  
122   sub download {
123          my $self=shift;
80        my $toolbox=shift;
124  
125          my $tool;
126          foreach $tool ( $self->tools() ) {
127            $self->verbose("Downloading ".$self->url($tool));
128 <          $toolbox->_download($self->url($tool));
128 >          # get into the cache
129 >          $self->{switch}->urlget($self->url($tool));
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 94 | Line 176 | sub require_start {
176          
177          $self->{switch}->checktag( $name, $hashref, 'version');
178          $self->{switch}->checktag( $name, $hashref, 'name');
179 <        $self->{switch}->checktag( $name, $hashref, 'file');
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 <          $self->{url}{$$hashref{'name'}}=$$hashref{'file'};
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  
# Line 120 | Line 252 | sub Arch_End {
252          pop @{$self->{ARCHBLOCK}};
253          $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
254   }
123

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines