Rev 7299 | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: perl; tabs: 4; -*-# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.## Module name : gen_packagelist.pl# Module type : Makefile system## Description : Create several lists of files based on the current# imported packages.## Creates:# list of all include paths# list of all libraries (if WIN32 target)## This implemenation relies on a complex datafile being generated# by the JATS build scripts.### Version Who Date Description# DDP 12-Oct-04 Created#............................................................................#require 5.006_001;use strict;use warnings;use Data::Dumper; # Debug onlyuse Pod::Usage; # required for help supportuse Getopt::Long;## Global variables#my $VERSION = "2.0.3"; # Update thisour %ScmBuildPkgRules;my $opt_help = 0;my $opt_manual;my $opt_verbose;my $opt_target = "WIN32"; # Default targetmy $inc_prefix = "";my @opt_exclude_lib;my @opt_exclude_package;my %exclude_lib;my %exclude_package;my $win32_target;my $result = GetOptions ("help+" => \$opt_help, # flag, multiple use allowed"manual" => \$opt_manual, # flag, multiple use allowed"verbose+" => \$opt_verbose, # flag, multiple use allowed"nolib=s" => \@opt_exclude_lib, # Multiple strings"nopackage=s" => \@opt_exclude_package, # Multiple strings"target=s" => \$opt_target, # Single string);## 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_manual || ($opt_help > 2));## Massage input options# Allow a comma seperated list of exclude options#@opt_exclude_lib = split( /,/,join(',',@opt_exclude_lib));foreach ( @opt_exclude_lib ){$exclude_lib{$_} = 1;print "Exclude library: $_\n";}@opt_exclude_package = split( /,/,join(',',@opt_exclude_package));foreach ( @opt_exclude_package ){$exclude_package{$_} = 1;print "Exclude package: $_\n";}################################################################################# Locate the JATS generated data file# This will be in the "interface" directory, or if this directory does not# exist the file will be found in the current directory## The data file can be "require"ed directly by Perl. The data will be# conatined with a few cf_xxxx hashes#for (qw(build.cfg)){my $fname = $_;$fname = "interface/$_" unless ( -f $_ );die "ERROR: Cannot locate $fname\n" unless ( -f $fname );require $fname;}# use Dumpvalue;# my $dumper = new Dumpvalue;# $dumper->set(globPrint => 1);# $dumper->dumpvars('main');die "ERROR: Data in build.cfg is not valid\n"unless ( keys(%ScmBuildPkgRules) >= 0 );#print Data::Dumper->Dump([\%ScmBuildPkgRules], [qw(*ScmBuildPkgRules)]);die "ERROR: No $opt_target target found\n"unless ( defined($ScmBuildPkgRules{$opt_target}) );## Detect WIN32 targets# These are special as we will create library lists too#$win32_target = ($opt_target =~ m/WIN32$/);## Create output files#open( INC, ">" . "$opt_target" . "_include.txt" ) ||die "ERROR: cannot create " . "$opt_target" . "_include.txt\n";## WIN32 targets are special# Generate library file lists# Prefix the include file list#if ($win32_target){$inc_prefix = "/I ";open( LIBD, ">" . "$opt_target" . "_libd.txt" ) ||die "ERROR: cannot create " . "$opt_target" . "_libd.txt\n";open( LIBP, ">" . "$opt_target" . "_libp.txt" ) ||die "ERROR: cannot create " . "$opt_target" . "_libp.txt\n";}## Locate an array of package information#my ($pPlatform) = $ScmBuildPkgRules{$opt_target};## Process each array element#foreach my $package ( @{$pPlatform} ){print "Processing Package: $package->{'NAME'}\n";next if ( $exclude_package{$package->{'NAME'}} );## Create a list of include directory paths#foreach my $incdir ( @{$package->{'PINCDIRS'}}){(my $inc = $package->{'ROOT'}.$incdir) =~ s~/~\\~g;print INC "$inc_prefix" . "$inc\n";}## Create a list of libraries# Ensure that library search hierarchy is retained#if ($win32_target){my %seenP;my %seenD;foreach my $libdir ( @{$package->{'PLIBDIRS'}}){foreach ( glob( "$package->{'ROOT'}$libdir/*D.lib" )){(my $lib = $_) =~ s~/~\\~g;(my $libname = $_) =~ s~.*/~~;$libname =~ s~[PDpd]\..*$~~;next if ( $seenD{$libname} );next if ( $exclude_lib{$libname} );$seenD{$libname} = 1;print LIBD "$lib\n";}foreach ( glob( "$package->{'ROOT'}$libdir/*P.lib" )){(my $lib = $_) =~ s~/~\\~g;(my $libname = $_) =~ s~.*/~~;$libname =~ s~[PDpd]\..*$~~;next if ( $seenP{$libname} );next if ( $exclude_lib{$libname} );$seenP{$libname} = 1;print LIBP "$lib\n";}}}}## Close the files#close INC;if ($win32_target){close LIBD;close LIBP;}## Let the user know which files have been created#print "Files created:\n";print " $opt_target" . "_include.txt - Header file search path\n";if ($win32_target){print " $opt_target" . "_libp.txt - Production libraries\n";print " $opt_target" . "_libd.txt - Debug libraries\n";}#-------------------------------------------------------------------------------# Documentation#=pod=for htmltoc SYSUTIL::=head1 NAMEgen_packagelist - Create lists of header and lib files for MSVC=head1 SYNOPSISjats etool gen_packagelist.pl [options]Options:-help - brief help message-help -help - Detailed help message-man - Full documentation-nolib name - Exclude named library files-nopackage name - Exclude named packages-target name - target (default = WIN32)=head1 OPTIONS=over 8=item B<-help>Print a brief help message and exits.=item B<-help -help>Print a detailed help message with an explanation for each option.=item B<-man>Prints the manual page and exits.=item B<-nolib name>Exclude specfic library files from the generated lists. The names may becomma seperated, or the option may be specified multiple times.The named library will be removed from all packages.=item B<-nopackage name>Exclude specfic packages from the generated lists. The names may becomma seperated, or the option may be specified multiple times.=item B<-target name>Specifies the target name. Default is WIN32.=back=head1 DESCRIPTIONB<This program> will create files intended to be included in a project filein Microsoft Visual Studio, or the Custom Directories dialog in the VisualAssist plug-in for Visual Studio.Information in the files is based on data extracted from the build.pl fileafter the JATS build command has been run. This program does not parsebuild.pl directly. If build.pl is modified the "build" process must be runbefore this program.The files created by this program are:=over 8=item B<(target-name)_include.txt>A list all header search directories found in the packages. The search orderimplicit in the build.pl file is preserved in this file.=item B<WIN32_libd.txt>A list all I<debug> libraries found in the packages (only if target is WIN32).=item B<WIN32_libp.txt>A list all I<production> libraries found in the packages (only if target isWIN32).=backB<NOTE:> Libraries that are classified as neither production of debug are notincluded in the list of libraries.=head1 EXAMPLEjats etool gen_packagelist -exclude SFSecurityModule,solidbasetypesThe program is an extended JATS tool and must be run with the "etool" option.=cut