ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildDataUtils.pm
Revision: 1.2
Committed: Fri Dec 10 13:41:37 2004 UTC (20 years, 4 months ago) by sashby
Content type: text/plain
Branch: MAIN
CVS Tags: V1_0_0
Changes since 1.1: +231 -0 lines
Log Message:
Merged V1_0 branch to HEAD

File Contents

# User Rev Content
1 sashby 1.2 #____________________________________________________________________
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.1.2.7 2004/10/01 10:09:39 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     # Return a list of keys (group names) for defined groups:
166     return keys %{$self->{content}->{DEFINED_GROUP}};
167     }
168    
169     sub dataforgroup
170     {
171     my $self=shift;
172     my ($groupname)=@_;
173     # Return hash containing data for defined group
174     # $groupname or return undef:
175     return $self->{content}->{DEFINED_GROUP}->{$groupname};
176     }
177    
178     sub buildproducts
179     {
180     my $self=shift;
181     # Returns hash of build products and their data:
182     return $self->{content}->{BUILDPRODUCTS};
183     }
184    
185     sub values
186     {
187     my $self=shift;
188     my ($type)=@_;
189     # Get a list of values from known types
190     return $self->{content}->{BUILDPRODUCTS}->{$type};
191     }
192    
193     sub basic_tags()
194     {
195     my $self=shift;
196     my $datatags=[];
197     my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE BUILDPRODUCTS) ];
198     my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
199     my @all_skip_tags;
200    
201     push(@all_skip_tags,@$skiptags,@$buildtags);
202    
203     foreach my $t (keys %{$self->{content}})
204     {
205     push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
206     }
207     return @{$datatags};
208     }
209    
210     sub clean()
211     {
212     my $self=shift;
213     my (@tags) = @_;
214     # Delete some useless entries:
215     delete $self->{makefilecontent};
216     delete $self->{simpledoc};
217     delete $self->{id};
218     delete $self->{tagcontent};
219     delete $self->{nested};
220    
221     delete $self->{DEPENDENCIES};
222    
223     map
224     {
225     delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
226     } @tags;
227    
228     return $self;
229     }
230    
231     1;