ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/ToolData.pm
Revision: 1.1.2.1
Committed: Fri Feb 27 15:34:55 2004 UTC (21 years, 2 months ago) by sashby
Content type: text/plain
Branch: SCRAM_V1_BRANCH
CVS Tags: V1_pre0, SCRAM_V1, SCRAMV1_IMPORT
Branch point for: V1_pre1
Changes since 1.1: +259 -0 lines
Log Message:
First import of new SCRAM packages into CMS cvs repos.

File Contents

# Content
1 #____________________________________________________________________
2 # File: ToolData.pm
3 #____________________________________________________________________
4 #
5 # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 # Update: 2003-11-21 15:26:07+0100
7 # Revision: $Id: ToolData.pm,v 1.4 2004/02/16 11:55:37 sashby Exp $
8 #
9 # Copyright: 2003 (C) Shaun Ashby
10 #
11 #--------------------------------------------------------------------
12 package BuildSystem::ToolData;
13 require 5.004;
14
15 use Exporter;
16
17 @ISA=qw(Exporter);
18 #
19 sub new
20 ###############################################################
21 # new #
22 ###############################################################
23 # modified : Fri Nov 21 15:26:14 2003 / SFA #
24 # params : #
25 # : #
26 # function : #
27 # : #
28 ###############################################################
29 {
30 my $proto=shift;
31 my $class=ref($proto) || $proto;
32 my $self={SCRAM_PROJECT => 0};
33 bless $self,$class;
34 return $self;
35 }
36
37 sub toolname()
38 {
39 my $self=shift;
40 @_ ? $self->{TOOLNAME} = shift
41 : $self->{TOOLNAME};
42 }
43
44 sub toolversion()
45 {
46 my $self=shift;
47 @_ ? $self->{TOOLVERSION} = shift
48 : $self->{TOOLVERSION};
49 }
50
51 sub lib()
52 {
53 my $self=shift;
54 # Add libs to array:
55 @_ ? push(@{$self->{LIB}},@{$_[0]})
56 : @{$self->{LIB}};
57 }
58
59 sub include()
60 {
61 my $self=shift;
62 # Add libs to array:
63 @_ ? push(@{$self->{INCLUDE}},@_)
64 : @{$self->{INCLUDE}};
65 }
66
67 sub libdir()
68 {
69 my $self=shift;
70 # Add libdir to array:
71 @_ ? push(@{$self->{LIBDIR}},@_)
72 : @{$self->{LIBDIR}};
73 }
74
75 sub use()
76 {
77 my $self=shift;
78 # Add deps to array:
79 @_ ? push(@{$self->{USE}},@{$_[0]})
80 : @{$self->{USE}};
81 }
82
83 sub makefile()
84 {
85 my $self=shift;
86 @_ ? push(@{$self->{MAKEFILE}},@{$_[0]})
87 : @{$self->{MAKEFILE}};
88 }
89
90 sub flags()
91 {
92 my $self=shift;
93 my ($flag,$flagvalue) = @_;
94
95 if ($flag && $flagvalue)
96 {
97 if (exists ($self->{FLAGS}->{$flag}))
98 {
99 push(@{$self->{FLAGS}->{$flag}},@$flagvalue);
100 }
101 else
102 {
103 $self->{FLAGS}->{$flag} = [ @$flagvalue ];
104 }
105 }
106 elsif ($flag && $self->{FLAGS}->{$flag}->[0] ne '')
107 {
108 return @{$self->{FLAGS}->{$flag}};
109 }
110 else
111 {
112 return "";
113 }
114 }
115
116 sub allflags()
117 {
118 my $self=shift;
119 (scalar(keys %{$self->{FLAGS}}) > 0) ? return $self->{FLAGS} : return undef;
120 }
121
122 sub scram_project()
123 {
124 my $self=shift;
125 @_ ? $self->{SCRAM_PROJECT} = shift
126 : $self->{SCRAM_PROJECT};
127 }
128
129 sub variable_data()
130 {
131 my $self=shift;
132 my ($varname,$varvalue) = @_;
133
134 if ($varname && $varvalue)
135 {
136 $self->{$varname} = $varvalue;
137 # Keep track of all variables:
138 push(@{$self->{VARIABLES}},$varname);
139 }
140 else
141 {
142 return $self->{$varname};
143 }
144 }
145
146 sub list_variables
147 {
148 my $self=shift;
149 return @{$self->{VARIABLES}};
150 }
151
152 sub runtime()
153 {
154 my $self=shift;
155 my ($rt,$rtvalue,$rt_type) = @_;
156
157 # If both a runtime name and value are supplied, store this variable:
158 if ($rt && $rtvalue)
159 {
160 # If there was a type (e.g. PATH), combine this with runtime var
161 # name to make it specific to a Runtime type:
162 if ($rt_type)
163 {
164 # Only uppercase:
165 $rt_type =~ tr/[a-z]/[A-Z]/;
166 $rtname = $rt_type.":".$rt;
167 $self->{RUNTIME}->{$rtname} = $rtvalue;
168 return;
169 }
170 else
171 {
172 $self->{RUNTIME}->{$rt} = $rtvalue;
173 return;
174 }
175 }
176 elsif ($rt)
177 {
178 # Return the value for this runtime var name:
179 return $self->{RUNTIME}->{$rt};
180 }
181 else
182 {
183 # Return all RT settings:
184 return $self->{RUNTIME};
185 }
186 }
187
188 sub getfeatures()
189 {
190 my $self=shift;
191 my ($feature)=@_;
192 my @feature_vars=$self->list_variables();
193 my @features;
194 push (@features, @feature_vars, qw(LIB LIBDIR INCLUDE MAKEFILE USE));
195
196 if ($feature && grep($feature eq $_, @features))
197 {
198 (ref($self->{$feature}) eq 'ARRAY') ? print join(" ",@{$self->{$feature}})
199 : print join(" ",$self->{$feature});
200 print "\n";
201 }
202 else
203 {
204 print join("\n",@features),"\n";
205 }
206 }
207
208 sub summarize_features()
209 {
210 my $self=shift;
211 my @variables = $self->list_variables();
212 my @features = qw(LIB LIBDIR INCLUDE MAKEFILE FLAGS USE);
213
214 # Print out any variables:
215 foreach my $var (@variables)
216 {
217 print $var,"=",$self->{$var},"\n";
218 }
219
220 print "SCRAM_PROJECT=";
221 ($self->scram_project() == 1) ? print "yes" : print "no";
222 print "\n";
223
224 foreach my $feature (@features)
225 {
226 if (exists $self->{$feature})
227 {
228 if ($feature eq 'MAKEFILE')
229 {
230 print "\n---- Makefile tag content ----","\n";
231 print join(" ",@{$self->{MAKEFILE}}),"\n\n";
232 }
233 elsif ($feature eq 'FLAGS')
234 {
235 print "\n---- BuildSystem compiler/make flags----","\n";
236 my $flags=$self->allflags();
237 while (my ($f,$fv) = each %{$flags})
238 {
239 print $f,"+=",join(" ",@{$fv}),"\n";
240 }
241 foreach my $flag (@flaglist)
242 {
243 print $flag,"+=",join(" ",@{$self->flags($flag)}),"\n";
244 }
245 }
246 elsif ($feature eq 'USE')
247 {
248 print "\n---- BuildSystem dependencies ----","\n";
249 print $feature,"=",join(" ",@{$self->{$feature}}),"\n\n";
250 }
251 else
252 {
253 print $feature,"=",join(" ",@{$self->{$feature}}),"\n";
254 }
255 }
256 }
257 }
258
259 1;