| 227 |
dpurdie |
1 |
# -*- mode: perl; tabs: 4; -*-
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 227 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : gen_packagelist.pl
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
#
|
|
|
7 |
# Description : Create several lists of files based on the current
|
|
|
8 |
# imported packages.
|
|
|
9 |
#
|
|
|
10 |
# Creates:
|
|
|
11 |
# list of all include paths
|
|
|
12 |
# list of all libraries (if WIN32 target)
|
|
|
13 |
#
|
|
|
14 |
# This implemenation relies on a complex datafile being generated
|
|
|
15 |
# by the JATS build scripts.
|
|
|
16 |
#
|
|
|
17 |
#
|
|
|
18 |
# Version Who Date Description
|
|
|
19 |
# DDP 12-Oct-04 Created
|
|
|
20 |
#............................................................................#
|
|
|
21 |
|
| 255 |
dpurdie |
22 |
require 5.006_001;
|
| 227 |
dpurdie |
23 |
use strict;
|
|
|
24 |
use warnings;
|
|
|
25 |
|
|
|
26 |
use Data::Dumper; # Debug only
|
|
|
27 |
use Pod::Usage; # required for help support
|
|
|
28 |
use Getopt::Long;
|
|
|
29 |
|
|
|
30 |
#
|
|
|
31 |
# Global variables
|
|
|
32 |
#
|
|
|
33 |
my $VERSION = "2.0.3"; # Update this
|
|
|
34 |
our %ScmBuildPkgRules;
|
|
|
35 |
my $opt_help = 0;
|
|
|
36 |
my $opt_manual;
|
|
|
37 |
my $opt_verbose;
|
|
|
38 |
my $opt_target = "WIN32"; # Default target
|
|
|
39 |
my $inc_prefix = "";
|
|
|
40 |
my @opt_exclude_lib;
|
|
|
41 |
my @opt_exclude_package;
|
|
|
42 |
my %exclude_lib;
|
|
|
43 |
my %exclude_package;
|
|
|
44 |
my $win32_target;
|
|
|
45 |
|
|
|
46 |
my $result = GetOptions (
|
|
|
47 |
"help+" => \$opt_help, # flag, multiple use allowed
|
|
|
48 |
"manual" => \$opt_manual, # flag, multiple use allowed
|
|
|
49 |
"verbose+" => \$opt_verbose, # flag, multiple use allowed
|
|
|
50 |
"nolib=s" => \@opt_exclude_lib, # Multiple strings
|
|
|
51 |
"nopackage=s" => \@opt_exclude_package, # Multiple strings
|
|
|
52 |
"target=s" => \$opt_target, # Single string
|
|
|
53 |
);
|
|
|
54 |
|
|
|
55 |
#
|
|
|
56 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
57 |
#
|
|
|
58 |
|
|
|
59 |
#
|
|
|
60 |
# Process help and manual options
|
|
|
61 |
#
|
|
|
62 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
63 |
pod2usage(-verbose => 1) if ($opt_help == 2 );
|
|
|
64 |
pod2usage(-verbose => 2) if ($opt_manual || ($opt_help > 2));
|
|
|
65 |
|
|
|
66 |
#
|
|
|
67 |
# Massage input options
|
|
|
68 |
# Allow a comma seperated list of exclude options
|
|
|
69 |
#
|
|
|
70 |
@opt_exclude_lib = split( /,/,join(',',@opt_exclude_lib));
|
|
|
71 |
foreach ( @opt_exclude_lib )
|
|
|
72 |
{
|
|
|
73 |
$exclude_lib{$_} = 1;
|
|
|
74 |
print "Exclude library: $_\n";
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
@opt_exclude_package = split( /,/,join(',',@opt_exclude_package));
|
|
|
78 |
foreach ( @opt_exclude_package )
|
|
|
79 |
{
|
|
|
80 |
$exclude_package{$_} = 1;
|
|
|
81 |
print "Exclude package: $_\n";
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
################################################################################
|
|
|
86 |
# Locate the JATS generated data file
|
|
|
87 |
# This will be in the "interface" directory, or if this directory does not
|
|
|
88 |
# exist the file will be found in the current directory
|
|
|
89 |
#
|
|
|
90 |
# The data file can be "require"ed directly by Perl. The data will be
|
|
|
91 |
# conatined with a few cf_xxxx hashes
|
|
|
92 |
#
|
|
|
93 |
for (qw(build.cfg))
|
|
|
94 |
{
|
|
|
95 |
my $fname = $_;
|
|
|
96 |
$fname = "interface/$_" unless ( -f $_ );
|
|
|
97 |
die "ERROR: Cannot locate $fname\n" unless ( -f $fname );
|
|
|
98 |
require $fname;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
# use Dumpvalue;
|
|
|
102 |
# my $dumper = new Dumpvalue;
|
|
|
103 |
# $dumper->set(globPrint => 1);
|
|
|
104 |
# $dumper->dumpvars('main');
|
|
|
105 |
|
|
|
106 |
die "ERROR: Data in build.cfg is not valid\n"
|
|
|
107 |
unless ( keys(%ScmBuildPkgRules) >= 0 );
|
|
|
108 |
|
|
|
109 |
#print Data::Dumper->Dump([\%ScmBuildPkgRules], [qw(*ScmBuildPkgRules)]);
|
|
|
110 |
|
|
|
111 |
die "ERROR: No $opt_target target found\n"
|
|
|
112 |
unless ( defined($ScmBuildPkgRules{$opt_target}) );
|
|
|
113 |
|
|
|
114 |
#
|
|
|
115 |
# Detect WIN32 targets
|
|
|
116 |
# These are special as we will create library lists too
|
|
|
117 |
#
|
|
|
118 |
$win32_target = ($opt_target =~ m/WIN32$/);
|
|
|
119 |
|
|
|
120 |
#
|
|
|
121 |
# Create output files
|
|
|
122 |
#
|
|
|
123 |
open( INC, ">" . "$opt_target" . "_include.txt" ) ||
|
|
|
124 |
die "ERROR: cannot create " . "$opt_target" . "_include.txt\n";
|
|
|
125 |
|
|
|
126 |
#
|
|
|
127 |
# WIN32 targets are special
|
|
|
128 |
# Generate library file lists
|
|
|
129 |
# Prefix the include file list
|
|
|
130 |
#
|
|
|
131 |
if ($win32_target)
|
|
|
132 |
{
|
|
|
133 |
$inc_prefix = "/I ";
|
|
|
134 |
|
|
|
135 |
open( LIBD, ">" . "$opt_target" . "_libd.txt" ) ||
|
|
|
136 |
die "ERROR: cannot create " . "$opt_target" . "_libd.txt\n";
|
|
|
137 |
|
|
|
138 |
open( LIBP, ">" . "$opt_target" . "_libp.txt" ) ||
|
|
|
139 |
die "ERROR: cannot create " . "$opt_target" . "_libp.txt\n";
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
#
|
|
|
143 |
# Locate an array of package information
|
|
|
144 |
#
|
|
|
145 |
my ($pPlatform) = $ScmBuildPkgRules{$opt_target};
|
|
|
146 |
|
|
|
147 |
#
|
|
|
148 |
# Process each array element
|
|
|
149 |
#
|
|
|
150 |
foreach my $package ( @{$pPlatform} )
|
|
|
151 |
{
|
|
|
152 |
print "Processing Package: $package->{'NAME'}\n";
|
|
|
153 |
next if ( $exclude_package{$package->{'NAME'}} );
|
|
|
154 |
|
|
|
155 |
#
|
|
|
156 |
# Create a list of include directory paths
|
|
|
157 |
#
|
|
|
158 |
foreach my $incdir ( @{$package->{'PINCDIRS'}})
|
|
|
159 |
{
|
|
|
160 |
(my $inc = $package->{'ROOT'}.$incdir) =~ s~/~\\~g;
|
|
|
161 |
print INC "$inc_prefix" . "$inc\n";
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
#
|
|
|
165 |
# Create a list of libraries
|
|
|
166 |
# Ensure that library search hierarchy is retained
|
|
|
167 |
#
|
|
|
168 |
if ($win32_target)
|
|
|
169 |
{
|
|
|
170 |
my %seenP;
|
|
|
171 |
my %seenD;
|
|
|
172 |
|
|
|
173 |
foreach my $libdir ( @{$package->{'PLIBDIRS'}})
|
|
|
174 |
{
|
|
|
175 |
foreach ( glob( "$package->{'ROOT'}$libdir/*D.lib" ))
|
|
|
176 |
{
|
|
|
177 |
(my $lib = $_) =~ s~/~\\~g;
|
|
|
178 |
(my $libname = $_) =~ s~.*/~~;
|
|
|
179 |
$libname =~ s~[PDpd]\..*$~~;
|
|
|
180 |
next if ( $seenD{$libname} );
|
|
|
181 |
next if ( $exclude_lib{$libname} );
|
|
|
182 |
$seenD{$libname} = 1;
|
|
|
183 |
print LIBD "$lib\n";
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
foreach ( glob( "$package->{'ROOT'}$libdir/*P.lib" ))
|
|
|
187 |
{
|
|
|
188 |
(my $lib = $_) =~ s~/~\\~g;
|
|
|
189 |
(my $libname = $_) =~ s~.*/~~;
|
|
|
190 |
$libname =~ s~[PDpd]\..*$~~;
|
|
|
191 |
next if ( $seenP{$libname} );
|
|
|
192 |
next if ( $exclude_lib{$libname} );
|
|
|
193 |
$seenP{$libname} = 1;
|
|
|
194 |
print LIBP "$lib\n";
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
#
|
|
|
201 |
# Close the files
|
|
|
202 |
#
|
|
|
203 |
close INC;
|
|
|
204 |
if ($win32_target)
|
|
|
205 |
{
|
|
|
206 |
close LIBD;
|
|
|
207 |
close LIBP;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
#
|
|
|
211 |
# Let the user know which files have been created
|
|
|
212 |
#
|
|
|
213 |
print "Files created:\n";
|
|
|
214 |
print " $opt_target" . "_include.txt - Header file search path\n";
|
|
|
215 |
if ($win32_target)
|
|
|
216 |
{
|
|
|
217 |
print " $opt_target" . "_libp.txt - Production libraries\n";
|
|
|
218 |
print " $opt_target" . "_libd.txt - Debug libraries\n";
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
#-------------------------------------------------------------------------------
|
|
|
222 |
# Documentation
|
|
|
223 |
#
|
|
|
224 |
|
|
|
225 |
=pod
|
|
|
226 |
|
| 361 |
dpurdie |
227 |
=for htmltoc SYSUTIL::
|
|
|
228 |
|
| 227 |
dpurdie |
229 |
=head1 NAME
|
|
|
230 |
|
|
|
231 |
gen_packagelist - Create lists of header and lib files for MSVC
|
|
|
232 |
|
|
|
233 |
=head1 SYNOPSIS
|
|
|
234 |
|
|
|
235 |
jats etool gen_packagelist.pl [options]
|
|
|
236 |
|
|
|
237 |
Options:
|
|
|
238 |
-help - brief help message
|
|
|
239 |
-help -help - Detailed help message
|
|
|
240 |
-man - Full documentation
|
|
|
241 |
-nolib name - Exclude named library files
|
|
|
242 |
-nopackage name - Exclude named packages
|
|
|
243 |
-target name - target (default = WIN32)
|
|
|
244 |
|
|
|
245 |
=head1 OPTIONS
|
|
|
246 |
|
|
|
247 |
=over 8
|
|
|
248 |
|
|
|
249 |
=item B<-help>
|
|
|
250 |
|
|
|
251 |
Print a brief help message and exits.
|
|
|
252 |
|
|
|
253 |
=item B<-help -help>
|
|
|
254 |
|
|
|
255 |
Print a detailed help message with an explanation for each option.
|
|
|
256 |
|
|
|
257 |
=item B<-man>
|
|
|
258 |
|
|
|
259 |
Prints the manual page and exits.
|
|
|
260 |
|
|
|
261 |
=item B<-nolib name>
|
|
|
262 |
|
|
|
263 |
Exclude specfic library files from the generated lists. The names may be
|
|
|
264 |
comma seperated, or the option may be specified multiple times.
|
|
|
265 |
|
|
|
266 |
The named library will be removed from all packages.
|
|
|
267 |
|
|
|
268 |
=item B<-nopackage name>
|
|
|
269 |
|
|
|
270 |
Exclude specfic packages from the generated lists. The names may be
|
|
|
271 |
comma seperated, or the option may be specified multiple times.
|
|
|
272 |
|
|
|
273 |
=item B<-target name>
|
|
|
274 |
|
|
|
275 |
Specifies the target name. Default is WIN32.
|
|
|
276 |
|
|
|
277 |
=back
|
|
|
278 |
|
|
|
279 |
=head1 DESCRIPTION
|
|
|
280 |
|
|
|
281 |
B<This program> will create files intended to be included in a project file
|
|
|
282 |
in Microsoft Visual Studio, or the Custom Directories dialog in the Visual
|
|
|
283 |
Assist plug-in for Visual Studio.
|
|
|
284 |
|
|
|
285 |
Information in the files is based on data extracted from the build.pl file
|
|
|
286 |
after the JATS build command has been run. This program does not parse
|
|
|
287 |
build.pl directly. If build.pl is modified the "build" process must be run
|
|
|
288 |
before this program.
|
|
|
289 |
|
|
|
290 |
The files created by this program are:
|
|
|
291 |
|
|
|
292 |
=over 8
|
|
|
293 |
|
|
|
294 |
=item B<(target-name)_include.txt>
|
|
|
295 |
|
|
|
296 |
A list all header search directories found in the packages. The search order
|
|
|
297 |
implicit in the build.pl file is preserved in this file.
|
|
|
298 |
|
|
|
299 |
=item B<WIN32_libd.txt>
|
|
|
300 |
|
|
|
301 |
A list all I<debug> libraries found in the packages (only if target is WIN32).
|
|
|
302 |
|
|
|
303 |
=item B<WIN32_libp.txt>
|
|
|
304 |
|
|
|
305 |
A list all I<production> libraries found in the packages (only if target is
|
|
|
306 |
WIN32).
|
|
|
307 |
|
|
|
308 |
=back
|
|
|
309 |
|
|
|
310 |
B<NOTE:> Libraries that are classified as neither production of debug are not
|
|
|
311 |
included in the list of libraries.
|
|
|
312 |
|
|
|
313 |
=head1 EXAMPLE
|
|
|
314 |
|
|
|
315 |
jats etool gen_packagelist -exclude SFSecurityModule,solidbasetypes
|
|
|
316 |
|
|
|
317 |
The program is an extended JATS tool and must be run with the "etool" option.
|
|
|
318 |
|
|
|
319 |
=cut
|
|
|
320 |
|