ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Requirements.pm
Revision: 1.1.2.3
Committed: Tue Apr 25 14:07:39 2000 UTC (25 years ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_12_2, V0_12_1
Changes since 1.1.2.2: +26 -1 lines
Log Message:
Add Arch

File Contents

# User Rev Content
1 williamc 1.1.2.1 # Requirements Doc - just to get ordering info
2     #
3     # Interface
4     # ---------
5     # new(file) : new requirements doc
6 williamc 1.1.2.2 # setup(toolbox): set up the requirements into the specified toolbox object
7     # download(toolbox) : download description files (into toolbox cache)
8 williamc 1.1.2.1 # tools() : Return list of requirements (ordered)
9     # version(tool) : return the version of a given tool
10 williamc 1.1.2.2 # url(tool) : return the url of a given tool
11 williamc 1.1.2.1
12     package BuildSystem::Requirements;
13     use ActiveDoc::SimpleDoc;
14 williamc 1.1.2.2 use Utilities::Verbose;
15    
16 williamc 1.1.2.1 require 5.004;
17 williamc 1.1.2.2 @ISA=qw(Utilities::Verbose);
18 williamc 1.1.2.1
19     sub new {
20     my $class=shift;
21     my $self={};
22     bless $self, $class;
23     $self->{file}=shift;
24     $self->{Arch}=1;
25 williamc 1.1.2.3 push @{$self->{ARCHBLOCK}}, $self->{Arch};
26 williamc 1.1.2.1 $self->init($self->{file});
27     return $self;
28     }
29    
30 williamc 1.1.2.2 sub setup {
31     my $self=shift;
32     my $toolbox=shift;
33    
34     my $tool;
35     foreach $tool ( $self->tools() ) {
36     $toolbox->toolsetup($tool, $self->version($tool), $self->url($tool));
37     }
38     }
39    
40 williamc 1.1.2.1 sub tools {
41     my $self=shift;
42     return @{$self->{tools}};
43     }
44    
45     sub version {
46     my $self=shift;
47     my $tool=shift;
48     return $self->{'version'}{$tool};
49     }
50    
51 williamc 1.1.2.2 sub url {
52     my $self=shift;
53     my $tool=shift;
54     return $self->{'url'}{$tool};
55     }
56    
57 williamc 1.1.2.1 sub init {
58     my $self=shift;
59     my $file=shift;
60    
61     my $switch=ActiveDoc::SimpleDoc->new();
62     $switch->filetoparse($file);
63     $switch->newparse("ordering");
64 williamc 1.1.2.3 $switch->addtag("ordering","Architecture",
65     \&Arch_Start,$self,
66     "", $self,
67     \&Arch_End, $self);
68     $switch->grouptag("Architecture","ordering");
69 williamc 1.1.2.1 $switch->addtag("ordering","require",
70     \&require_start,$self,
71     "", $self,
72     "", $self);
73     $self->{switch}=$switch;
74     @{$self->{tools}}=();
75 williamc 1.1.2.2 $self->{switch}->parse("ordering");
76     }
77    
78     sub download {
79     my $self=shift;
80     my $toolbox=shift;
81    
82     my $tool;
83     foreach $tool ( $self->tools() ) {
84     $self->verbose("Downloading ".$self->url($tool));
85     $toolbox->_download($self->url($tool));
86     }
87 williamc 1.1.2.1 }
88    
89     # ---- Tag routines
90     sub require_start {
91     my $self=shift;
92     my $name=shift;
93     my $hashref=shift;
94    
95     $self->{switch}->checktag( $name, $hashref, 'version');
96     $self->{switch}->checktag( $name, $hashref, 'name');
97 williamc 1.1.2.2 $self->{switch}->checktag( $name, $hashref, 'file');
98 williamc 1.1.2.1 if ( $self->{Arch} ) {
99     push @{$self->{tools}}, $$hashref{'name'};
100 williamc 1.1.2.2 $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
101     $self->{url}{$$hashref{'name'}}=$$hashref{'file'};
102 williamc 1.1.2.1 }
103     }
104 williamc 1.1.2.3
105     sub Arch_Start {
106     my $self=shift;
107     my $name=shift;
108     my $hashref=shift;
109    
110     $self->{switch}->checktag($name, $hashref,'name');
111     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
112     : ($self->{Arch}=0);
113     push @{$self->{ARCHBLOCK}}, $self->{Arch};
114     }
115    
116     sub Arch_End {
117     my $self=shift;
118     my $name=shift;
119    
120     pop @{$self->{ARCHBLOCK}};
121     $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
122     }
123