ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildDataUtils.pm
Revision: 1.3
Committed: Wed Feb 16 18:02:59 2005 UTC (20 years, 2 months ago) by sashby
Content type: text/plain
Branch: MAIN
Changes since 1.2: +8 -1 lines
Log Message:
First attempt at skipp function. Updates to templates.

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 sashby 1.3 # Revision: $Id: BuildDataUtils.pm,v 1.2 2004/12/10 13:41:37 sashby Exp $
8 sashby 1.2 #
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 sashby 1.3 sub skipped
76     {
77     my $self=shift;
78     # Indicate that the current package should not be considered during a build:
79     return $self->{content}->{SKIPPED};
80     }
81    
82 sashby 1.2 sub flags
83     {
84     my $self=shift;
85     # Return hash data for flags:
86     return $self->{content}->{FLAGS};
87     }
88    
89     sub allflags
90     {
91     my $self=shift;
92     # Return hash data for flags:
93     return $self->{content}->{FLAGS};
94     }
95    
96     sub makefile
97     {
98     my $self=shift;
99     # Return an array of makefile stubs:
100     return $self->{content}->{MAKEFILE};
101     }
102    
103     sub archspecific
104     {
105     my $self=shift;
106    
107     # Check to see if there is arch-dependent data. If so, return it:
108     if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
109     {
110     while (my ($k,$v) = each %{$self->{content}->{ARCH}})
111     {
112     if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
113     {
114     return $self->{content}->{ARCH}->{$k};
115     }
116     }
117     }
118     return "";
119     }
120    
121     #
122     # The routines below are used when processing the build data:
123     #
124     sub use
125     {
126     my $self=shift;
127     # Add or return uses (package deps):
128     @_ ? push(@{$self->{content}->{USE}},@_)
129     : @{$self->{content}->{USE}};
130     }
131    
132     sub group
133     {
134     my $self=shift;
135     # Add or return groups:
136     @_ ? push(@{$self->{content}->{GROUP}},@_)
137     : @{$self->{content}->{GROUP}};
138     }
139    
140     sub hasexport
141     {
142     my $self=shift;
143     # Check to see if there is a valid export block:
144     my $nkeys = $self->exporteddatatypes();
145     $nkeys > 0 ? return 1 : return 0;
146     }
147    
148     sub has
149     {
150     my $self=shift;
151     my ($datatype)=@_;
152     (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
153     }
154    
155     sub exported
156     {
157     my $self=shift;
158     # Return a hash. Keys are type of data provided:
159     return ($self->{content}->{EXPORT});
160     }
161    
162     sub exporteddatatypes
163     {
164     my $self=shift;
165     # Return exported data types:
166     return keys %{$self->{content}->{EXPORT}};
167     }
168    
169     sub defined_group
170     {
171     my $self=shift;
172     # Return a list of keys (group names) for defined groups:
173     return keys %{$self->{content}->{DEFINED_GROUP}};
174     }
175    
176     sub dataforgroup
177     {
178     my $self=shift;
179     my ($groupname)=@_;
180     # Return hash containing data for defined group
181     # $groupname or return undef:
182     return $self->{content}->{DEFINED_GROUP}->{$groupname};
183     }
184    
185     sub buildproducts
186     {
187     my $self=shift;
188     # Returns hash of build products and their data:
189     return $self->{content}->{BUILDPRODUCTS};
190     }
191    
192     sub values
193     {
194     my $self=shift;
195     my ($type)=@_;
196     # Get a list of values from known types
197     return $self->{content}->{BUILDPRODUCTS}->{$type};
198     }
199    
200     sub basic_tags()
201     {
202     my $self=shift;
203     my $datatags=[];
204     my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE BUILDPRODUCTS) ];
205     my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
206     my @all_skip_tags;
207    
208     push(@all_skip_tags,@$skiptags,@$buildtags);
209    
210     foreach my $t (keys %{$self->{content}})
211     {
212     push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
213     }
214     return @{$datatags};
215     }
216    
217     sub clean()
218     {
219     my $self=shift;
220     my (@tags) = @_;
221     # Delete some useless entries:
222     delete $self->{makefilecontent};
223     delete $self->{simpledoc};
224     delete $self->{id};
225     delete $self->{tagcontent};
226     delete $self->{nested};
227    
228     delete $self->{DEPENDENCIES};
229    
230     map
231     {
232     delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
233     } @tags;
234    
235     return $self;
236     }
237    
238     1;