Subversion Repositories DevTools

Rev

Rev 2434 | Go to most recent revision | Details | Compare with Previous | 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
 
2314 dpurdie 22
 
23
#
24
#   Directive specific globals
25
#
2326 dpurdie 26
my $MakeNsisPackage_count = 1;          # Suffix for multiple generated files
2314 dpurdie 27
my %MakeNsisPackage_names;              # Hash of used output names
28
 
1139 dpurdie 29
#-------------------------------------------------------------------------------
30
# Function        : MakeNsisPackage
31
#
32
# Description     : This directive supports the building of Windows Installers
33
#                   using NSIS. This is a script driven application
34
#
35
# Inputs          : $platform   - Pltaform selector
36
#                   @elements   - Options and arguments
37
#
38
#                   Valid Options and Arguments
39
#                       --Script=Name           - Specifies the script to use
40
#                                                 Multiple allowed
41
#                       --Verbose=n             - Specifies verbosity
42
#                       --Output=Name           - Specifies the output EXE
43
#                                                 Defaults to useful name
44
#                       --Define=Name=Value     - Send to compiler
45
#                       --Package=Name          - Use this package name instead
46
#                                                 of the build's name.
47
#                                                 Not suggested
48
#                       --Plain                 - No frills
2326 dpurdie 49
#                       --NoPackage             - Do not package the installer
1139 dpurdie 50
#
51
#
52
# Returns         : Will not return on error
53
#
54
 
55
sub MakeNsisPackage
56
{
57
    my( $platforms, @elements ) = @_;
58
    my @scripts;
59
    my $vlevel = 2;
60
    my $ofile;
61
    my @defines;
62
    my @genargs;
63
    my $package = $ScmBuildPackage;
2326 dpurdie 64
    my $noPackage;
1139 dpurdie 65
 
66
    return if ( ! ActivePlatform($platforms) );
67
 
68
    #
69
    #   Parse the command line arguments
70
    #
71
    foreach ( @elements )
72
    {
73
        if ( m~^--Script=(.+)~i ) {
74
            push @scripts, $1;
75
 
76
        } elsif  ( m~^--Verbose=(\d+)~i ) {
77
            $vlevel = $1;
78
 
79
        } elsif  ( m~^--Output=(.+)~i ) {
80
            $ofile = $1;
81
 
82
        } elsif  ( m~^--Define=(.+)~i ) {
83
            push @defines, $1;
84
 
85
        } elsif  ( m~^--Plain~i ) {
86
            push @genargs, '-Plain';
87
 
88
        } elsif  ( m~^--Package=(.+)~i ) {
89
            push @genargs, '-Package=' . $1;
90
            $package = $1;
2326 dpurdie 91
 
92
        } elsif  ( m~^--NoPackage~i ) {
93
            $noPackage = 1;
1139 dpurdie 94
 
95
        } else {
96
            Warning ("nsisDirective: Unknown option ignored: $_");
97
        }
98
    }
99
 
100
    #
101
    #   Sanity Tests
102
    #
103
    Error ("nsisDirective: No script specified" ) unless ( @scripts );
104
    $vlevel = 4 if ( $vlevel > 4 );
105
    $vlevel = 0 if ( $vlevel < 0 );
106
 
107
    #
108
    #   Create a 'nice' executable name, unless one has been provided
109
    #   Could have ${GBE_TYPE} suffix, but other windows installers don't
110
    #
111
    #   Note: Fix platform to WIN32 incase the installer is based on other
112
    #         platforms (ie: VS2005) as that would be most confusing.
113
    #         Could be based on machine type.
114
    #
2314 dpurdie 115
    $ofile = "$package-$ScmBuildVersion.$ScmBuildProject-WIN32"
116
        unless ( $ofile );
117
    $ofile .= '.exe'
118
        unless ( $ofile =~ m~\.exe$~i );
119
    Error ("MakeNsisPackage. Multiple packages with the same name: $ofile")
120
        if ( exists $MakeNsisPackage_names{$ofile} );
1139 dpurdie 121
 
122
    #
2314 dpurdie 123
    #   Create unique file name for the jats-generated file
2326 dpurdie 124
    #   Include the name of the first script
2314 dpurdie 125
    #
2326 dpurdie 126
    my $dfile = $scripts[0];
127
    $dfile =~ s~^.*/~~;
128
    $dfile =~ s~\..*?$~~;
129
    $dfile = 'JatsNsisDefs'. $MakeNsisPackage_count++ . '_' . $dfile . '.nsh';
2314 dpurdie 130
    $MakeNsisPackage_names{$ofile} = $dfile;
131
 
132
    #
1139 dpurdie 133
    #   Create build time values in a file suitable for NSIS to include
134
    #
135
    GenerateFiles ('*', '--Tool=MakeNsisDefs.pl',
136
                   '-installer=' . $ofile,
137
                   @genargs,
2314 dpurdie 138
                   '-out=--Generated('.$dfile.')' );
1139 dpurdie 139
 
140
    #
2434 dpurdie 141
    #   Invoke 'makensis' to do the hard work
1139 dpurdie 142
    #
143
    GenerateFiles ('*', 'makensis' ,
2434 dpurdie 144
                        $noPackage ? '--NoGenerate' : '--AutoGenerate',
145
                        '--Text=' . $ofile,
1139 dpurdie 146
                        '--NoVarTag',
147
                        '--UnknownPreq',
148
                        '--CreatedProg='. $ofile,
149
                        '/NOCONFIG',
150
                        '/NOCD',
151
                        '--Var(BinDir,--tag=/DGBE_BINDIR)',
152
                        '--Var(ObjDir,--tag=/DGBE_OBJDIR)',
153
                        '--Var(Target,--tag=/DGBE_TARGET)',
154
                        '--Var(Type,--tag=/DGBE_TYPE)',
155
                        (map { '/D' . $_ } @defines),
156
                        '/V' . $vlevel,
2314 dpurdie 157
                        '--Prerequisite('.$dfile.')',
1139 dpurdie 158
                        map { '--Prerequisite('.$_. ')' } @scripts,
159
                        );
160
 
161
    # Package up the EXE
162
    #
2326 dpurdie 163
    PackageFile ('*', $ofile )
164
        unless $noPackage;
1139 dpurdie 165
 
166
}
167
 
2314 dpurdie 168
1;