Subversion Repositories DevTools

Rev

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