ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
Revision: 1.1.2.4.2.2
Committed: Thu Aug 10 15:39:19 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
Changes since 1.1.2.4.2.1: +34 -1 lines
Log Message:
upgrade doc version to 2.0 and add 1.0 compatability mode

File Contents

# Content
1 # Requirements Doc - just to get ordering info
2 #
3 # Interface
4 # ---------
5 # new(file,URLcache) : 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)
9 # version(tool) : return the version of a given tool
10 # url(tool) : return the url of a given tool
11
12 package BuildSystem::Requirements;
13 use ActiveDoc::SimpleURLDoc;
14 use Utilities::Verbose;
15
16 require 5.004;
17 @ISA=qw(Utilities::Verbose);
18
19 sub new {
20 my $class=shift;
21 my $self={};
22 bless $self, $class;
23 $self->{file}=shift;
24 $self->{cache}=shift;
25 $self->{mydocversion}="2.0";
26 $self->{Arch}=1;
27 push @{$self->{ARCHBLOCK}}, $self->{Arch};
28 $self->init($self->{file});
29 return $self;
30 }
31
32 sub setup {
33 my $self=shift;
34 my $toolbox=shift;
35
36 my $tool;
37 foreach $tool ( $self->tools() ) {
38 $self->verbose("Setting Up Tool $tool");
39 $toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
40 }
41 }
42
43 sub tools {
44 my $self=shift;
45 return @{$self->{tools}};
46 }
47
48 sub version {
49 my $self=shift;
50 my $tool=shift;
51 return $self->{'version'}{$tool};
52 }
53
54 sub url {
55 my $self=shift;
56 my $tool=shift;
57 return $self->{'url'}{$tool};
58 }
59
60 sub init {
61 my $self=shift;
62 my $file=shift;
63
64 my $switch=ActiveDoc::SimpleURLDoc->new($self->{cache});
65 $switch->filetoparse($file);
66 $switch->newparse("doc");
67 $switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self);
68 $switch->newparse("ordering");
69 $switch->addbasetags("ordering");
70 $switch->addtag("ordering","Architecture",
71 \&Arch_Start,$self,
72 "", $self,
73 \&Arch_End, $self);
74 $switch->grouptag("Architecture","ordering");
75 $switch->addtag("ordering","require",
76 \&require_start,$self,
77 "", $self,
78 "", $self);
79 # -- backwards compatiblity - TODO remove with backwards comp in ToolBox
80 $switch->newparse("oldordering");
81 $switch->addtag("oldordering","Architecture",
82 \&Arch_Start,$self,
83 "", $self,
84 \&Arch_End, $self);
85 $switch->grouptag("Architecture","oldordering");
86 $switch->addtag("oldordering","require",
87 \&oldrequire_start,$self,
88 "", $self,
89 "", $self);
90
91 $self->{switch}=$switch;
92 @{$self->{tools}}=();
93
94 $self->{switch}->parse("doc");
95 # -- for backwards compatability only parse if we have a docversion
96 # defined
97 if ( defined $self->{docversion} ) {
98 if ( $self->{docversion} eq $self->{mydocversion} ) {
99 $self->{switch}->parse("ordering");
100 }
101 elsif ( $self->{docversion} eq "1.0" ) {
102 print "Warning : Version 1.0 Requirement docs deprecated\n";
103 $self->{switch}->parse("oldordering");
104 }
105 }
106 else {
107 #print "wrong doc version - not parsing\n";
108 }
109 }
110
111 sub download {
112 my $self=shift;
113
114 my $tool;
115 foreach $tool ( $self->tools() ) {
116 $self->verbose("Downloading ".$self->url($tool));
117 # get into the cache
118 $self->{switch}->urlget($self->url($tool));
119 }
120 }
121
122 # ---- Tag routines
123
124 sub Doc_start {
125 my $self=shift;
126 my $name=shift;
127 my $hashref=shift;
128
129 $self->{switch}->checktag( $name, $hashref, 'type');
130 $self->{switch}->checktag( $name, $hashref, 'version');
131
132 $self->{docversion}=$$hashref{'version'};
133 }
134
135 sub require_start {
136 my $self=shift;
137 my $name=shift;
138 my $hashref=shift;
139
140 $self->{switch}->checktag( $name, $hashref, 'version');
141 $self->{switch}->checktag( $name, $hashref, 'name');
142 $self->{switch}->checktag( $name, $hashref, 'url');
143 if ( $self->{Arch} ) {
144 push @{$self->{tools}}, $$hashref{'name'};
145 $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
146 # -- make sure the full url is taken
147 my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
148 $self->{url}{$$hashref{'name'}}=$urlobj->url();
149 }
150 }
151
152 sub Arch_Start {
153 my $self=shift;
154 my $name=shift;
155 my $hashref=shift;
156
157 $self->{switch}->checktag($name, $hashref,'name');
158 ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
159 : ($self->{Arch}=0);
160 push @{$self->{ARCHBLOCK}}, $self->{Arch};
161 }
162
163 sub Arch_End {
164 my $self=shift;
165 my $name=shift;
166
167 pop @{$self->{ARCHBLOCK}};
168 $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
169 }
170
171 sub oldrequire_start {
172 my $self=shift;
173 my $name=shift;
174 my $hashref=shift;
175
176 $self->{switch}->checktag( $name, $hashref, 'version');
177 $self->{switch}->checktag( $name, $hashref, 'name');
178 $self->{switch}->checktag( $name, $hashref, 'file');
179 if ( $self->{Arch} ) {
180 push @{$self->{tools}}, $$hashref{'name'};
181 $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
182 $self->{url}{$$hashref{'name'}}=$$hashref{'file'};
183 }
184 }