Subversion Repositories DevTools

Rev

Rev 247 | Rev 261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
2
# Copyright ( C ) 2007 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
#                 The purpose of this module is to provide an interface
14
#                 between (essentially) internal data structures and user
15
#                 scripts that need to access the data. These are primarily
16
#                 deployment scripts.
17
#
18
#                 The 'All' tag is used for backward compatabilty. It simply
19
#                 exports all the known data structures. NOT to be used by new
20
#                 code.
21
#
22
#
23
#
24
# Interface     : ReadBuildConfig           - Initialise module
25
#                 getPlatformParts          - Get a list of Platform parts
26
#
27
#......................................................................#
28
 
255 dpurdie 29
require 5.006_001;
227 dpurdie 30
use strict;
31
use warnings;
32
 
33
#===============================================================================
34
package ReadBuildConfig;
35
use JatsError;
36
use JatsMakeInfo qw(:basic);
37
 
38
# automatically export what we need into namespace of caller.
39
use Exporter();
40
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK);
41
@ISA         = qw(Exporter);
42
@EXPORT      = qw(  ReadBuildConfig
43
                    getPlatformParts
44
                    getPackagePaths
45
                );
46
@EXPORT_OK =  qw(   $InterfaceVersion
47
                    $ScmBuildMachType
48
                    $ScmInterfaceVersion
49
                    $ScmBuildName
50
                    $ScmBuildPackage
51
                    $ScmBuildVersion
52
                    $ScmBuildProject
53
                    $ScmBuildVersionFull
54
                    $ScmBuildPreviousVersion
55
                    $ScmProjectSupport
56
                    $ScmSrcDir
57
                    $ScmLocal
58
                    $ScmDeploymentPatch
59
                    $ScmBuildSrc
60
                    $ScmExpert
61
                    %ScmBuildAliases
62
                    %ScmBuildProducts
63
                    %ScmBuildPlatforms
64
                    %ScmBuildPkgRules
65
                    @BUILDPLATFORMS
66
                    @DEFBUILDPLATFORMS
67
                    @BUILDTOOLSPATH
68
                    %BUILDPLATFORM_PARTS
69
                    %BUILDINFO
247 dpurdie 70
                    %BUILD_KNOWNFILES
227 dpurdie 71
                );
72
 
73
%EXPORT_TAGS = (All => [@EXPORT, @EXPORT_OK]);
74
 
75
#-------------------------------------------------------------------------------
76
#   Global variables
77
#
78
 
79
my $interface;
80
my $platform;
81
 
82
#
83
#   The $InterfaceVersion value is manually maintained
84
#   The integer part should be changed to indicate a incompatible change
85
#   to the JATS files created within the interface directory
86
#
87
#   $InterfaceVersion is treated as a float. The fractional part can be
88
#   used to indicate minor changes to the file format.
89
#
90
our $InterfaceVersion       = "2.0";            # Change will issue error message
91
 
92
#
93
#   The following varaibles are "read" in from the build.cfg file
94
#   In order to access simply access we need to declare them
95
#
96
our %BUILDINFO;
97
our %BUILDPLATFORM_PARTS;
98
our $ScmInterfaceVersion;
99
our %ScmBuildPkgRules;
100
our $ScmBuildMachType;
101
 
102
#-------------------------------------------------------------------------------
103
# Function        : ReadBuildConfig
104
#
105
# Description     : Read in the build config information
106
#                   Read in build.cfg
107
#
108
# Inputs          : $interface              - Path to the interface directory
109
#                   $platform               - Platform being processed
110
#
111
# Returns         : Nothing
112
#
113
sub ReadBuildConfig
114
{
115
    $interface = shift;
116
    $platform = shift;
117
 
118
    my $no_test;
119
    foreach  ( @_ )
120
    {
121
        if ( m/^--NoTest/i ) {
122
            $no_test = 1;
123
        } else {
124
            Warning ("ReadBuildConfig, Unknown option: $_");
125
        }
126
    }
127
 
128
    Debug("BuildConfig::Reading config, $interface");
129
    my $cfgfile = "$interface/build.cfg";
130
    Error ("JATS internal file missing. Rebuild required",
131
           "BuildConfig: Cannot find file: $cfgfile" ) unless ( -f $cfgfile );
132
 
133
    #
134
    #   Include the build.cfg data
135
    #
136
    require ( $cfgfile );
137
 
138
    #
139
    #   Ensure that the version of the interface files can be consumed
140
    #   The $ScmInterfaceVersion is a written copy of $InterfaceVersion
141
    #
142
    #   Allow build.cfg files that do not have a ScmInterfaceVersion
143
    #   Assume that these are at version 1.0.
144
    #
145
    $ScmInterfaceVersion = '1.0' unless ( $ScmInterfaceVersion );
146
    Debug ("ReadBuildConfig: Version: $ScmInterfaceVersion, Need: $InterfaceVersion");
147
    if ( int($ScmInterfaceVersion) != int($InterfaceVersion)  )
148
    {
149
        Error ("JATS interface files are not compatible with this version of JATS",
150
               "Rebuild required.",
151
               "Current Interface Version: $ScmInterfaceVersion",
152
               "JATS Interface Version   : $InterfaceVersion" );
153
    }
154
 
155
    #
156
    #   Ensure that this config file is designed for this machine type
157
    #   At make-time this test may not be valid. It should have been
158
    #   validated before make-time.
159
    #
160
    TestMachType ($ScmBuildMachType, "build.cfg") unless $no_test;
161
 
162
    #
163
    #   Remove some unused data
164
    #   Reduces the size of Makefile.cfg. Speeds up writting
165
    #
166
    if ( $platform )
167
    {
168
        for (keys %::ScmBuildPlatforms)
169
        {
170
            next if ($_ eq $platform );
171
            delete ($::BUILDPLATFORM_PARTS{$_} );
172
            delete ($::BUILDINFO{$_} );
173
            delete ($::ScmBuildPkgRules{$_} );
174
        }
175
    }
176
 
177
    #   dump
178
    #
179
    Debug( "Aliases:" );
180
    if ( ! defined(%::ScmBuildAliases) ) {
181
        Debug( "  undefined" );
182
 
183
    } else {
184
        foreach my $key (keys %::ScmBuildAliases) {
185
            my( @value ) = split( ' ', $::ScmBuildAliases{ $key } );
186
            Debug( " $key\t= @value" );
187
        }
188
    }
189
 
190
    Debug( "Products:" );
191
    if ( ! defined(%::ScmBuildProducts) ) {
192
        Debug( "  undefined" );
193
 
194
    } else {
195
        foreach my $key (keys %::ScmBuildProducts) {
196
            my( @value ) = split( ',', $::ScmBuildProducts{ $key } );
197
            Debug( " $key\t= @value" );
198
        }
199
    }
200
 
201
    Debug( "Platforms:" );
202
    if ( ! defined(%::ScmBuildPlatforms) ) {
203
        Debug( "  undefined" );
204
 
205
    } else {
206
        foreach my $key (keys %::ScmBuildPlatforms) {
207
            my( @args ) = split( /$;/, $::ScmBuildPlatforms{ $key } );
208
            Debug( " $key\t= @args" );
209
        }
210
    }
211
}
212
 
213
#-------------------------------------------------------------------------------
214
# Function        : getPlatformParts
215
#
216
# Description     : return a list of platform parts
217
#
218
# Inputs          : None
219
#
220
# Returns         : A list of platform parts to search in the interface
221
#                   directory, local directory or other
222
#
223
sub getPlatformParts
224
{
225
    Error ("BuildConfig. Not initialised") unless ( $platform );
226
    return @{$BUILDINFO{$platform}{PARTS}};
227
}
228
 
229
#-------------------------------------------------------------------------------
230
# Function        : getPackagePaths
231
#
232
# Description     : Return a list of all packages
233
#                   LinkPkgarchive packages will be provided as is
234
#                   BuildPkgArchive packages will be provided as a single
235
#                   reference to the interface directory
236
#
237
# Inputs          : Options
238
#                       --Interface=xxxx            Path to the interface dir
239
#                                                   If provided, then the path
240
#                                                   will be used for the first
241
#                                                   BuildPkgArchive
242
#                       --All                       All paths
243
#                       --Tools                     All Tools Paths
244
#                       --Gbe                       All Gbe paths
245
#
246
# Returns         : An array of paths
247
#
248
sub getPackagePaths
249
{
250
    Error ("BuildConfig. Not initialised") unless ( $platform );
251
 
252
    my $interface;
253
    my $all;
254
    my $need;
255
    my @result;
256
 
257
    #
258
    #   Parse Options
259
    #
260
    foreach ( @_ )
261
    {
262
        if ( m~^--Interface=(.+)~ ) {
263
            $interface = $1;
264
        } elsif ( m~^--All~ ) {
265
            $all = 1;
266
        } elsif ( m~^--Tools~ ) {
267
            $need = 'TOOLDIRS';
268
        } elsif ( m~^--Gbe~ ) {
269
            $need = 'CFGDIR';
270
        } else {
271
            Error ("BuildConfig. Unknown Option: $_");
272
        }
273
    }
274
 
275
    #
276
    #   Locate rqeuired entries
277
    #
278
    for my $entry (@{$ScmBuildPkgRules{$platform} })
279
    {
280
        #
281
        #   Do we need this entry
282
        #   Select tools and gbe entries
283
        #
284
        my @subdirs = '/';
285
        if ( $need )
286
        {
287
            next unless ( exists ($entry->{$need} ) );
288
            my $subdir = $entry->{$need};
289
            if ( ref($subdir) eq 'ARRAY' ) {
290
                @subdirs = @{$subdir};
291
            } else {
292
                @subdirs = $subdir;
293
            }
294
        }
295
 
296
        #
297
        #   If a BuildPkgArchive, then give the interface dir, unless
298
        #   we need all the true paths
299
        #
300
        if ( ($entry->{'TYPE'} eq 'build' ) && !$all )
301
        {
302
            if ( $interface )
303
            {
304
                push @result, $interface;
305
                $interface = '';
306
            }
307
        }
308
        else
309
        {
310
            foreach my $subdir ( @subdirs )
311
            {
312
                my $dir = $entry->{'ROOT'} . $subdir;
313
                $dir =~ s~/+~/~g;
314
                $dir =~ s~/+$~~g;
315
                push @result, $dir;
316
            }
317
        }
318
    }
319
 
320
    return @result;
321
}
322
 
323
#------------------------------------------------------------------------------
324
1;