1 |
# Requirements Doc - just to get ordering info
|
2 |
#
|
3 |
# Interface
|
4 |
# ---------
|
5 |
# new(file,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)
|
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::ActiveDoc;
|
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->{dbstore}=shift;
|
26 |
$self->{mydocversion}="2.0";
|
27 |
$self->{Arch}=1;
|
28 |
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
29 |
$self->init($self->{file});
|
30 |
return $self;
|
31 |
}
|
32 |
|
33 |
sub setup {
|
34 |
my $self=shift;
|
35 |
my $toolbox=shift;
|
36 |
|
37 |
my $tool;
|
38 |
foreach $tool ( $self->tools() ) {
|
39 |
$self->verbose("Setting Up Tool $tool");
|
40 |
$toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
|
41 |
}
|
42 |
}
|
43 |
|
44 |
sub tools {
|
45 |
my $self=shift;
|
46 |
return @{$self->{tools}};
|
47 |
}
|
48 |
|
49 |
sub version {
|
50 |
my $self=shift;
|
51 |
my $tool=shift;
|
52 |
return $self->{'version'}{$tool};
|
53 |
}
|
54 |
|
55 |
sub url {
|
56 |
my $self=shift;
|
57 |
my $tool=shift;
|
58 |
return $self->{'url'}{$tool};
|
59 |
}
|
60 |
|
61 |
sub init {
|
62 |
my $self=shift;
|
63 |
my $file=shift;
|
64 |
|
65 |
my $switch=ActiveDoc::ActiveDoc->new($self->{cache});
|
66 |
$switch->filetoparse($file);
|
67 |
$switch->newparse("doc");
|
68 |
$switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self);
|
69 |
$switch->newparse("ordering");
|
70 |
$switch->addbasetags("ordering");
|
71 |
$switch->addtag("ordering","Architecture",
|
72 |
\&Arch_Start,$self,
|
73 |
"", $self,
|
74 |
\&Arch_End, $self);
|
75 |
$switch->grouptag("Architecture","ordering");
|
76 |
$switch->addtag("ordering","require",
|
77 |
\&require_start,$self,
|
78 |
"", $self,
|
79 |
"", $self);
|
80 |
|
81 |
$self->{switch}=$switch;
|
82 |
@{$self->{tools}}=();
|
83 |
|
84 |
$self->{switch}->parse("doc");
|
85 |
# -- for backwards compatability only parse if we have a docversion
|
86 |
# defined
|
87 |
if ( defined $self->{docversion} ) {
|
88 |
if ( $self->{docversion} eq $self->{mydocversion} ) {
|
89 |
$self->{switch}->parse("ordering");
|
90 |
}
|
91 |
}
|
92 |
else {
|
93 |
#print "wrong doc version - not parsing\n";
|
94 |
}
|
95 |
}
|
96 |
|
97 |
sub download {
|
98 |
my $self=shift;
|
99 |
|
100 |
my $tool;
|
101 |
foreach $tool ( $self->tools() ) {
|
102 |
$self->verbose("Downloading ".$self->url($tool));
|
103 |
# get into the cache
|
104 |
$self->{switch}->urlget($self->url($tool));
|
105 |
}
|
106 |
}
|
107 |
|
108 |
# ---- Tag routines
|
109 |
|
110 |
sub Doc_start {
|
111 |
my $self=shift;
|
112 |
my $name=shift;
|
113 |
my $hashref=shift;
|
114 |
|
115 |
$self->{switch}->checktag( $name, $hashref, 'type');
|
116 |
$self->{switch}->checktag( $name, $hashref, 'version');
|
117 |
|
118 |
$self->{docversion}=$$hashref{'version'};
|
119 |
}
|
120 |
|
121 |
sub require_start {
|
122 |
my $self=shift;
|
123 |
my $name=shift;
|
124 |
my $hashref=shift;
|
125 |
|
126 |
$self->{switch}->checktag( $name, $hashref, 'version');
|
127 |
$self->{switch}->checktag( $name, $hashref, 'name');
|
128 |
$self->{switch}->checktag( $name, $hashref, 'url');
|
129 |
if ( $self->{Arch} ) {
|
130 |
push @{$self->{tools}}, $$hashref{'name'};
|
131 |
$self->{version}{$$hashref{'name'}}=$$hashref{'version'};
|
132 |
# -- make sure the full url is taken
|
133 |
my $urlobj=$self->{switch}->expandurl($$hashref{'url'});
|
134 |
$self->{url}{$$hashref{'name'}}=$urlobj->url();
|
135 |
}
|
136 |
}
|
137 |
|
138 |
sub Arch_Start {
|
139 |
my $self=shift;
|
140 |
my $name=shift;
|
141 |
my $hashref=shift;
|
142 |
|
143 |
$self->{switch}->checktag($name, $hashref,'name');
|
144 |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
|
145 |
: ($self->{Arch}=0);
|
146 |
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
147 |
}
|
148 |
|
149 |
sub Arch_End {
|
150 |
my $self=shift;
|
151 |
my $name=shift;
|
152 |
|
153 |
pop @{$self->{ARCHBLOCK}};
|
154 |
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
|
155 |
}
|