Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
1139 dpurdie 1
########################################################################
2
# Copyright (C) 2010 Vix-ERG Limited, All rights reserved
3
#
4
# Module name   : nsisDirective.pm
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Provides the 'nsisDirective' directive to JATS
10
#
11
# Usage         : See Below
12
#
13
#......................................................................#
14
 
15
require 5.008_002;
16
use strict;
17
use warnings;
18
use JatsError;
19
 
20
our $ScmPlatform;                       # Target Platform
21
 
22
#-------------------------------------------------------------------------------
23
# Function        : MakeNsisPackage
24
#
25
# Description     : This directive supports the building of Windows Installers
26
#                   using NSIS. This is a script driven application
27
#
28
# Inputs          : $platform   - Pltaform selector
29
#                   @elements   - Options and arguments
30
#
31
#                   Valid Options and Arguments
32
#                       --Script=Name           - Specifies the script to use
33
#                                                 Multiple allowed
34
#                       --Verbose=n             - Specifies verbosity
35
#                       --Output=Name           - Specifies the output EXE
36
#                                                 Defaults to useful name
37
#                       --Define=Name=Value     - Send to compiler
38
#                       --Package=Name          - Use this package name instead
39
#                                                 of the build's name.
40
#                                                 Not suggested
41
#                       --Plain                 - No frills
42
#
43
#
44
# Returns         : Will not return on error
45
#
46
 
47
sub MakeNsisPackage
48
{
49
    my( $platforms, @elements ) = @_;
50
    my @scripts;
51
    my $vlevel = 2;
52
    my $ofile;
53
    my @defines;
54
    my @genargs;
55
    my $package = $ScmBuildPackage;
56
 
57
    return if ( ! ActivePlatform($platforms) );
58
 
59
    #
60
    #   Parse the command line arguments
61
    #
62
    foreach ( @elements )
63
    {
64
        if ( m~^--Script=(.+)~i ) {
65
            push @scripts, $1;
66
 
67
        } elsif  ( m~^--Verbose=(\d+)~i ) {
68
            $vlevel = $1;
69
 
70
        } elsif  ( m~^--Output=(.+)~i ) {
71
            $ofile = $1;
72
 
73
        } elsif  ( m~^--Define=(.+)~i ) {
74
            push @defines, $1;
75
 
76
        } elsif  ( m~^--Plain~i ) {
77
            push @genargs, '-Plain';
78
 
79
        } elsif  ( m~^--Package=(.+)~i ) {
80
            push @genargs, '-Package=' . $1;
81
            $package = $1;
82
 
83
        } else {
84
            Warning ("nsisDirective: Unknown option ignored: $_");
85
        }
86
    }
87
 
88
    #
89
    #   Sanity Tests
90
    #
91
    Error ("nsisDirective: No script specified" ) unless ( @scripts );
92
    $vlevel = 4 if ( $vlevel > 4 );
93
    $vlevel = 0 if ( $vlevel < 0 );
94
 
95
    #
96
    #   Create a 'nice' executable name, unless one has been provided
97
    #   Could have ${GBE_TYPE} suffix, but other windows installers don't
98
    #
99
    #   Note: Fix platform to WIN32 incase the installer is based on other
100
    #         platforms (ie: VS2005) as that would be most confusing.
101
    #         Could be based on machine type.
102
    #
103
    unless ( $ofile )
104
    {
105
        $ofile = "$package-$ScmBuildVersion.$ScmBuildProject-WIN32";
106
    }
107
    $ofile .= '.exe' unless ( $ofile =~ m~\.exe$~i );
108
 
109
    #
110
    #   Create build time values in a file suitable for NSIS to include
111
    #
112
    GenerateFiles ('*', '--Tool=MakeNsisDefs.pl',
113
                   '-installer=' . $ofile,
114
                   @genargs,
115
                   '-out=--Generated(JatsNsisDefs.nsh)' );
116
 
117
    #
118
    #   Invoke 'makensys' to do the hard work
119
    #
120
    GenerateFiles ('*', 'makensis' ,
121
                        '--AutoGenerate',
122
                        '--NoVarTag',
123
                        '--UnknownPreq',
124
                        '--CreatedProg='. $ofile,
125
                        '/NOCONFIG',
126
                        '/NOCD',
127
                        '--Var(BinDir,--tag=/DGBE_BINDIR)',
128
                        '--Var(ObjDir,--tag=/DGBE_OBJDIR)',
129
                        '--Var(Target,--tag=/DGBE_TARGET)',
130
                        '--Var(Type,--tag=/DGBE_TYPE)',
131
                        (map { '/D' . $_ } @defines),
132
                        '/V' . $vlevel,
133
                        '--Prerequisite(JatsNsisDefs.nsh)',
134
                        map { '--Prerequisite('.$_. ')' } @scripts,
135
                        );
136
 
137
    # Package up the EXE
138
    #
139
    PackageFile ('*', $ofile );
140
 
141
}
142