Subversion Repositories DevTools

Rev

Rev 267 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

########################################################################
# Copyright (C) 1998-2004 ERG Limited, All rights reserved
#
# Module name   : gen_winrc.pl
# Module type   : Makefile system
# Compiler(s)   : n/a
# Environment(s):
#
# Description   : A script to generate a RC file
#                 Provided for backward compatablity only
#                 Use BuildVersion ( '--Style=WinRc', ... );
#
#                 The script will:
#                   Take user options
#                   Create a .rc file
#
#......................................................................#

require 5.006_001;
use strict;
use warnings;

use JatsError;
use BuildVersion;
use Getopt::Long;
use Pod::Usage;                             # required for help support
use Cwd;

my $VERSION = "1.2.0";                      # Update this

#
#   Options
#
my $opt_outfile;
my $opt_version;
my $opt_comment;
my $opt_product;
my $opt_name;
my $opt_description;
my $opt_defs_only;
my $opt_icon;

my $opt_help = 0;
my $opt_debug   = $ENV{'GBE_DEBUG'}     || 0;      # Allow global debug
my $opt_verbose = $ENV{'GBE_VERBOSE'}   || 0;      # Allow global verbose

#
#   Global variables
#   Used to allow the re-use of BuildVersion.pm
#
our $CurrentYear;
our $CurrentTime;
our $BuildVersion;

#-------------------------------------------------------------------------------
# Entry           : Main program entry
#
# Inputs          : Options and arguments on the command line
#
my $result = GetOptions (
                "help:+"        => \$opt_help,
                "manual:3"      => \$opt_help,
                "verbose:+"     => \$opt_verbose,

                "out:s"         => \$opt_outfile,
                "version:s"     => \$opt_version,
                "comment:s"     => \$opt_comment,
                "product:s"     => \$opt_product,
                "name:s"        => \$opt_name,
                "description:s" => \$opt_description,
                "definitions"   => \$opt_defs_only,
                "icon:s"        => \$opt_icon,
                
                );

                #
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
                #

#
#   Process help and manual options
#
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
pod2usage(-verbose => 1)  if ($opt_help == 2 );
pod2usage(-verbose => 2)  if ($opt_help > 2);

#
#   Configure the Error reporting process now that we have the user options
#
ErrorConfig( 'name'    =>'GENRC', 'verbose' => $opt_verbose );

#
#   Validate user options
#   Not expecting any user arguments, other than options, so spit if any are found
#
Error ("Unexpected command line arguments present" )
    if ( $#ARGV >= 0 );

#
#   Sanity test of user arguments
#
Error ("No output file specified")  unless ( $opt_outfile );
Error ("No version specified")      unless ( $opt_version );
Error ("No name specified")         unless ( $opt_name );

#
#   Use BuildVersionWinRC to do the hard work
#   Create an option call list for this function
#
my @args = '--ToolUse';
push @args, "--Version=$opt_version"  if ( $opt_version );
push @args, "--Comment=$opt_comment"  if ( $opt_comment );
push @args, "--Product=$opt_product"  if ( $opt_product );
push @args, "--PkgName=$opt_name"     if ( $opt_name );
push @args, "--Description=$opt_description"  if ( $opt_description );
push @args, "--Definitions"  if ( $opt_defs_only );
push @args, "--Icon=$opt_icon"     if ( $opt_icon );

#
#   Keep the Module Happy
#   Provide globals used by the module
#
$CurrentTime = localtime;
my ($sec, $min, $hour, $mday, $mon, $year) = localtime();
$CurrentYear = 1900 + $year;
$BuildVersion = 'Unknown';

#
#   Invoke the same class used by the jats build process to create
#   the Resource File.
#

BuildVersionWinRC ( $opt_outfile, @args );
exit 0;

#-------------------------------------------------------------------------------
#   Documentation
#

=pod

=for htmltoc    MAKEUTIL::

=head1 NAME

gen_winrc.pl - Generate a Windows RC file

=head1 SYNOPSIS

 gen_winrc.pl [arguments] ...

 Arguments:
    -help                   - brief help message
    -help -help             - Detailed help message
    -man                    - Full documentation
    -verbose                - Verbose information

   Mandatory
    -out file               - Name of the output file
    -version nn.nn.nn       - Release version
    -name string            - Program Name

  Optional
    -comment string         - Comment string
    -description string     - Description string
    -definitions            - Only generate the definitions
    -icon filename          - The name of an icon file

=head1 OPTIONS

=over 8

=item -help

Print a brief help message and exits.

=item -help -help

Print a detailed help message with an explanation for each option.

=item -man

Prints the manual page and exits.

=item -verbose

Increase the level of debugging information displayed. This option may be used
multiple times.

=item -out file

Specifies the name of the output file. The option is mandatory.

=item -version nn.nn.nn

Specify the version to include include in the resource file. This must be of
the form nn.nn.nn, where nn is a decimal digit.

Within a JATS makefile the value of $ScmBuildVersion may be used.

The option is mandatory.

=item -name string

Specify the name of the program. The option is mandatory.

Within a JATS makefile the value of $ScmBuildPackage may be used.

=item -comment string

Specify an optional comment string. If the string contains whitespace then item
should be enclosed in quotes.

=item -description string

Specify an optional description string. If the string contains whitespace then item
should be enclosed in quotes.

=item -definitions

This option will only write out a file that contains the definitions. The body
of the resource script will not be generated. The file that is generated may
be included within another resource file.

=item -icon filename

This option will add the specified icon file to the resource being created.
The icon will appear against the DLL.

=back

=head1 DESCRIPTION

This program will generate a basic Windows resource file that contains the
program name and version number. The resulting file may then be included in
another resource file, or used directly to generate a basic program resource.

=for htmlclass Note

Note: Use of this utility has been deprecated in favour of the BuildVersion
directive that performs the same operation with a simpler interface.

=head1 EXAMPLE

=head2 Used within makefile.pl - Basic

    GenerateFiles ('WIN32', "--Tool=gen_winrc.pl",
                            "-out --GeneratedCommon(prog.rc)",
                            "-version=$ScmBuildVersion",
                            "-comment='This is a comment'",
                            "-name=$ScmBuildPackage",
                            "-description='This is a description'",
                            "--NoWarn" );

    Prog          ( '*'    , "MyProg", @OBJS );
    Prog          ( 'WIN32', "MyProg", "--Resource=prog.rc" );

The resource script will be generated with basic information. It can then be
added to the program or DLL as required.

=cut