Subversion Repositories DevTools

Rev

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
 
2314 dpurdie 22
 
23
#
24
#   Directive specific globals
25
#
26
my $MakeNsisPackage_count = '';         # Suffix for multiple generated files
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
49
#
50
#
51
# Returns         : Will not return on error
52
#
53
 
54
sub MakeNsisPackage
55
{
56
    my( $platforms, @elements ) = @_;
57
    my @scripts;
58
    my $vlevel = 2;
59
    my $ofile;
60
    my @defines;
61
    my @genargs;
62
    my $package = $ScmBuildPackage;
63
 
64
    return if ( ! ActivePlatform($platforms) );
65
 
66
    #
67
    #   Parse the command line arguments
68
    #
69
    foreach ( @elements )
70
    {
71
        if ( m~^--Script=(.+)~i ) {
72
            push @scripts, $1;
73
 
74
        } elsif  ( m~^--Verbose=(\d+)~i ) {
75
            $vlevel = $1;
76
 
77
        } elsif  ( m~^--Output=(.+)~i ) {
78
            $ofile = $1;
79
 
80
        } elsif  ( m~^--Define=(.+)~i ) {
81
            push @defines, $1;
82
 
83
        } elsif  ( m~^--Plain~i ) {
84
            push @genargs, '-Plain';
85
 
86
        } elsif  ( m~^--Package=(.+)~i ) {
87
            push @genargs, '-Package=' . $1;
88
            $package = $1;
89
 
90
        } else {
91
            Warning ("nsisDirective: Unknown option ignored: $_");
92
        }
93
    }
94
 
95
    #
96
    #   Sanity Tests
97
    #
98
    Error ("nsisDirective: No script specified" ) unless ( @scripts );
99
    $vlevel = 4 if ( $vlevel > 4 );
100
    $vlevel = 0 if ( $vlevel < 0 );
101
 
102
    #
103
    #   Create a 'nice' executable name, unless one has been provided
104
    #   Could have ${GBE_TYPE} suffix, but other windows installers don't
105
    #
106
    #   Note: Fix platform to WIN32 incase the installer is based on other
107
    #         platforms (ie: VS2005) as that would be most confusing.
108
    #         Could be based on machine type.
109
    #
2314 dpurdie 110
    $ofile = "$package-$ScmBuildVersion.$ScmBuildProject-WIN32"
111
        unless ( $ofile );
112
    $ofile .= '.exe'
113
        unless ( $ofile =~ m~\.exe$~i );
114
    Error ("MakeNsisPackage. Multiple packages with the same name: $ofile")
115
        if ( exists $MakeNsisPackage_names{$ofile} );
1139 dpurdie 116
 
117
    #
2314 dpurdie 118
    #   Create unique file name for the jats-generated file
119
    #
120
    my $dfile = 'JatsNsisDefs'. $MakeNsisPackage_count++ .'.nsh';
121
    $MakeNsisPackage_names{$ofile} = $dfile;
122
 
123
    #
1139 dpurdie 124
    #   Create build time values in a file suitable for NSIS to include
125
    #
126
    GenerateFiles ('*', '--Tool=MakeNsisDefs.pl',
127
                   '-installer=' . $ofile,
128
                   @genargs,
2314 dpurdie 129
                   '-out=--Generated('.$dfile.')' );
1139 dpurdie 130
 
131
    #
132
    #   Invoke 'makensys' to do the hard work
133
    #
134
    GenerateFiles ('*', 'makensis' ,
135
                        '--AutoGenerate',
136
                        '--NoVarTag',
137
                        '--UnknownPreq',
138
                        '--CreatedProg='. $ofile,
139
                        '/NOCONFIG',
140
                        '/NOCD',
141
                        '--Var(BinDir,--tag=/DGBE_BINDIR)',
142
                        '--Var(ObjDir,--tag=/DGBE_OBJDIR)',
143
                        '--Var(Target,--tag=/DGBE_TARGET)',
144
                        '--Var(Type,--tag=/DGBE_TYPE)',
145
                        (map { '/D' . $_ } @defines),
146
                        '/V' . $vlevel,
2314 dpurdie 147
                        '--Prerequisite('.$dfile.')',
1139 dpurdie 148
                        map { '--Prerequisite('.$_. ')' } @scripts,
149
                        );
150
 
151
    # Package up the EXE
152
    #
153
    PackageFile ('*', $ofile );
154
 
155
}
156
 
2314 dpurdie 157
1;