######################################################################## # Copyright (C) 2008 ERG Limited, All rights reserved # # Module name : GenerateCab.pm # Module type : JATS Plugin # Compiler(s) : PERL # Environment(s): JATS # # Description : This package extends the JATS toolset at build time # It provides additional directives to the JATS makefiles # to simplify the directives. # # The directive matches up with a run-time tool to # do the bulk of the work. # # Operation : This package adds the JATS directive GenerateCab # When used the directive will use GenerateFiles to invoke # a script (CabWiz.pl) to actually do the hard work. # # Syntax : GenerateCab (, InfFile, [options]); # Options: # --Cab=name # --Platform=name # --PackageFile # --PackageProg # --Verbose[=n] # #......................................................................# require 5.006_001; use strict; use warnings; our @CABS; # Create global list OF generated CABS our $ScmPlatform; # Target Platform #------------------------------------------------------------------------------- # Function : GenerateCab # # Description : Create a CAB file # # Inputs : $platforms - Platform selector # $inf_file - Input INF file # Options # --Cab=Name - Cab Filename # --Platform=name - Optional platform name # --PackageProg - Package as Program # --PackageFile - Package as File # --Verbose[=n] - Runtime debugging # # Returns : Nothing # sub GenerateCab { my( $platforms, $inf_file, @opts ) = @_; my $pname; my $verbose; my $cab_file; my $package_prog; my $package_file; Debug2( "GenerateCab", @_ ); return if ( ! ActivePlatform($platforms) ); # # Extract options # foreach ( @opts ) { if ( m~^--Platform=(.+)~i ) { $pname = $1; } elsif ( m~^--Verbose=(\d+)~i ) { $verbose = $1; } elsif ( m~^--Verbose~i ) { $verbose = 1; } elsif ( m~^--Cab=(.+)~i ) { $cab_file = $1; } elsif ( m~^--PackageProg~i ) { $package_prog = 1; } elsif ( m~^--PackageFile~i ) { $package_file = 1; } else { Error ("GenerateCab: Unknown option: $_"); } } # # Sanity Test # Error ("GenerateCab: No INF file provided") unless ( $inf_file ); # # Insert defaults # Create a CAB file in the same format as other deployed files # unless ( $cab_file ) { $cab_file = "$ScmBuildPackage-$ScmBuildVersion.$ScmBuildProject-$ScmPlatform-\$(GBE_TYPE).cab"; $package_file = 1 unless ( $package_prog ); } # # Simply use Generate Files # With lots of options # Src ( '*', $inf_file ); # # Create an array of optional comamnd arguments # my @cmd; push @cmd, "-verbose=$verbose" if ( $verbose ); push @cmd, "-platform_name=$pname" if ( $pname ); GenerateFiles ('*', '--Tool=cabwiz.pl', '--AutoGenerate', '--Clean', '--Var(InterfaceDir)', '--Var(LocalDir)', '--Var(Platform)', '--Var(Type)', "-inf --Prerequisite{$inf_file}", "-out --Generated{$cab_file}", @cmd, ); # # The Packager has created a binary in the 'OBJ' directory # Lets package it as a program. # PackageProg ('*', $cab_file ) if $package_prog; PackageFile ('*', $cab_file ) if $package_file; push @CABS, $cab_file; } 1;