Rev 2434 | Blame | Compare with Previous | Last modification | View Log | RSS feed
######################################################################### Copyright (C) 2010 Vix-ERG Limited, All rights reserved## Module name : nsisDirective.pm# Module type : Makefile system# Compiler(s) : Perl# Environment(s): jats## Description : Provides the 'nsisDirective' directive to JATS## Usage : See Below##......................................................................#require 5.008_002;use strict;use warnings;use JatsError;our $ScmPlatform; # Target Platform## Directive specific globals#my $MakeNsisPackage_count = 1; # Suffix for multiple generated filesmy %MakeNsisPackage_names; # Hash of used output names#-------------------------------------------------------------------------------# Function : MakeNsisPackage## Description : This directive supports the building of Windows Installers# using NSIS. This is a script driven application## Inputs : $platform - Pltaform selector# @elements - Options and arguments## Valid Options and Arguments# --Script=Name - Specifies the script to use# Multiple allowed# --Verbose=n - Specifies verbosity# --Output=Name - Specifies the output EXE# Defaults to useful name# --Define=Name=Value - Send to compiler# --Package=Name - Use this package name instead# of the build's name.# Not suggested# --Plain - No frills# --NoPackage - Do not package the installer# --RecipeTag=name - Tag this recipe# --PkgArch=arch - Override default architecture# Default WIN32 or X64### Returns : Will not return on error#sub MakeNsisPackage{my( $platforms, @elements ) = @_;my @scripts;my $vlevel = 2;my $ofile;my @defines;my @genargs;my $package = $ScmBuildPackage;my $noPackage;my @passThroughArgs;my $pkgArch = GetGlobalOption('PACKAGE_ARCH', 'WIN32');return if ( ! ActivePlatform($platforms) );## Parse the command line arguments#foreach ( @elements ){if ( m~^--Script=(.+)~i ) {push @scripts, $1;} elsif ( m~^--Verbose=(\d+)~i ) {$vlevel = $1;} elsif ( m~^--Output=(.+)~i ) {$ofile = $1;} elsif ( m~^--Define=(.+)~i ) {push @defines, $1;} elsif ( m~^--Plain~i ) {push @genargs, '-Plain';} elsif ( m~^--Package=(.+)~i ) {push @genargs, '-Package=' . $1;$package = $1;} elsif ( m~^--NoPackage~i ) {$noPackage = 1;} elsif ( m~^--RecipeTag=~i ) {push @passThroughArgs, $_;} elsif ( m~^--PkgArch=(.+)~i ) {$pkgArch = $1;} else {Warning ("nsisDirective: Unknown option ignored: $_");}}## Sanity Tests#Error ("nsisDirective: No script specified" ) unless ( @scripts );Error ("PkgArch is not specified") unless (defined $pkgArch && (length($pkgArch) > 0));$vlevel = 4 if ( $vlevel > 4 );$vlevel = 0 if ( $vlevel < 0 );## Create a 'nice' executable name, unless one has been provided# Could have ${GBE_TYPE} suffix, but other windows installers don't## Note: Fix platform to WIN32 incase the installer is based on other# platforms (ie: VS2005) as that would be most confusing.# Could be based on machine type.#$ofile = "$package-$ScmBuildVersion.$ScmBuildProject-$pkgArch"unless ( $ofile );$ofile .= '.exe'unless ( $ofile =~ m~\.exe$~i );Error ("MakeNsisPackage. Multiple packages with the same name: $ofile")if ( exists $MakeNsisPackage_names{$ofile} );## Create unique file name for the jats-generated file# Include the name of the first script#my $dfile = $scripts[0];$dfile =~ s~^.*/~~;$dfile =~ s~\..*?$~~;$dfile = 'JatsNsisDefs'. $MakeNsisPackage_count++ . '_' . $dfile . '.nsh';$MakeNsisPackage_names{$ofile} = $dfile;## Create build time values in a file suitable for NSIS to include#push @genargs, '-PkgArch=' . $pkgArch;GenerateFiles ('*', '--Tool=MakeNsisDefs.pl','-installer=' . $ofile,@genargs,'-out=--Generated('.$dfile.')' );## Invoke 'makensis' to do the hard work#GenerateFiles ('*', 'makensis' ,$noPackage ? '--NoGenerate' : '--AutoGenerate','--Text=' . $ofile,@passThroughArgs,'--NoVarTag','--UnknownPreq','--CreatedProg='. $ofile,'/NOCONFIG','/NOCD','--Var(BinDir,--tag=/DGBE_BINDIR)','--Var(ObjDir,--tag=/DGBE_OBJDIR)','--Var(Target,--tag=/DGBE_TARGET)','--Var(Type,--tag=/DGBE_TYPE)',(map { '/D' . $_ } @defines),'/V' . $vlevel,'--Prerequisite('.$dfile.')',map { '--Prerequisite('.$_. ')' } @scripts,);# Package up the EXE#PackageFile ('*', $ofile )unless $noPackage;}1;