Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1532 dpurdie 1
########################################################################
2
# Copyright ( C ) 2006 ERG Limited, All rights reserved
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats build system
8
#
9
# Description   : Provide access to information from the build.pl file as parsed
10
#                 by JATS. This is more complete than the parser in the
11
#                 "BuildFile.pm"
12
#
13
#                 This class is used by deploylib.pm, and we can ensure that JATS
14
#                 has parsed the build.pl file
15
#
16
#......................................................................#
17
 
18
require 5.6.1;
19
use strict;
20
use warnings;
21
use Data::Dumper;
22
 
23
#===============================================================================
24
package DeployUtils::BuildConfig;
1534 dpurdie 25
use JatsError;
1532 dpurdie 26
 
27
# automatically export what we need into namespace of caller.
28
use Exporter();
29
our (@ISA, @EXPORT);
30
@ISA         = qw(Exporter);
31
@EXPORT      = qw( );
32
 
33
 
34
#
35
#   The following varaibles are "read" in from the build.cfg file
36
#   In order to access thme we need to declare them
37
#
38
our %ScmBuildPkgRules;
39
our %BUILDPLATFORM_PARTS;
40
 
41
#-------------------------------------------------------------------------------
42
# Function        : new constructor
43
#
44
# Description     : Create a new instance of the BuildConfig class
45
#
46
# Inputs          : $obclass                - Class Name,
47
#                   $buildFile              - Path to the root directory
48
#                   $Platform               - Desirect target platform
49
#
50
# Returns         : Class reference
51
#
52
sub new
53
{
54
    my $obclass = shift;
55
    my $class = ref($obclass) || $obclass;
56
    my $buildPath = shift;
57
    my $Platform = shift;
58
 
1534 dpurdie 59
    Debug("BuildFile::new Instantiating new object of class $class");
1532 dpurdie 60
    bless my $self = {
61
        _BUILDPATH          => $buildPath,
62
        _PLATFORM           => $Platform,
63
        _DPKGARCHIVE        => {},
64
    } => ( $class );
65
 
66
    #
67
    #   Insert required information
68
    #   Read in the build.cfg file as parsed by JATS - this is the real deal
69
    #
70
    readCfg( $buildPath );
71
 
72
#    $self->dumpSelf();
73
    return($self);
74
}   # new
75
 
76
#-------------------------------------------------------------------------------
77
# Function        : readCfg
78
#
79
# Description     : Read in the build.cfg file
80
#                   This file contains complete parse information from the JATS
81
#                   build.pl file parser. This is much more complete than the
82
#                   simplistic parser in BuildFile.pm
83
#
84
#                   build.cfg is read within the context of a package to contain
85
#                   the variables that are added to the namespace.
86
#
87
# Inputs          : RootDir         - Root directory
88
#                                     Expect to find interface/build.cfg
89
#
90
# Returns         : Nothing
91
#
92
sub readCfg
93
{
94
    my ($RootDir) = @_;
95
 
96
    #
97
    #   Current assumption is that the build.cfg file is within a directory
98
    #   named 'inerface'. This is not strictly true as the name of the directory
99
    #   is specified in the build.pl file. We could hunt for it.
100
    #
101
    my $cfgfile = "$RootDir/interface/build.cfg";
1534 dpurdie 102
    Error ("Cannot find file: $cfgfile" ) unless ( -f $cfgfile );
1532 dpurdie 103
 
104
    #
105
    #   Include the build.cfg data
106
    #
107
 
108
    require ( $cfgfile );
109
}
110
 
111
 
112
#-------------------------------------------------------------------------------
113
# Function        : getDpkgArchiveHash
114
#
115
# Description     : Create a hash to describe the external packages as declared
116
#                   with LinkPkgArchive or BuildPkgArchive directives
117
#
118
#                   This is a compatability function
119
#                   The hash is usef by the user written deployfile.pl's
120
#                   This is ugly, and not good, but that is what has been done
121
#
122
# Inputs          : None
123
#
124
# Returns         : A hash of the form:
125
#
126
#                        {$module}{type}
127
#                        {$module}{version}
128
#                        {$module}{versionFull}
129
#                        {$module}{proj}
130
#
131
#
132
sub getDpkgArchiveHash
133
{
134
    my $self = shift;
135
 
136
    foreach my $entry ( @{$ScmBuildPkgRules{$self->{_PLATFORM}}} )
137
    {
138
 
139
        my $module = $entry->{'DNAME'};
140
        my $ref = $self->{_DPKGARCHIVE};
141
 
142
        $ref->{$module}{'type'}           = $entry->{'TYPE'} =~ /build/ ? 'BuildPkgArchive' : 'LinkPkgArchive';
143
        $ref->{$module}{'version'}        = $entry->{'DVERSION'};
144
        $ref->{$module}{'versionFull'}    = $entry->{'VERSION'};
145
        $ref->{$module}{'proj'}           = $entry->{'DPROJ'};
146
    }
147
 
148
    return %{$self->{_DPKGARCHIVE}};
149
}
150
 
151
 
152
#-------------------------------------------------------------------------------
153
# Function        : getDpkgArchiveInfo
154
#
155
# Description     : Get the DpkgArchiveHash entry for a given module
156
#
157
# Inputs          : $module     - name of the module
158
#
159
# Returns         : Entry
160
#
161
sub getDpkgArchiveInfo
162
{
163
    my $self = shift;
164
    my $module = shift;
165
 
166
    if ( ! defined($module) || ! defined($self->{_DPKGARCHIVE}{$module}) )
167
    {
168
        return undef;
169
    }
170
    else
171
    {
172
        return \%{$self->{_DPKGARCHIVE}{$module}};
173
    }
174
}
175
 
176
#-------------------------------------------------------------------------------
177
# Function        : getDpkgArchiveList
178
#
179
# Description     : returns a list of Modules in the DpkgArchive Hash
180
#
181
# Inputs          : None
182
#
183
# Returns         : A sorted list
184
#
185
sub getDpkgArchiveList
186
{
187
    my $self = shift;
188
 
189
    return sort keys %{$self->{_DPKGARCHIVE}};
190
}
191
 
192
#-------------------------------------------------------------------------------
193
# Function        : getPlatformParts
194
#
195
# Description     : return a list of platform parts
196
#
197
# Inputs          : None
198
#
199
# Returns         : A list
200
#
201
sub getPlatformParts
202
{
203
    my $self = shift;
204
 
205
    return @{$BUILDPLATFORM_PARTS{$self->{_PLATFORM}}};
206
}
207
 
208
#-------------------------------------------------------------------------------
209
# Function        : getBuildPkgRules
210
#
211
# Description     : Return a list of BuildPkgRules for the specified platform
212
#
213
# Description     : return a list of platform parts
214
#
215
# Inputs          : None
216
#
217
# Returns         : A list
218
#
219
sub getBuildPkgRules
220
{
221
    my $self = shift;
222
 
223
    return @{$ScmBuildPkgRules{$self->{_PLATFORM}}};
224
}
225
 
226
#-------------------------------------------------------------------------------
227
# Function        : dumpSelf
228
#
229
# Description     : Dump the class internals
230
#
231
# Inputs          : None
232
#
233
# Returns         : Nothing
234
#
235
sub dumpSelf
236
{
237
    my $self = shift;
238
 
239
    print Data::Dumper->Dump([$self], [ref($self)]);
240
}
241
 
242
#------------------------------------------------------------------------------
243
1;