Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 dpurdie 1
#! /usr/bin/perl
2
########################################################################
5709 dpurdie 3
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
392 dpurdie 4
#
5
# Module name   : jats_deploy.pl
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s):
9
#
10
# Description   : This script is run via the JATS wrapper script
11
#                 The script will setup an environment suitable for the
12
#                 processing of the deployfile.pl script
13
#
14
#                 NOTE:
15
#                 Appears to be the start of something.
16
#                   Don't know where Deploy.cfg is generated or what it
17
#                   might contain.
18
#
19
#                   Dosn't actually call the deployfile. Perhaps that was the
20
#                   next step.
21
#
22
#......................................................................#
23
 
24
require 5.006_001;
25
use strict;
26
use warnings;
27
use JatsError;
28
 
29
use Data::Dumper;                           # Debug only
30
use Pod::Usage;                             # required for help support
31
use Getopt::Long;
32
use Cwd;
33
 
34
my $VERSION = "1.0.0";                      # Update this
35
 
36
#
37
#   Options
38
#
39
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
40
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
41
my $opt_help = 0;
42
my $opt_manual = 0;
43
 
44
#
45
#   Globals
46
#
47
my $GBE_PERL     = $ENV{'GBE_PERL'};        # Essential ENV variables
48
my $GBE_CORE     = $ENV{'GBE_CORE'};
49
my $USER         = $ENV{'USER'};
50
my $GBE_MACHTYPE = $ENV{'GBE_MACHTYPE'};
51
 
52
#
53
#   Imported Globals (configuration)
54
#
55
our @deploy_cf_args;
56
our $ScmBuildName;
57
our $ScmBuildPackage;
58
our $ScmBuildVersion;
59
our $ScmBuildVersionFull;
60
our $ScmBuildProject;
61
our $ScmBuildPreviousVersion;
62
our $ScmSrcDir;
63
our @BUILDPLATFORMS;
64
our %ScmBuildAliases;
65
our @DEFBUILDPLATFORMS;
66
our %ScmBuildPlatforms;
67
our %BUILDPLATFORM_PARTS;
68
 
69
#
70
#   Working variables
71
#
72
my $deployfile;
73
 
74
#-------------------------------------------------------------------------------
75
# Function        : Mainline Entry Point
76
#
77
# Description     :
78
#
79
# Inputs          :
80
#
81
my $result = GetOptions (
82
                "help+"         => \$opt_help,              # flag, multiple use allowed
83
                "manual"        => \$opt_manual,            # flag, multiple use allowed
84
                "verbose+"      => \$opt_verbose,           # flag, multiple use allowed
85
                );
86
 
87
                #
88
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
89
                #
90
 
91
#
92
#   Process help and manual options
93
#
94
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
95
pod2usage(-verbose => 1)  if ($opt_help == 2 );
96
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
97
 
98
#
99
#   Configure the error reporting process now that we have the user options
100
#
101
ErrorConfig( 'name'    =>'DEPLOY',
102
             'verbose' => $opt_verbose,
103
             'debug'   => $opt_debug
104
             );
105
 
106
#
107
#   Validate user options
108
#
109
 
110
#
111
#   Locate the JATS generated data file
112
#   This will be in the "interface" directory, or if this directory does not
113
#   exist the file will be found in the current directory. The name of the
114
#   interface directory is not well defined. It may be called interface
115
#   but it may not. It will be one directory below the build directory.
116
#
117
#   The data file can be "require"ed directly by Perl.
118
#
119
my $idir;
120
opendir (DIR, "." ) or Error( "Cannot open the current directory");
121
while ( $_ = readdir( DIR ) )
122
{
123
    next if ( $_ =~ m/\./ );
124
    next unless ( -d $_ );
125
    if ( -f "$_/Build.cfg" )
126
    {
127
        Verbose ("Search for Build.cfg in: $_");
128
        Warning( "Multiple interface directories located" )
129
            if ( $idir );
130
        $idir = $_;
131
    }
132
}
133
closedir DIR;
134
Error ("No suitable interface directory located") unless defined($idir);
135
 
136
#
137
#   Read in the general Build.cfg data and the Deploy.cfg data
138
#
139
#for (qw(Build.cfg Deploy.cfg))
140
for (qw( Build.cfg ))
141
{
142
    my $fname = $_;
143
    $fname = "$idir/$_" unless ( -f $_ );
144
    Verbose ("Check for: $fname");
145
    Error( "Cannot locate $fname") unless ( -f $fname );
146
    require $fname;
147
}
148
 
149
#
150
#   Display useful information
151
#
152
if ( $opt_verbose )
153
{
154
    print "Build Parameters\n";
155
    print "     ScmBuildName             $::ScmBuildName\n";
156
    print "     ScmBuildPackage          $::ScmBuildPackage\n";
157
    print "     ScmBuildVersion          $::ScmBuildVersion\n";
158
    print "     ScmBuildProject          $::ScmBuildProject\n";
159
    print "     ScmBuildVersionFull      $::ScmBuildVersionFull\n";
160
    print "     ScmBuildPreviousVersion  $::ScmBuildPreviousVersion\n";
161
    print "     ScmSrcDir                $::ScmSrcDir\n";
162
 
163
 
164
    print "\nBuildDeploy Arguments\n";
165
    foreach (@::deploy_cf_args )
166
    {
167
        print "     $_\n";
168
    }
169
}
170
 
171
#
172
#   Locate the deployfile.pl
173
#   This MUST be in the directory specified ScmSrcDir or the build directory
174
#
175
foreach ( ".", $::ScmSrcDir )
176
{
177
    next unless( -f "$_/deployfile.pl" );
178
    Warning("Multiple deployfile.pl file found") if ( $deployfile );
179
    $deployfile = "$_/deployfile.pl";
180
}
181
 
182
Error("deployfile.pl not found")
183
    unless ( $deployfile );
184
Verbose("Deployment script: $deployfile" );
185
 
186
#
187
#   Invoke the deployfile.pl for each required platform
188
#   The platforms have been specified by the user on the command line
189
#
190
#   There are some special processing rules (largely to look like make )
191
#
192
#       all         - process all default platforms
193
#       XXXX        - process production and debug for XXXX
194
#       XXXX_debug  - process debug for XXXX
195
#       XXXX_prod   - process production for XXXX
196
#
197
if ( $#ARGV < 0  )
198
{
199
    #
200
    #   Display a list of available comamnd targets
201
    #
202
    print "Available platforms include:\n";
203
    print "     all, debug, prod\n";
204
    print "     " . join ( ', ', @::DEFBUILDPLATFORMS) . "\n";
205
 
206
    print "\n";
207
    Warning("Nothing to do" );
208
}
209
 
210
foreach my $platform ( @ARGV )
211
{
212
    my $gdebug = 1;
213
    my $gprod = 1;
214
    my @platform_list;
215
 
216
    #
217
    #   Extract _prod and _debug information
218
    #
219
    $gprod = 0  if ( $platform =~ m/_debug$/ );
220
    $gdebug = 0 if ( $platform =~ m/_prod$/ );
221
    $platform =~ s/_debug$|_prod$//;
222
 
223
    #
224
    #   Create a list of platforms to process
225
    #
226
    if ( $platform eq 'all' ) {
227
        @platform_list = @::DEFBUILDPLATFORMS;
228
        Verbose ("Alias of all: @platform_list");
229
 
230
    } elsif ( defined $::ScmBuildAliases{$platform} ) {
231
        #
232
        #   Remove options from the Alias list to leave platforms
233
        #
234
        @platform_list = grep{!/^--/} split( ' ', $::ScmBuildAliases{$platform});
235
        Verbose ("Alias of $platform: @platform_list");
236
 
237
    } else {
238
        my $found;
239
        foreach  ( @::BUILDPLATFORMS )
240
        {
241
            if ( $_ eq $platform )
242
            {
243
                $found++;
244
                last;
245
            }
246
        }
247
        Error( "Platform not known: $platform")
248
            unless ( $found );
249
 
250
        push @platform_list, $platform;
251
    }
252
 
253
    #
254
    #   Process each platform in the list
255
    #   These may need to be done for both the debug and production flavor
256
    #   Examine the platform arguments to pickup build specified limits
257
    #
258
    foreach my $platform ( @platform_list )
259
    {
260
        #
261
        #   Process platform arguments looking for OnlyProd and OnlyDebug
262
        #   This will then modify the global user request
263
        #
264
        my $debug = $gdebug;
265
        my $prod = $gprod;
266
 
267
        my @platform_ops = split( "$;", $::ScmBuildPlatforms{$platform} );
268
        foreach  ( @platform_ops )
269
        {
270
            $prod = 0 if ( m/^--OnlyDebug/ );
271
            $debug = 0 if ( m/^--OnlyProd/ )
272
        }
273
        Verbose( "Platform: $platform, debug:$debug, Prod:$prod");
274
        process_platform( $platform, "D" ) if ( $debug );
275
        process_platform( $platform, "P" ) if ( $prod );
276
        Warning ("Nothing to do for: $platform") unless ( $debug || $prod );
277
    }
278
}
279
 
280
#-------------------------------------------------------------------------------
281
# Function        : process_platform
282
#
283
# Description     : Perform processing for one platform
284
#
285
# Inputs          : $platform       - platform to process
286
#                   $type           - P or D
287
#
288
# Returns         : Nothing
289
#
290
sub process_platform
291
{
292
    my( $platform, $type ) = @_;
293
    my @parts = @{$BUILDPLATFORM_PARTS{$platform}};
294
 
295
    my $target = $parts[-1];            # Last one is the target
296
    my $product = $parts[1];            # 2nd one is the product
297
 
298
    print "---- Processing $platform ($product, $target), $type\n";
299
 
300
 
301
    system ( $GBE_PERL,
302
            '-w',  $deployfile,                 # File to process
303
		    '-r', '.' ,                         # Root directory
304
		    '-n', $::ScmBuildName,              # Package Name
305
		    '-d', lc($::ScmBuildName),          # Directory
306
		    '-v', $::ScmBuildVersionFull,       # Build version
307
		    '-t', $type,                        # Build type
308
		    '-o', $::ScmBuildPreviousVersion,   # Previous Version
309
		    '-m', $platform,                    # Platform
310
		    '-g', $target,                      # Target
311
		    '-k', $product );                   # Product
312
 
313
}
314
 
315
#-------------------------------------------------------------------------------
316
#   Documentation
317
#
318
 
319
=pod
320
 
321
=head1 NAME
322
 
323
jats_deploy - Process deployfile.pl's
324
 
325
=head1 SYNOPSIS
326
 
327
  jats deploy [options] action
328
 
329
 Options:
330
    -help              - brief help message
331
    -help -help        - Detailed help message
332
    -man               - Full documentation
333
    -verbose           - Generate verbose output
334
 
335
 Actions:
336
    all                 - Debug and Production builds
337
    debug               - Debug build of all platform
338
    prod                - Production build of all platforms
339
    other*              - Specify a single platform. Optional _prod or _debug
340
 
341
=head1 OPTIONS
342
 
343
=over 8
344
 
345
=item B<-help>
346
 
347
Print a brief help message and exits.
348
 
349
=item B<-help -help>
350
 
351
Print a detailed help message with an explanation for each option.
352
 
353
=item B<-man>
354
 
355
Prints the manual page and exits.
356
 
357
=item B<-verbose>
358
 
359
Incresed the level of output generated by the program.
360
 
361
=back
362
 
363
=head1 DESCRIPTION
364
 
365
This program is the primary tool for the invocation of the deployfile.pl scripts
366
 
367
In normal operation the program will:
368
 
369
=over 8
370
 
371
=item Setup the environment
372
 
373
Read the deploy.cfg file from the interface directory.
374
 
375
=item Locate and execute the deployfile.pl
376
 
377
This file MUST be located in the primary source directory. The same directory
378
as the top level makefile.
379
 
5542 dpurdie 380
=back
381
 
392 dpurdie 382
=cut
383