Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1031 dpurdie 1
########################################################################
2
# Copyright (C) 2008 ERG Limited, All rights reserved
3
#
4
# Module name   : GenerateCab.pm
5
# Module type   : JATS Plugin
6
# Compiler(s)   : PERL
7
# Environment(s): JATS
8
#
9
# Description   : This package extends the JATS toolset at build time
10
#                 It provides additional directives to the JATS makefiles
11
#                 to simplify the directives.
12
#
13
#                 The directive matches up with a run-time tool to
14
#                 do the bulk of the work.
15
#
16
# Operation     : This package adds the JATS directive GenerateCab
17
#                 When used the directive will use GenerateFiles to invoke
18
#                 a script (CabWiz.pl) to actually do the hard work.
19
#
20
# Syntax        : GenerateCab (<platforms>, InfFile, [options]);
21
#                 Options:
22
#                   --Cab=name
23
#                   --Platform=name
24
#                   --PackageFile
25
#                   --PackageProg
26
#                   --Verbose[=n]
27
#
28
#......................................................................#
29
 
30
require 5.006_001;
31
use strict;
32
use warnings;
33
 
34
our @CABS;                              # Create global list OF generated CABS
35
our $ScmPlatform;                       # Target Platform
36
 
37
#-------------------------------------------------------------------------------
38
# Function        : GenerateCab
39
#
40
# Description     : Create a CAB file
41
#
42
# Inputs          : $platforms          - Platform selector
43
#                   $inf_file           - Input INF file
44
#                   Options
45
#                       --Cab=Name      - Cab Filename
46
#                       --Platform=name - Optional platform name
47
#                       --PackageProg   - Package as Program
48
#                       --PackageFile   - Package as File
49
#                       --Verbose[=n]   - Runtime debugging
50
#
51
# Returns         : Nothing
52
#
53
sub GenerateCab
54
{
55
    my( $platforms, $inf_file, @opts ) = @_;
56
    my $pname;
57
    my $verbose;
58
    my $cab_file;
59
    my $package_prog;
60
    my $package_file;
61
 
62
    Debug2( "GenerateCab", @_ );
63
    return if ( ! ActivePlatform($platforms) );
64
 
65
    #
66
    #   Extract options
67
    #
68
    foreach  ( @opts )
69
    {
70
        if ( m~^--Platform=(.+)~i ) {
71
            $pname = $1;
72
 
73
        } elsif ( m~^--Verbose=(\d+)~i ) {
74
            $verbose = $1;
75
 
76
        } elsif ( m~^--Verbose~i ) {
77
            $verbose = 1;
78
 
79
        } elsif ( m~^--Cab=(.+)~i ) {
80
            $cab_file = $1;
81
 
82
        } elsif ( m~^--PackageProg~i ) {
83
            $package_prog = 1;
84
 
85
        } elsif ( m~^--PackageFile~i ) {
86
            $package_file = 1;
87
 
88
        } else {
89
            Error ("GenerateCab: Unknown option: $_");
90
        }
91
    }
92
 
93
    #
94
    #   Sanity Test
95
    #
96
    Error ("GenerateCab: No INF file provided") unless ( $inf_file );
97
 
98
    #
99
    #   Insert defaults
100
    #   Create a CAB file in the same format as other deployed files
101
    #
102
    unless ( $cab_file )
103
    {
104
        $cab_file = "$ScmBuildPackage-$ScmBuildVersion.$ScmBuildProject-$ScmPlatform-\$(GBE_TYPE).cab";
105
        $package_file = 1 unless ( $package_prog );
106
    }
107
 
108
    #
109
    #   Simply use Generate Files
110
    #   With lots of options
111
    #
112
    Src ( '*', $inf_file );
113
 
114
    #
115
    #   Create an array of optional comamnd arguments
116
    #
117
    my @cmd;
118
    push @cmd, "-verbose=$verbose" if ( $verbose );
119
    push @cmd, "-platform_name=$pname" if ( $pname );
120
 
121
    GenerateFiles ('*', '--Tool=cabwiz.pl',
122
                    '--AutoGenerate',
123
                    '--Clean',
124
                    '--Var(InterfaceDir)',
125
                    '--Var(LocalDir)',
126
                    '--Var(Platform)',
127
                    '--Var(Type)',
128
                    "-inf --Prerequisite{$inf_file}",
129
                    "-out --Generated{$cab_file}",
130
                    @cmd,
131
                    );
132
 
133
    #
134
    #   The Packager has created a binary in the 'OBJ' directory
135
    #   Lets package it as a program.
136
    #
137
    PackageProg ('*', $cab_file ) if $package_prog;
138
    PackageFile ('*', $cab_file ) if $package_file;
139
 
140
    push @CABS, $cab_file;
141
}
142
 
143
1;