ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
Revision: 1.1.2.4.2.8
Committed: Thu Aug 24 09:49:51 2000 UTC (24 years, 8 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
Changes since 1.1.2.4.2.7: +15 -9 lines
Log Message:
Change Requirements Interface

File Contents

# Content
1 # Requirements Doc - just to get ordering info
2 #
3 # Interface
4 # ---------
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 ALL requirements (ordered)
9 # selectedtools() : Return list of only those tools selected
10 # version(tool) : return the version 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::ActiveDoc;
16 use Utilities::Verbose;
17
18 require 5.004;
19 @ISA=qw(Utilities::Verbose);
20
21 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});
32 return $self;
33 }
34
35 sub setup {
36 my $self=shift;
37 my $toolbox=shift;
38
39 my $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
46 sub tools {
47 my $self=shift;
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 toolurl {
69 my $self=shift;
70 my $tool=shift;
71 return $self->{'url'}{$tool};
72 }
73
74 sub init {
75 my $self=shift;
76 my $url=shift;
77
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 \&require_end, $self);
104
105 $self->{reqcontext}=0;
106 $self->{switch}=$switch;
107 undef $self->{restrictstack};
108 @{$self->{tools}}=();
109
110 my($doctype,$docversion)=$switch->doctype();
111 # -- for backwards compatability only parse if we have a docversion
112 # defined
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;
130
131 my $tool;
132 foreach $tool ( $self->tools() ) {
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 Restrict_start {
151 my $self=shift;
152 my $name=shift;
153 my $hashref=shift;
154
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 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 {
179 my $self=shift;
180 my $name=shift;
181 my $hashref=shift;
182
183 $self->{switch}->checktag( $name, $hashref, 'version');
184 $self->{switch}->checktag( $name, $hashref, 'name');
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 # -- 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
243 sub Arch_Start {
244 my $self=shift;
245 my $name=shift;
246 my $hashref=shift;
247
248 $self->{switch}->checktag($name, $hashref,'name');
249 ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
250 : ($self->{Arch}=0);
251 push @{$self->{ARCHBLOCK}}, $self->{Arch};
252 }
253
254 sub Arch_End {
255 my $self=shift;
256 my $name=shift;
257
258 pop @{$self->{ARCHBLOCK}};
259 $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
260 }