Subversion Repositories DevTools

Rev

Rev 255 | Rev 361 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2004 ERG Limited, All rights reserved
3
#
4
# Module name   : gen_winrc.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s):
8
#
9
# Description   : A script to generate a RC file
267 dpurdie 10
#                 Provided for backward compatablity only
11
#                 Use BuildVersion ( '--Style=WinRc', ... );
12
#
227 dpurdie 13
#                 The script will:
14
#                   Take user options
15
#                   Create a .rc file
16
#
17
#......................................................................#
18
 
255 dpurdie 19
require 5.006_001;
227 dpurdie 20
use strict;
21
use warnings;
22
 
23
use JatsError;
267 dpurdie 24
use BuildVersion;
227 dpurdie 25
use Getopt::Long;
26
use Pod::Usage;                             # required for help support
27
use Cwd;
28
 
267 dpurdie 29
my $VERSION = "1.2.0";                      # Update this
227 dpurdie 30
 
31
#
32
#   Options
33
#
34
my $opt_outfile;
35
my $opt_version;
36
my $opt_comment;
37
my $opt_product;
38
my $opt_name;
39
my $opt_description;
40
my $opt_defs_only;
41
my $opt_icon;
42
 
43
my $opt_help = 0;
44
my $opt_debug   = $ENV{'GBE_DEBUG'}     || 0;      # Allow global debug
45
my $opt_verbose = $ENV{'GBE_VERBOSE'}   || 0;      # Allow global verbose
46
 
47
#
48
#   Global variables
267 dpurdie 49
#   Used to allow the re-use of BuildVersion.pm
227 dpurdie 50
#
267 dpurdie 51
our $CurrentYear;
52
our $CurrentTime;
53
our $BuildVersion;
227 dpurdie 54
 
55
#-------------------------------------------------------------------------------
56
# Entry           : Main program entry
57
#
58
# Inputs          : Options and arguments on the command line
59
#
60
my $result = GetOptions (
267 dpurdie 61
                "help:+"        => \$opt_help,
62
                "manual:3"      => \$opt_help,
63
                "verbose:+"     => \$opt_verbose,
227 dpurdie 64
 
65
                "out:s"         => \$opt_outfile,
66
                "version:s"     => \$opt_version,
67
                "comment:s"     => \$opt_comment,
68
                "product:s"     => \$opt_product,
69
                "name:s"        => \$opt_name,
70
                "description:s" => \$opt_description,
71
                "definitions"   => \$opt_defs_only,
72
                "icon:s"        => \$opt_icon,
73
 
74
                );
75
 
76
                #
77
                #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
78
                #
79
 
80
#
81
#   Process help and manual options
82
#
83
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
84
pod2usage(-verbose => 1)  if ($opt_help == 2 );
267 dpurdie 85
pod2usage(-verbose => 2)  if ($opt_help > 2);
227 dpurdie 86
 
87
#
88
#   Configure the Error reporting process now that we have the user options
89
#
90
ErrorConfig( 'name'    =>'GENRC', 'verbose' => $opt_verbose );
91
 
92
#
93
#   Validate user options
94
#   Not expecting any user arguments, other than options, so spit if any are found
95
#
96
Error ("Unexpected command line arguments present" )
97
    if ( $#ARGV >= 0 );
98
 
99
#
100
#   Sanity test of user arguments
101
#
102
Error ("No output file specified")  unless ( $opt_outfile );
103
Error ("No version specified")      unless ( $opt_version );
104
Error ("No name specified")         unless ( $opt_name );
105
 
106
#
267 dpurdie 107
#   Use BuildVersionWinRC to do the hard work
108
#   Create an option call list for this function
227 dpurdie 109
#
267 dpurdie 110
my @args = '--ToolUse';
111
push @args, "--Version=$opt_version"  if ( $opt_version );
112
push @args, "--Comment=$opt_comment"  if ( $opt_comment );
113
push @args, "--Product=$opt_product"  if ( $opt_product );
114
push @args, "--PkgName=$opt_name"     if ( $opt_name );
115
push @args, "--Description=$opt_description"  if ( $opt_description );
116
push @args, "--Definitions"  if ( $opt_defs_only );
117
push @args, "--Icon=$opt_icon"     if ( $opt_icon );
227 dpurdie 118
 
119
#
267 dpurdie 120
#   Keep the Module Happy
121
#   Provide globals used by the module
227 dpurdie 122
#
267 dpurdie 123
$CurrentTime = localtime;
124
my ($sec, $min, $hour, $mday, $mon, $year) = localtime();
125
$CurrentYear = 1900 + $year;
126
$BuildVersion = 'Unknown';
227 dpurdie 127
 
128
#
267 dpurdie 129
#   Invoke the same class used by the jats build process to create
130
#   the Resource File.
227 dpurdie 131
#
132
 
267 dpurdie 133
BuildVersionWinRC ( $opt_outfile, @args );
227 dpurdie 134
exit 0;
135
 
136
#-------------------------------------------------------------------------------
267 dpurdie 137
#   Documentation
227 dpurdie 138
#
139
 
140
=pod
141
 
142
=head1 NAME
143
 
144
gen_winrc.pl - Generate a Windows RC file
145
 
146
=head1 SYNOPSIS
147
 
148
 gen_winrc.pl [arguments] ...
149
 
150
 Arguments:
151
    -help                   - brief help message
152
    -help -help             - Detailed help message
153
    -man                    - Full documentation
154
    -verbose                - Verbose information
155
 
156
   Mandatory
157
    -out file               - Name of the output file
158
    -version nn.nn.nn       - Release version
159
    -name string            - Program Name
160
 
161
  Optional
162
    -comment string         - Comment string
163
    -description string     - Description string
164
    -definitions            - Only generate the definitions
165
    -icon filename          - The name of an icon file
166
 
167
=head1 OPTIONS
168
 
169
=over 8
170
 
171
=item B<-help>
172
 
173
Print a brief help message and exits.
174
 
175
=item B<-help -help>
176
 
177
Print a detailed help message with an explanation for each option.
178
 
179
=item B<-man>
180
 
181
Prints the manual page and exits.
182
 
183
=item B<-verbose>
184
 
185
Increase the level of debugging information displayed. This option may be used
186
multiple times.
187
 
188
=item B<-out file>
189
 
190
Specifies the name of the output file. The option is mandatory.
191
 
192
=item B<-version nn.nn.nn>
193
 
194
Specify the version to include include in the resource file. This must be of
195
the form nn.nn.nn, where nn is a decimal digit.
196
 
197
Within a JATS makefile the value of $ScmBuildVersion may be used.
198
 
199
The option is mandatory.
200
 
201
=item B<-name string>
202
 
203
Specify the name of the program. The option is mandatory.
204
 
205
Within a JATS makefile the value of $ScmBuildPackage may be used.
206
 
207
=item B<-comment string>
208
 
209
Specify an optional comment string. If the string contains whitespace then item
210
should be enclosed in quotes.
211
 
212
=item B<-description string>
213
 
214
Specify an optional description string. If the string contains whitespace then item
215
should be enclosed in quotes.
216
 
217
=item B<-definitions>
218
 
219
This option will only write out a file that contains the definitions. The body
220
of the resource script will not be generated. The file that is generated may
221
be included within another resource file.
222
 
223
=item B<-icon filename>
224
 
225
This option will add the specified icon file to the resource being created.
226
The icon will appear against the DLL.
227
 
228
=back
229
 
230
=head1 DESCRIPTION
231
 
232
B<This program> will generate a basic Windows resource file to contains the
233
program name and version number. The resulting file may then be included in
234
another resource file, or used directly to generate a basic program resource.
235
 
236
=head1 EXAMPLE
237
 
238
=head2 Used within makefile.pl - Basic
239
 
240
    GenerateFiles ('WIN32', "--Tool=gen_winrc.pl",
241
                            "-out --GeneratedCommon(prog.rc)",
242
                            "-version=$ScmBuildVersion",
243
                            "-comment='This is a comment'",
244
                            "-name=$ScmBuildPackage",
245
                            "-description='This is a description'",
246
                            "--NoWarn" );
247
 
248
    Prog          ( '*'    , "MyProg", @OBJS );
249
    Prog          ( 'WIN32', "MyProg", "--Resource=prog.rc" );
250
 
251
The resource script will be generated with basic information. It can then be
252
added to the program or DLL as required.
253
 
254
=cut