Subversion Repositories DevTools

Rev

Rev 255 | Rev 361 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 267
Line 1... Line -...
1
#! /usr/bin/perl
-
 
2
########################################################################
1
########################################################################
3
# Copyright (C) 1998-2004 ERG Limited, All rights reserved
2
# Copyright (C) 1998-2004 ERG Limited, All rights reserved
4
#
3
#
5
# Module name   : gen_winrc.pl
4
# Module name   : gen_winrc.pl
6
# Module type   : Makefile system
5
# Module type   : Makefile system
7
# Compiler(s)   : n/a
6
# Compiler(s)   : n/a
8
# Environment(s):
7
# Environment(s):
9
#
8
#
10
# Description   : A script to generate a RC file
9
# Description   : A script to generate a RC file
-
 
10
#                 Provided for backward compatablity only
-
 
11
#                 Use BuildVersion ( '--Style=WinRc', ... );
-
 
12
#
11
#                 The script will:
13
#                 The script will:
12
#                   Take user options
14
#                   Take user options
13
#
-
 
14
#                   Create a .rc file
15
#                   Create a .rc file
15
#
16
#
16
#
-
 
17
# Version   Who      Date        Description
-
 
18
# 1.0.0     DDP      20-Jul-04   Created
-
 
19
#
-
 
20
#......................................................................#
17
#......................................................................#
21
 
18
 
22
require 5.006_001;
19
require 5.006_001;
23
use strict;
20
use strict;
24
use warnings;
21
use warnings;
25
 
22
 
26
use JatsError;
23
use JatsError;
-
 
24
use BuildVersion;
27
use Getopt::Long;
25
use Getopt::Long;
28
use Pod::Usage;                             # required for help support
26
use Pod::Usage;                             # required for help support
29
use Cwd;
27
use Cwd;
30
 
28
 
31
my $VERSION = "1.1.0";                      # Update this
29
my $VERSION = "1.2.0";                      # Update this
32
 
30
 
33
#
31
#
34
#   Options
32
#   Options
35
#
33
#
36
my $opt_outfile;
34
my $opt_outfile;
Line 41... Line 39...
41
my $opt_description;
39
my $opt_description;
42
my $opt_defs_only;
40
my $opt_defs_only;
43
my $opt_icon;
41
my $opt_icon;
44
 
42
 
45
my $opt_help = 0;
43
my $opt_help = 0;
46
my $opt_manual = 0;
-
 
47
my $opt_debug   = $ENV{'GBE_DEBUG'}     || 0;      # Allow global debug
44
my $opt_debug   = $ENV{'GBE_DEBUG'}     || 0;      # Allow global debug
48
my $opt_verbose = $ENV{'GBE_VERBOSE'}   || 0;      # Allow global verbose
45
my $opt_verbose = $ENV{'GBE_VERBOSE'}   || 0;      # Allow global verbose
49
 
46
 
50
 
-
 
51
#
47
#
52
#   Global variables
48
#   Global variables
-
 
49
#   Used to allow the re-use of BuildVersion.pm
53
#
50
#
54
my $file_version;
-
 
55
my $product_version;
51
our $CurrentYear;
56
 
-
 
57
my $current_time = localtime;
52
our $CurrentTime;
58
my ($sec,$min,$hour,$mday,$mon,$lyear,$wday,$yday,$isdst) = localtime();
-
 
59
my $year = $lyear + 1900;
53
our $BuildVersion;
60
 
54
 
61
#-------------------------------------------------------------------------------
55
#-------------------------------------------------------------------------------
62
# Entry           : Main program entry
56
# Entry           : Main program entry
63
#
57
#
64
# Inputs          : Options and arguments on the command line
58
# Inputs          : Options and arguments on the command line
65
#
59
#
66
my $result = GetOptions (
60
my $result = GetOptions (
67
                "help+"         => \$opt_help,
61
                "help:+"        => \$opt_help,
68
                "manual"        => \$opt_manual,
62
                "manual:3"      => \$opt_help,
69
                "verbose+"      => \$opt_verbose,
63
                "verbose:+"     => \$opt_verbose,
70
 
64
 
71
                "out:s"         => \$opt_outfile,
65
                "out:s"         => \$opt_outfile,
72
                "version:s"     => \$opt_version,
66
                "version:s"     => \$opt_version,
73
                "comment:s"     => \$opt_comment,
67
                "comment:s"     => \$opt_comment,
74
                "product:s"     => \$opt_product,
68
                "product:s"     => \$opt_product,
Line 86... Line 80...
86
#
80
#
87
#   Process help and manual options
81
#   Process help and manual options
88
#
82
#
89
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
83
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
90
pod2usage(-verbose => 1)  if ($opt_help == 2 );
84
pod2usage(-verbose => 1)  if ($opt_help == 2 );
91
pod2usage(-verbose => 2)  if ($opt_manual || $opt_help > 2);
85
pod2usage(-verbose => 2)  if ($opt_help > 2);
92
 
86
 
93
#
87
#
94
#   Configure the Error reporting process now that we have the user options
88
#   Configure the Error reporting process now that we have the user options
95
#
89
#
96
ErrorConfig( 'name'    =>'GENRC', 'verbose' => $opt_verbose );
90
ErrorConfig( 'name'    =>'GENRC', 'verbose' => $opt_verbose );
Line 108... Line 102...
108
Error ("No output file specified")  unless ( $opt_outfile );
102
Error ("No output file specified")  unless ( $opt_outfile );
109
Error ("No version specified")      unless ( $opt_version );
103
Error ("No version specified")      unless ( $opt_version );
110
Error ("No name specified")         unless ( $opt_name );
104
Error ("No name specified")         unless ( $opt_name );
111
 
105
 
112
#
106
#
-
 
107
#   Use BuildVersionWinRC to do the hard work
113
#   Process arguments
108
#   Create an option call list for this function
114
#
109
#
115
#   File and product versions
-
 
116
#       These appear to be comma delemited numbers
-
 
117
#       Base this in the user version string
-
 
118
#       Allow for build number embedded in the patch number
-
 
119
#       Allow for 4 field version number
-
 
120
#
-
 
121
#   Allow for   nn.nn.nn                - Force nn.nn.nn.0
-
 
122
#   and         nn.nn.nn.nn
110
my @args = '--ToolUse';
123
#
-
 
124
 
-
 
125
my ($major, $minor, $patch, $build ) = split ('\.', $opt_version);
111
push @args, "--Version=$opt_version"  if ( $opt_version );
126
 
-
 
127
    #
-
 
128
    #   Decode the patch number and extract the build number
-
 
129
    #   Need to know the the length of the user string to decode
-
 
130
    #   Those less than three digits are build 0
-
 
131
    #
-
 
132
    if ( ! defined ($build) )
-
 
133
    {
-
 
134
        $build = 0;
-
 
135
        if ( length( $patch) >= 4 )
-
 
136
        {
-
 
137
            $build = substr( $patch, -3 ,3);
-
 
138
            $patch = substr( $patch,  0 ,length($patch)-3);
-
 
139
        }
-
 
140
    }
-
 
141
 
-
 
142
$product_version = $file_version =  "$major, $minor, $patch, $build";
-
 
143
 
-
 
144
#
-
 
145
#   Generate the output file
-
 
146
#
-
 
147
open ( RC, ">$opt_outfile" ) || Error ("Cannot open output: $opt_outfile");
-
 
148
 
-
 
149
#--------- Auto-generated Configuration -------------------------------------
-
 
150
# -*- mode: perl; tabs: 8; -*-
-
 
151
#
-
 
152
#                   -- Please do not edit this file. --
-
 
153
#
-
 
154
# Generated from GBE_BUILDLIB=${ARGV[1]} (version $BuildVersion)
-
 
155
#           on   $CurrentTime
-
 
156
#
-
 
157
# Makelib configuration file
-
 
158
#
-
 
159
 
-
 
160
 
-
 
161
prc     ("/////////////////////////////////////////////////////////////////////////////");
-
 
162
prc     ("//");
-
 
163
prc     ("//    GENERATED FILE. DO NOT EDIT");
-
 
164
prc     ("//");
-
 
165
prc     ("//    Generated on: $current_time");
112
push @args, "--Comment=$opt_comment"  if ( $opt_comment );
166
prc     ("//");
-
 
167
prc     ("//");
-
 
168
prc     ("");
-
 
169
prc     ("#include \"afxres.h\"");
-
 
170
prc     ("");
-
 
171
prc     ("");
-
 
172
pdefs   ("RC_STR_EMPTY"         , "" );
-
 
173
pdefs   ("RC_STR_COMPANY"       , "ERG Group" );
-
 
174
pdefs   ("RC_STR_PRODUCTNAME"   , $opt_product );
113
push @args, "--Product=$opt_product"  if ( $opt_product );
175
pdefs   ("RC_STR_COMMENT"       , $opt_comment );
114
push @args, "--PkgName=$opt_name"     if ( $opt_name );
176
pdefs   ("RC_STR_DESCRIPTION"   , $opt_description );
115
push @args, "--Description=$opt_description"  if ( $opt_description );
177
pdefs   ("RC_STR_NAME"          , $opt_name );
-
 
178
pdefs   ("RC_STR_VERSION"       , $product_version );
116
push @args, "--Definitions"  if ( $opt_defs_only );
179
pdef    ("RC_NUM_VERSION"       , $product_version );
117
push @args, "--Icon=$opt_icon"     if ( $opt_icon );
180
pdefs   ("RC_STR_COPYRIGHT"     , "Copyright ERG Group $year" );
-
 
181
prc     ('#ifdef _DEBUG');
-
 
182
pdefs   ("RC_STR_SPECIAL"       , "Debug Version" );
-
 
183
prc     ('#else');
-
 
184
pdefs   ("RC_STR_SPECIAL"       , "Production Version" );
-
 
185
prc     ('#endif');
-
 
186
prc     ("");
-
 
187
 
-
 
188
unless ( $opt_defs_only )
-
 
189
{
-
 
190
    prc     ('');
-
 
191
    prc     ('VS_VERSION_INFO VERSIONINFO');
-
 
192
    prc     (' FILEVERSION      RC_NUM_VERSION');
-
 
193
    prc     (' PRODUCTVERSION   RC_NUM_VERSION');
-
 
194
    prc     (' FILEFLAGSMASK 0x3fL');
-
 
195
    prc     ('#ifdef _DEBUG');
-
 
196
    prc     (' FILEFLAGS 0x1L');
-
 
197
    prc     ('#else');
-
 
198
    prc     (' FILEFLAGS 0x0L');
-
 
199
    prc     ('#endif');
-
 
200
    prc     (' FILEOS 0x40004L');
-
 
201
    prc     (' FILETYPE 0x1L');
-
 
202
    prc     (' FILESUBTYPE 0x0L');
-
 
203
    prc     ('BEGIN');
-
 
204
    prc     ('    BLOCK "StringFileInfo"');
-
 
205
    prc     ('    BEGIN');
-
 
206
    prc     ('        BLOCK "0c0904b0"');
-
 
207
    prc     ('        BEGIN');
-
 
208
    prc     ('            VALUE "Comments",         RC_STR_COMMENT');
-
 
209
    prc     ('            VALUE "CompanyName",      RC_STR_COMPANY');
-
 
210
    prc     ('            VALUE "FileDescription",  RC_STR_DESCRIPTION');
-
 
211
    prc     ('            VALUE "FileVersion",      RC_STR_VERSION');
-
 
212
    prc     ('            VALUE "InternalName",     RC_STR_NAME');
-
 
213
    prc     ('            VALUE "LegalCopyright",   RC_STR_COPYRIGHT');
-
 
214
    prc     ('            VALUE "LegalTrademarks",  RC_STR_EMPTY');
-
 
215
    prc     ('            VALUE "OriginalFilename", RC_STR_EMPTY');
-
 
216
    prc     ('            VALUE "PrivateBuild",     RC_STR_EMPTY');
-
 
217
    prc     ('            VALUE "ProductName",      RC_STR_PRODUCTNAME');
-
 
218
    prc     ('            VALUE "ProductVersion",   RC_STR_EMPTY');
-
 
219
    prc     ('            VALUE "SpecialBuild",     RC_STR_SPECIAL');
-
 
220
    prc     ('        END');
-
 
221
    prc     ('    END');
-
 
222
    prc     ('        BLOCK "VarFileInfo"');
-
 
223
    prc     ('        BEGIN');
-
 
224
    prc     ('            VALUE "Translation", 0xc09, 1200');
-
 
225
    prc     ('        END');
-
 
226
    prc     ('END');
-
 
227
    prc     ('');
-
 
228
 
-
 
229
    if ( $opt_icon )
-
 
230
    {
-
 
231
    prc     ('');
-
 
232
    prc     ('/////////////////////////////////////////////////////////////////////////////');
-
 
233
    prc     ('//');
-
 
234
    prc     ('// Icon');
-
 
235
    prc     ('//');
-
 
236
    prc     ('// Icon with lowest ID value placed first to ensure application icon');
-
 
237
    prc     ('// remains consistent on all systems.');
-
 
238
    prc     ("101       ICON    DISCARDABLE     \"$opt_icon\"");
-
 
239
    prc     ('');
-
 
240
    }
-
 
241
}
-
 
242
 
-
 
243
prc     ("// End of File //////////////////////////////////////////////////////////////");
-
 
244
 
-
 
245
close (RC);
-
 
246
exit 0;
-
 
247
 
118
 
248
#-------------------------------------------------------------------------------
-
 
249
# Function        : prc
-
 
250
#
119
#
-
 
120
#   Keep the Module Happy
251
# Description     : Print a line to the RC file
121
#   Provide globals used by the module
252
#
122
#
-
 
123
$CurrentTime = localtime;
-
 
124
my ($sec, $min, $hour, $mday, $mon, $year) = localtime();
253
# Inputs          : Line to print
125
$CurrentYear = 1900 + $year;
-
 
126
$BuildVersion = 'Unknown';
-
 
127
 
254
#
128
#
-
 
129
#   Invoke the same class used by the jats build process to create
255
# Returns         :
130
#   the Resource File.
256
#
131
#
257
sub prc
-
 
258
{
-
 
259
    print RC "@_\n";
-
 
260
}
-
 
261
 
-
 
262
sub pdefs
-
 
263
{
-
 
264
    my ($arg, $val) = @_;
-
 
265
    $val = "" unless ( $val );
-
 
266
    print RC "#define $arg \"$val\\0\"\n";
-
 
267
 
132
 
268
}
-
 
269
 
-
 
270
sub pdef
-
 
271
{
-
 
272
    my ($arg, $val) = @_;
-
 
273
    print RC "#define $arg $val\n";
133
BuildVersionWinRC ( $opt_outfile, @args );
274
}
134
exit 0;
275
 
135
 
-
 
136
#-------------------------------------------------------------------------------
-
 
137
#   Documentation
-
 
138
#
276
 
139
 
277
=pod
140
=pod
278
 
141
 
279
=head1 NAME
142
=head1 NAME
280
 
143