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.1 by williamc, Fri Apr 7 08:12:47 2000 UTC vs.
Revision 1.1.2.4 by williamc, Thu May 4 15:45:07 2000 UTC

# Line 3 | Line 3
3   # Interface
4   # ---------
5   # new(file)     : 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::SimpleDoc;
14 + use Utilities::Verbose;
15 +
16   require 5.004;
17 + @ISA=qw(Utilities::Verbose);
18  
19   sub new {
20          my $class=shift;
# Line 16 | Line 22 | sub new {
22          bless $self, $class;
23          $self->{file}=shift;
24          $self->{Arch}=1;
25 <        push @{$self->{ARCHBLOCK}}, $Arch;
25 >        push @{$self->{ARCHBLOCK}}, $self->{Arch};
26          $self->init($self->{file});
27          return $self;
28   }
29  
30 + 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   sub tools {
41          my $self=shift;
42          return @{$self->{tools}};
# Line 32 | Line 48 | sub version {
48          return $self->{'version'}{$tool};
49   }
50  
51 + sub url {
52 +        my $self=shift;
53 +        my $tool=shift;
54 +        return $self->{'url'}{$tool};
55 + }
56 +
57   sub init {
58          my $self=shift;
59          my $file=shift;
60  
61          my $switch=ActiveDoc::SimpleDoc->new();
62          $switch->filetoparse($file);
63 +        $switch->newparse("doc");
64 +        $switch->addtag("doc","Doc", \&Doc_start,$self,"",$self,"",$self);
65          $switch->newparse("ordering");
66 +        $switch->addtag("ordering","Architecture",
67 +                                        \&Arch_Start,$self,
68 +                                        "", $self,
69 +                                        \&Arch_End, $self);
70 +        $switch->grouptag("Architecture","ordering");
71          $switch->addtag("ordering","require",
72                                          \&require_start,$self,
73                                          "", $self,
74                                          "", $self);
75          $self->{switch}=$switch;
76          @{$self->{tools}}=();
77 <        $switch->parse("ordering");
77 >        
78 >        $self->{switch}->parse("doc");
79 >        # -- for backwards compatability only parse if we have a docversion
80 >        #    defined
81 >        if ( defined $self->{docversion} ) {
82 >          $self->{switch}->parse("ordering");
83 >        }
84 > }
85 >
86 > sub download {
87 >        my $self=shift;
88 >        my $toolbox=shift;
89 >
90 >        my $tool;
91 >        foreach $tool ( $self->tools() ) {
92 >          $self->verbose("Downloading ".$self->url($tool));
93 >          $toolbox->_download($self->url($tool));
94 >        }
95   }
96  
97   # ---- Tag routines
98 +
99 + sub Doc_start {
100 +        my $self=shift;
101 +        my $name=shift;
102 +        my $hashref=shift;
103 +
104 +        $self->{switch}->checktag( $name, $hashref, 'type');
105 +        $self->{switch}->checktag( $name, $hashref, 'version');
106 +
107 +        $self->{docversion}=$$hashref{'version'};
108 + }
109 +
110   sub require_start {
111          my $self=shift;
112          my $name=shift;
# Line 56 | Line 114 | sub require_start {
114          
115          $self->{switch}->checktag( $name, $hashref, 'version');
116          $self->{switch}->checktag( $name, $hashref, 'name');
117 +        $self->{switch}->checktag( $name, $hashref, 'file');
118          if ( $self->{Arch} ) {
119            push @{$self->{tools}}, $$hashref{'name'};
120 <          $self->{version}{$$hashref{'name'}}=$$hashref{'version'}
120 >          $self->{version}{$$hashref{'name'}}=$$hashref{'version'};
121 >          $self->{url}{$$hashref{'name'}}=$$hashref{'file'};
122          }
123   }
124 +
125 + sub Arch_Start {
126 +        my $self=shift;
127 +        my $name=shift;
128 +        my $hashref=shift;
129 +
130 +        $self->{switch}->checktag($name, $hashref,'name');
131 +        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
132 +                                                : ($self->{Arch}=0);
133 +        push @{$self->{ARCHBLOCK}}, $self->{Arch};
134 + }
135 +
136 + sub Arch_End {
137 +        my $self=shift;
138 +        my $name=shift;
139 +
140 +        pop @{$self->{ARCHBLOCK}};
141 +        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
142 + }
143 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines