ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildDataUtils.pm
Revision: 1.4
Committed: Wed Mar 9 19:28:19 2005 UTC (20 years, 2 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: V1_0_3-p4, V1_0_3-p3, V1_0_3-p2, before110xmlBRmerge, V1_0_4p1, V1_0_3-p1, V1_0_3, V1_0_2, V1_0_2_p1, v102p1, V1_0_1
Branch point for: v103_with_xml, v103_branch
Changes since 1.3: +16 -13 lines
Log Message:
Started adding support for skipping builds in some dirs.

File Contents

# Content
1 #____________________________________________________________________
2 # File: BuildDataUtils.pm
3 #____________________________________________________________________
4 #
5 # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 # Update: 2003-12-03 19:18:46+0100
7 # Revision: $Id: BuildDataUtils.pm,v 1.3 2005/02/16 18:02:59 sashby Exp $
8 #
9 # Copyright: 2003 (C) Shaun Ashby
10 #
11 #--------------------------------------------------------------------
12 package BuildSystem::BuildDataUtils;
13 require 5.004;
14
15 use Exporter;
16 @ISA=qw(Exporter);
17 @EXPORT_OK=qw( );
18
19
20 sub new()
21 ###############################################################
22 # new #
23 ###############################################################
24 # modified : Wed Dec 3 19:18:50 2003 / SFA #
25 # params : #
26 # : #
27 # function : #
28 # : #
29 ###############################################################
30 {
31 my $proto=shift;
32 my $class=ref($proto) || $proto;
33 my $self={};
34
35 bless $self,$class;
36 return $self;
37 }
38
39 #
40 sub classpath
41 {
42 my $self=shift;
43 # Return array of ClassPaths:
44 return $self->{content}->{CLASSPATH};
45 }
46
47 sub productstore
48 {
49 my $self=shift;
50 # Return an array of ProductStore hashes:
51 return $self->{content}->{PRODUCTSTORE};
52 }
53
54 sub lib
55 {
56 my $self=shift;
57 # Return an array of required libs:
58 return $self->{content}->{LIB};
59 }
60
61 sub include
62 {
63 my $self=shift;
64 # Return an array of required includes:
65 return $self->{content}->{INCLUDE};
66 }
67
68 sub libtype
69 {
70 my $self=shift;
71 # Return an array of required lib types:
72 return $self->{content}->{LIBTYPE};
73 }
74
75 sub flags
76 {
77 my $self=shift;
78 # Return hash data for flags:
79 return $self->{content}->{FLAGS};
80 }
81
82 sub allflags
83 {
84 my $self=shift;
85 # Return hash data for flags:
86 return $self->{content}->{FLAGS};
87 }
88
89 sub makefile
90 {
91 my $self=shift;
92 # Return an array of makefile stubs:
93 return $self->{content}->{MAKEFILE};
94 }
95
96 sub archspecific
97 {
98 my $self=shift;
99
100 # Check to see if there is arch-dependent data. If so, return it:
101 if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
102 {
103 while (my ($k,$v) = each %{$self->{content}->{ARCH}})
104 {
105 if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
106 {
107 return $self->{content}->{ARCH}->{$k};
108 }
109 }
110 }
111 return "";
112 }
113
114 #
115 # The routines below are used when processing the build data:
116 #
117 sub use
118 {
119 my $self=shift;
120 # Add or return uses (package deps):
121 @_ ? push(@{$self->{content}->{USE}},@_)
122 : @{$self->{content}->{USE}};
123 }
124
125 sub group
126 {
127 my $self=shift;
128 # Add or return groups:
129 @_ ? push(@{$self->{content}->{GROUP}},@_)
130 : @{$self->{content}->{GROUP}};
131 }
132
133 sub hasexport
134 {
135 my $self=shift;
136 # Check to see if there is a valid export block:
137 my $nkeys = $self->exporteddatatypes();
138 $nkeys > 0 ? return 1 : return 0;
139 }
140
141 sub has
142 {
143 my $self=shift;
144 my ($datatype)=@_;
145 (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
146 }
147
148 sub exported
149 {
150 my $self=shift;
151 # Return a hash. Keys are type of data provided:
152 return ($self->{content}->{EXPORT});
153 }
154
155 sub exporteddatatypes
156 {
157 my $self=shift;
158 # Return exported data types:
159 return keys %{$self->{content}->{EXPORT}};
160 }
161
162 sub defined_group
163 {
164 my $self=shift;
165
166 if (exists($self->{content}->{DEFINED_GROUP}))
167 {
168 # Return a list of keys (group names) for defined groups:
169 return [ keys %{$self->{content}->{DEFINED_GROUP}} ];
170 }
171 else
172 {
173 return 0;
174 }
175 }
176
177 sub dataforgroup
178 {
179 my $self=shift;
180 my ($groupname)=@_;
181 # Return hash containing data for defined group
182 # $groupname or return undef:
183 return $self->{content}->{DEFINED_GROUP}->{$groupname};
184 }
185
186 sub buildproducts
187 {
188 my $self=shift;
189 # Returns hash of build products and their data:
190 return $self->{content}->{BUILDPRODUCTS};
191 }
192
193 sub values
194 {
195 my $self=shift;
196 my ($type)=@_;
197 # Get a list of values from known types
198 return $self->{content}->{BUILDPRODUCTS}->{$type};
199 }
200
201 sub basic_tags()
202 {
203 my $self=shift;
204 my $datatags=[];
205 my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE BUILDPRODUCTS) ];
206 my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
207 my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
208 my @all_skip_tags;
209
210 push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
211
212 foreach my $t (keys %{$self->{content}})
213 {
214 push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
215 }
216 return @{$datatags};
217 }
218
219 sub clean()
220 {
221 my $self=shift;
222 my (@tags) = @_;
223
224 # Delete some useless entries:
225 delete $self->{makefilecontent};
226 delete $self->{simpledoc};
227 delete $self->{id};
228 delete $self->{tagcontent};
229 delete $self->{nested};
230
231 delete $self->{DEPENDENCIES};
232
233 map
234 {
235 delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
236 } @tags;
237
238 return $self;
239 }
240
241 1;