Rev 361 | Blame | Compare with Previous | Last modification | View Log | RSS feed
# -*- mode: perl; tabs: 4; -*-# Copyright (C) 2004 ERG Transit Systems, All rights reserved## Module name : gen_msprojects# Module type : Makefile system## Description : Generate Microsoft Workspace and Project files from JATS source# This implemenation relies on a complex datafile being generated# by the JATS build scripts.### Version Who Date Description# DDP 5-May-04 Created#............................................................................#use strict;use JatsError;use JatsSystem;use JatsMakeInfo;use ReadBuildConfig qw(:All);use JatsMakeConfig;use ConfigurationFile;use Pod::Usage; # required for help supportuse Getopt::Long;my $VERSION = "2.0.1"; # Update this## Global variables#our @cf_filelist; # List of non-root makefilesour %msproj_info; # Generatedour $ScmBuildMachType; # from Makefile.gbeour $ScmRoot;our $ScmInterface;## Project names. Indexed by directory#my %pnames;my %pnames_files;my %pnames_sname;my %platforms_all; # Complete list of target platform namesmy $default_platform;my $bsc_file;my $build_file_name;my $project_name;my $interface_path;my $jats_path;## Options#my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debugmy $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbosemy $opt_help = 0;my $opt_manual = 0;my $opt_platform;my $opt_rebuild;my $opt_interface;my $opt_make_debug;my $opt_make_prod;#-------------------------------------------------------------------------------# Function : Mainline Entry Point## Description :## Inputs :#my $result = GetOptions ("help+" => \$opt_help,"manual" => \$opt_manual,"verbose+" => \$opt_verbose,"platform=s" => \$opt_platform,"interface=s" => \$opt_interface,"rebuild" => \$opt_rebuild,"debug" => \$opt_make_debug,"production" => \$opt_make_prod,);## 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));## Configure the Error reporting process now that we have the user options#ErrorConfig( 'name' =>'VSGEN', 'verbose' => $opt_verbose );## Sanity test#Error ("Conflicting options: -debug and -prod")if ( $opt_make_debug && $opt_make_prod );## Determine the mode of operation# Extract one key work from the argument list#my $cmd = pop @ARGV;if (! $cmd or $cmd eq "create" ) {create_msprojects();} elsif ( $cmd eq "build" ) {build_msproject();} elsif ( $cmd eq "clean" ) {clean_msproject();} elsif ( $cmd eq "make" ) {make_msproject();} else {Error( "Command not known: $cmd\n");}exit;#-------------------------------------------------------------------------------# Function : make_msproject## Description : This function processes build and make requests from the# visual studio project "build" comands## Make componets + manage source browser updates## Inputs :## Returns :#sub make_msproject{load_msproject_config();## If rebuilding then clean first# Use "unbuild" as this will also delete "installed" files#if ( $opt_rebuild ){System ("\"$jats_path\" make ${opt_platform}_unbuild");unlink ($msproj_info{'BSC_FILE'});}System ("\"$jats_path\" make ${opt_platform}_all_$msproj_info{'tname'} OPTIONS=gensbr");if ( $msproj_info{$opt_platform}{'SBR_ROOTS'} ){## Now combine SBR files into a common BSC file for source browsing#print "Creating Source Browser Information: $msproj_info{'BSC_FILE'} for $opt_platform\n";my @files;foreach my $dir ( @{$msproj_info{$opt_platform}{'SBR_ROOTS'}} ){if ( -d $dir ){print "Creating filelist in: $dir\n";push @files, qx (find $dir -type f -name *.sbr);}else{print "Object directory not found: $dir\n";}}if ( @files ){my $file_list = join ' ', @files;$file_list =~ s~/~\\~g;Verbose ("Files: $file_list\n");print "Running bscmake over all the files\n";System ("bscmake -v -o $msproj_info{'BSC_FILE'} $file_list" );}else{print "ERROR: No SBR files found\n";}}}#-------------------------------------------------------------------------------# Function : build_msproject## Description : This function processes build and make requests from the# visual studio project "build" comands## Rebuild the makefiles + project files## Inputs :## Returns :#sub build_msproject{load_msproject_config();System ("\"$jats_path\" -b $msproj_info{'BUILD_FILE'} build");}#-------------------------------------------------------------------------------# Function : clean_msproject## Description : This function will delete all the MSDEV files created## Inputs :## Returns :#sub clean_msproject{ReadMakeInfo();$opt_interface = "$::ScmRoot/$::ScmInterface";load_msproject_config();foreach my $file ( @{$msproj_info{'FILES'}} ){print "Delete: $file\n";unlink $file;}}#-------------------------------------------------------------------------------# Function : load_msproject_config## Description : Load the specila gen_msproject.cfg file# This file conatins lots of goodies## Inputs :## Returns :#sub load_msproject_config{Error("No interface path specified") unless ( $opt_interface );Error("Interface directory not found" ) unless ( -d $opt_interface );my $cfg_file = "$opt_interface/gen_msproject.cfg";Error("Internal config file not found") unless -f ($cfg_file);require $cfg_file;$jats_path = $msproj_info{'JATS'}}#-------------------------------------------------------------------------------# Function : create_msprojects## Description : Create a tree of MS projects## Inputs : None## Returns : Nothing#sub create_msprojects{($jats_path = find_in_path ("jats.bat")) =~ s~/~\\~g;$msproj_info{'JATS'} = $jats_path;## Retain the type of the project#if ( $opt_make_prod ){print "Creating a Production Builder\n";$msproj_info{'tname'} = 'prod';$msproj_info{'tletter'} = 'P';}else{print "Creating a Debug Builder\n";$msproj_info{'tname'} = 'debug';$msproj_info{'tletter'} = 'D';}$msproj_info{'FILES'} = ();## Locate the base of the JATS build# This will be provided by Makefile.gbe#ReadMakeInfo();$interface_path = "$::ScmRoot/$::ScmInterface";## Read in the global build variables#ReadBuildConfig( $interface_path );$build_file_name = $::ScmBuildSrc;die "ERROR: Cannot determine buildfile name\n" unless ( defined $build_file_name );## Create a 'Nice' project name# MS will screw up if there is a "-" in the name#die "ERROR: Cannot determine package name\n" unless ( defined $::ScmBuildPackage );$project_name = $::ScmBuildPackage;$project_name =~ s~-~_~g;$msproj_info{'BUILD_FILE'} = $build_file_name;$msproj_info{'PROJECT'} = $project_name;## Determine the root directory#die "ERROR: Cannot determine build root\n" unless ( defined $::ScmRoot );my $root_dir = $::ScmRoot;$bsc_file = $root_dir . '/' . $project_name . ".bsc";$bsc_file =~ s~//~/~g;$bsc_file =~ s~/~\\~g;print "BSC File: $bsc_file\n";$msproj_info{'ROOT_DIR'} = $root_dir;$msproj_info{'BSC_FILE'} = $bsc_file;unlink ($msproj_info{'BSC_FILE'});## Read in all the makefile data in one hit#my $mfdata = JatsMakeConfigReader::GetAllMakeInfo();## Scan the projects and create unique names for each project# Cannot simply base the project name on the subdirectory#foreach my $dir ( $mfdata->AllDirs() ){## Get the data for this makefile entry#my $mff = $mfdata->GetEntry($dir);print "Scanning: $dir\n";## Exclude the root makefile# Exclude makefiles without any platforms - causes havoc with MSDEV#next if $mff->GetInfoItem('noplatforms');push @cf_filelist, $dir;foreach my $tgt ( $mff->GetPlatforms() ){$platforms_all{$tgt} = "Win32 Jats $tgt";## Save info to allow building of source browser data#if ( $mff->GetDataItem($tgt, '$TS_sbr_support') ){## Record the base directory for each makefile# This may be used to locate SBR files later# Only process debug objects# Only process subdirs that are a part of this project#my $sbr_dir = $mff->GetDataItem($tgt, '$Cwd') . "/${tgt}$msproj_info{'tletter'}.OBJ";push @{$msproj_info{$tgt}{'SBR_ROOTS'}}, $sbr_dir;## Remove any existing SBR files to ensure that any processed# SBR files are deleted#if ( -d $sbr_dir ){print "Delete SBR files\n";unlink split( ' ', qx (find $sbr_dir -type f -name *.sbr));}}}}## Simplify the Project Name# Clean it up as much as possible by removing as much of the common# part of the source directory name as possible from each name#my %pname_hash;my $first_key;foreach my $key ( @cf_filelist ){$first_key = $key unless ( $first_key );$pname_hash{$key} = [split '/', $key ]}my $miss = 0;my $kill_level;foreach my $level ( 1..10 ){my $first_arg = @{$pname_hash{$first_key}}[$level];unless ( $first_arg){$kill_level = $level - 1;$miss = 1;last;}$kill_level = $level;foreach my $key ( @cf_filelist ){unless ( @{$pname_hash{$key}}[$level] eq $first_arg ){$miss = 1;}}last if ( $miss );}## Generate "nice" names for the projects# Prepend Jats to avoid conflict with the any existing names#foreach my $key ( @cf_filelist ){my @list = @{$pname_hash{$key}};my $nname = join( '_', @list[$kill_level .. $#list] );$nname =~ s~-~_~g;$nname = "Jats_" . $nname;$pnames{$key} = $nname;my $project_path = $key . "/" . $nname . ".dsp";$pnames_files{$key} = $project_path;my $sname = $key;$sname =~ s~.*/~~;$pnames_sname{$key} = $sname;}## Deterine the default project# Use a WIN32 project if it is present#if ( $platforms_all{'WIN32'} ){$default_platform = 'WIN32';}else{($default_platform) = sort keys( %platforms_all );}print "Default Platform: $default_platform\n";## Add entry for the Top project#$pnames{"."} = "Project_Make_" . $project_name;$pnames_files{"."} = "Project_Make_" . $project_name . ".dsp";$pnames_sname{"."} = $project_name;## Generate a top-level Workspace file# This file will reference a project file for each child makefile#GenerateStudioWorkspace ( ".", "Project_Build_" . $project_name, keys(%pnames) );GenerateStudioProjectRoot( ".", "Project_Build_" . $project_name );GenerateStudioProjectTop ( ".", $pnames{"."} );## Generate Workspace / Project files for each of the subdirectores# The information for each subdierctory is held in a different Makefile*.cfg# file. Process each one in turn.#foreach my $key ( @cf_filelist ){## Get the data for this makefile entry#my $mff = $mfdata->GetEntry($key);GenerateStudioWorkspace( $key, $pnames{$key} );GenerateStudioProject ( $key, $pnames{$key}, $mff );}## Create a file in the interface directory to communicate# Essential information to build time instances of this program# It is easier to pass them via a file than through the command line#my $cfg_file = "$interface_path/gen_msproject.cfg";print "Creating: $cfg_file\n";my $fh = ConfigurationFile::New( $cfg_file );$fh->HeaderSimple( "gen_msproject","JATS Information for gen_msproject" );$fh->Dump( [\%msproj_info], [qw(*msproj_info)] );$fh->Close();}#-------------------------------------------------------------------------------# Function : print_dsf## Description : Print a line to the Developer Studio file# The DSF files need to be \r\n terminated, even when generated# within a unix environment. This is achieved by opening the file# in binary mode and forcing a "\r\n" line terminator## Inputs :## Returns :#sub print_dsf{print DSF "@_\r\n";}#-------------------------------------------------------------------------------# Function : GenerateStudioWorkspace## Description : Generate a Microsoft Developer Studio Workspace file## Inputs : $1 - Target directory# $2 - Workspace Name# $3 - Array of target sub project directories## Returns :#sub GenerateStudioWorkspace{my ($tdir, $fname, @subdirs ) = @_;foreach ( qw( opt ncb dsw ) ){unlink ("$tdir/$fname.$_");push @{$msproj_info{'FILES'}}, "$tdir/$fname.$_";}push @{$msproj_info{'FILES'}}, "$tdir/$fname.dsw";open( DSF, ">$tdir/$fname.dsw" ) ||die "ERROR: cannot create $tdir/$fname.dsw\n";binmode DSF;## Generate the Workspace header#print_dsf "Microsoft Developer Studio Workspace File, Format Version 6.00";print_dsf "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!";print_dsf "# Generated by JATS";print_dsf "";print_dsf "###############################################################################";print_dsf "";## Generate project sections for each subproject# The Root project simply references all the known subprojects# Non-Root projects are associated with a local project file and possible# sub project files.#my $project_name = $fname;my $project_path = "./" . $fname;print_dsf "###############################################################################";print_dsf "Project: \"$project_name\"=$project_path.dsp - Package Owner=<4>";print_dsf "";print_dsf "Package=<5>";print_dsf "{{{";print_dsf "}}}";print_dsf "";print_dsf "Package=<4>";print_dsf "{{{";print_dsf "}}}";print_dsf "";foreach my $subdir ( @subdirs ){print_dsf "###############################################################################";print_dsf "Project: \"$pnames{$subdir}\"=$pnames_files{$subdir} - Package Owner=<4>";print_dsf "";print_dsf "Package=<5>";print_dsf "{{{";print_dsf "}}}";print_dsf "";print_dsf "Package=<4>";print_dsf "{{{";print_dsf "}}}";print_dsf "";}## Generate the global section#print_dsf "###############################################################################";print_dsf "";print_dsf "Global:";print_dsf "";print_dsf "Package=<5>";print_dsf "{{{";print_dsf "}}}";print_dsf "";print_dsf "Package=<3>";print_dsf "{{{";print_dsf "}}}";print_dsf "";print_dsf "###############################################################################";close DSF;}#-------------------------------------------------------------------------------# Function : GenerateStudioProjectRoot## Description : Generate a Microsoft Developer Studio Project file for# the toplevel project. This is a special project file## Inputs : $1 - Target directory# $2 - Project Name## Returns :#sub GenerateStudioProjectRoot{my ( $tdir, $fname ) = @_;## Determine the various platforms for the project and generate# a configuration for each platforms#my %platform;my $first_platform;my $vs_config;my $cfg = "$fname - Win32 Jats WIN32";print "Project Config: $cfg\n";## Create the Project File and generate the basic header#push @{$msproj_info{'FILES'}}, "$tdir/$fname.dsp";open( DSF, ">$tdir/$fname.dsp" ) ||die "ERROR: cannot create $tdir/$fname.dsp\n";binmode DSF;print_dsf "# Microsoft Developer Studio Project File - Name=\"$fname\" - Package Owner=<4>";print_dsf "# Microsoft Developer Studio Generated Build File, Format Version 6.00";print_dsf "# ** DO NOT EDIT **";print_dsf "# Generated by JATS";print_dsf "";## Generate the default configuration entry#print_dsf "# TARGTYPE \"Win32 (x86) External Target\" 0x0106";print_dsf "";print_dsf "CFG=$cfg";## Generate the MESSAGE section#print_dsf "!MESSAGE This is not a valid makefile. To build this project using NMAKE,";print_dsf "!MESSAGE use the Export Makefile command and run";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\".";print_dsf "!MESSAGE ";print_dsf "!MESSAGE You can specify a configuration when running NMAKE";print_dsf "!MESSAGE by defining the macro CFG on the command line. For example:";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\" CFG=\"$fname - Win32 Jats make\"";print_dsf "!MESSAGE ";print_dsf "!MESSAGE Possible choices for configuration are:";print_dsf "!MESSAGE ";print_dsf "!MESSAGE \"$cfg\" (based on \"Win32 (x86) External Target\")";print_dsf "!MESSAGE ";print_dsf "";## Generate a Project#print_dsf "# Begin Project";print_dsf "# PROP AllowPerConfigDependencies 0";print_dsf "# PROP Scc_ProjName \"\"";print_dsf "# PROP Scc_LocalPath \"\"";## Generate configuration section#print_dsf "# PROP BASE Use_MFC 0";print_dsf "# PROP BASE Use_Debug_Libraries 0";print_dsf "# PROP BASE Output_Dir \"\"";print_dsf "# PROP BASE Intermediate_Dir \"\"";print_dsf "# PROP BASE Cmd_Line \"CommandLine\"";print_dsf "# PROP BASE Rebuild_Opt \"Rebuild\"";print_dsf "# PROP BASE Target_File \"Output\"";print_dsf "# PROP BASE Bsc_Name \"\"";print_dsf "# PROP BASE Target_Dir \"\"";print_dsf "# PROP Use_MFC 0";print_dsf "# PROP Use_Debug_Libraries 0";print_dsf "# PROP Output_Dir \"\"";print_dsf "# PROP Intermediate_Dir \"\"";print_dsf "# PROP Cmd_Line \"\"$jats_path\" gen_msproject build -interface=$interface_path\"";print_dsf "# PROP Rebuild_Opt \"-rebuild\"";print_dsf "# PROP Bsc_Name \"$bsc_file\"";print_dsf "# PROP Target_Dir \"\"";## Generate the Target section#print_dsf "# Begin Target";print_dsf "";print_dsf "# Name \"$cfg\"";## Create various groups of files#my @file_list;## List of main builder files# Note that build.pl may not always be the main build file#for ( $build_file_name, qw( makefile.pl warnings.mri)){push @file_list, $_if ( -f $_ );}print_dsp_group ("Jats Builder", "pl" , @file_list );## Other useful builder files#@file_list = ();push @file_list, "build.pl"if ( $build_file_name ne "build.pl" );print_dsp_group ("Other Jats Builder", "pl" , @file_list );@file_list = glob ( "warnings.*" );print_dsp_group ("Warning Filter", "pl" , @file_list );print_dsf "# End Target";print_dsf "# End Project";close DSF;}#-------------------------------------------------------------------------------# Function : GenerateStudioProjectTop## Description : Generate a Microsoft Developer Studio Project file for# the toplevel project. This is a special project file# that will allow the user to make the ENTIRE project## Inputs : $1 - Target directory# $2 - Project Name## Returns :#sub GenerateStudioProjectTop{my ( $tdir, $fname ) = @_;## Create the Project File and generate the basic header#push @{$msproj_info{'FILES'}}, "$tdir/$fname.dsp";open( DSF, ">$pnames_files{$tdir}" ) ||die "ERROR: cannot create $pnames_files{$tdir}\n";binmode DSF;print_dsf "# Microsoft Developer Studio Project File - Name=\"$pnames{$tdir}\" - Package Owner=<4>";print_dsf "# Microsoft Developer Studio Generated Build File, Format Version 6.00";print_dsf "# ** DO NOT EDIT **";print_dsf "# Generated by JATS";print_dsf "";## Generate the default configuration entry#print_dsf "# TARGTYPE \"Win32 (x86) External Target\" 0x0106";print_dsf "";print_dsf "CFG=$fname - $platforms_all{$default_platform}";## Generate the MESSAGE section#print_dsf "!MESSAGE This is not a valid makefile. To build this project using NMAKE,";print_dsf "!MESSAGE use the Export Makefile command and run";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\".";print_dsf "!MESSAGE ";print_dsf "!MESSAGE You can specify a configuration when running NMAKE";print_dsf "!MESSAGE by defining the macro CFG on the command line. For example:";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\" CFG=\"$fname - Win32 Jats make\"";print_dsf "!MESSAGE ";print_dsf "!MESSAGE Possible choices for configuration are:";print_dsf "!MESSAGE ";for ( sort keys %platforms_all){print_dsf "!MESSAGE \"$fname - $platforms_all{$_}\" (based on \"Win32 (x86) External Target\")";}print_dsf "!MESSAGE ";print_dsf "";## Generate a Project#print_dsf "# Begin Project";print_dsf "# PROP AllowPerConfigDependencies 0";print_dsf "# PROP Scc_ProjName \"\"";print_dsf "# PROP Scc_LocalPath \"\"";## Generate per-configuration sections#my $if_statement = "IF";for (sort keys %platforms_all){print_dsf "!$if_statement \"\$(CFG)\" == \"$fname - $platforms_all{$_}\"";$if_statement = "ELSEIF";print_dsf "# PROP BASE Use_MFC 0";print_dsf "# PROP BASE Use_Debug_Libraries 0";print_dsf "# PROP BASE Output_Dir \"\"";print_dsf "# PROP BASE Intermediate_Dir \"\"";print_dsf "# PROP BASE Cmd_Line \"CommandLine\"";print_dsf "# PROP BASE Rebuild_Opt \"Rebuild\"";print_dsf "# PROP BASE Target_File \"Output\"";print_dsf "# PROP BASE Bsc_Name \"\"";print_dsf "# PROP BASE Target_Dir \"\"";print_dsf "# PROP Use_MFC 0";print_dsf "# PROP Use_Debug_Libraries 0";print_dsf "# PROP Output_Dir \"\"";print_dsf "# PROP Intermediate_Dir \"\"";print_dsf "# PROP Cmd_Line \"\"$jats_path\" gen_msproject make -platform=$_ -interface=$interface_path\"";print_dsf "# PROP Rebuild_Opt \"-rebuild\"";print_dsf "# PROP Target_File \"\"";print_dsf "# PROP Bsc_Name \"$bsc_file\"";print_dsf "# PROP Target_Dir \"\"";}print_dsf "!ENDIF";## Generate the Target section#print_dsf "# Begin Target";print_dsf "";for (sort keys %platforms_all){print_dsf "# Name \"$fname - $platforms_all{$_}\"";}print_dsf "# End Target";print_dsf "# End Project";close DSF;}#-------------------------------------------------------------------------------# Function : GenerateStudioProject## Description : Generate a Microsoft Developer Studio Project file# The name of the generated file is taken from the# current directory.## Inputs : $1 - Target directory# $2 - Project Name# $3 - Ref to an object that conatins data for this project## Returns :#sub GenerateStudioProject{my ( $tdir, $fname, $pdata ) = @_;my $sname = $pnames_sname{$tdir};## Plaforms in this makefile#my @platform = sort ( $pdata->GetPlatforms() );## Create the Project File and generate the basic header#push @{$msproj_info{'FILES'}}, "$pnames_files{$tdir}";open( DSF, ">$pnames_files{$tdir}" ) ||die "ERROR: cannot create $pnames_files{$tdir}\n";binmode DSF;print_dsf "# Microsoft Developer Studio Project File - Name=\"$pnames{$tdir}\" - Package Owner=<4>";print_dsf "# Microsoft Developer Studio Generated Build File, Format Version 6.00";print_dsf "# ** DO NOT EDIT **";print_dsf "# Generated by JATS";print_dsf "";## Generate the default configuration entry#print_dsf "# TARGTYPE \"Win32 (x86) External Target\" 0x0106";print_dsf "";print_dsf "CFG=$fname - $platforms_all{$default_platform}";## Generate the MESSAGE section#print_dsf "!MESSAGE This is not a valid makefile. To build this project using NMAKE,";print_dsf "!MESSAGE use the Export Makefile command and run";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\".";print_dsf "!MESSAGE ";print_dsf "!MESSAGE You can specify a configuration when running NMAKE";print_dsf "!MESSAGE by defining the macro CFG on the command line. For example:";print_dsf "!MESSAGE ";print_dsf "!MESSAGE NMAKE /f \"$fname.mak\" CFG=\"$fname - Win32 Jats make\"";print_dsf "!MESSAGE ";print_dsf "!MESSAGE Possible choices for configuration are:";print_dsf "!MESSAGE ";for (@platform){print_dsf "!MESSAGE \"$fname - $platforms_all{$_}\" (based on \"Win32 (x86) External Target\")";}print_dsf "!MESSAGE ";print_dsf "";## Generate a Project#print_dsf "# Begin Project";print_dsf "# PROP AllowPerConfigDependencies 0";print_dsf "# PROP Scc_ProjName \"\"";print_dsf "# PROP Scc_LocalPath \"\"";## Generate per-configuration sections#my $if_statement = "IF";for (@platform){## Extract some platform specific data#my $target_file = $pdata->GetDataItem($_, '$TS_target_file');## Convert symbolic paths to physical paths#$target_file =~ s~\$\(BINDIR\)~${_}$msproj_info{'tletter'}.BIN~;$target_file =~ s~\$\(LIBDIR\)~$_.LIB~;$target_file =~ s~\$\(GBE_TYPE\)~$msproj_info{'tletter'}~;print_dsf "!$if_statement \"\$(CFG)\" == \"$fname - $platforms_all{$_}\"";$if_statement = "ELSEIF";print_dsf "# PROP BASE Use_MFC 0";print_dsf "# PROP BASE Use_Debug_Libraries 0";print_dsf "# PROP BASE Output_Dir \"\"";print_dsf "# PROP BASE Intermediate_Dir \"\"";print_dsf "# PROP BASE Cmd_Line \"CommandLine\"";print_dsf "# PROP BASE Rebuild_Opt \"Rebuild\"";print_dsf "# PROP BASE Target_File \"Output\"";print_dsf "# PROP BASE Bsc_Name \"\"";print_dsf "# PROP BASE Target_Dir \"\"";print_dsf "# PROP Use_MFC 0";print_dsf "# PROP Use_Debug_Libraries 0";print_dsf "# PROP Output_Dir \"${_}$msproj_info{'tletter'}.BIN\"";print_dsf "# PROP Intermediate_Dir \"${_}$msproj_info{'tletter'}.OBJ\"";print_dsf "# PROP Cmd_Line \"\"$jats_path\" gen_msproject make -platform=$_ -interface=$interface_path\"";print_dsf "# PROP Rebuild_Opt \"-rebuild\"";print_dsf "# PROP Target_File \"$target_file\"";print_dsf "# PROP Bsc_Name \"$bsc_file\"";print_dsf "# PROP Target_Dir \"\"";}print_dsf "!ENDIF";## Generate the Target section#print_dsf "# Begin Target";print_dsf "";for (@platform){print_dsf "# Name \"$fname - $platforms_all{$_}\"";}## Generate the various file groups for each of the platforms# Crunch the various known file groups and merge all the platform# source files into one common view# If a file is common to all platforms then place it in one folder# Remaining files are placed in platform folders#my %common_srcs; # Hash of all common filesmy %other_srcs; # Hash, by platform, of non-common files## Generate a complete list of all file names in all platforms# The hash value may be common - if the file is common on all platforms# This assumption will be used#my %complete_list;for (@platform){my $sentry = $pdata->GetDataItem($_, '%SRCS');for my $file ( keys %{$sentry} ){$complete_list{$file} = $sentry->{$file};}}# print "Processing from : $base\n";# print Dumper ( $pdata->{$base}{'%SRCS'} );for my $file ( keys %complete_list ){my $missing;my $full_name = $complete_list{$file};for (@platform){unless ( $pdata->GetDataItem($_, '%SRCS')->{$file} eq $full_name ){$missing = 1;last;}}if ( $missing ){## Add files to non-common list#for (@platform){my $sentry = $pdata->GetDataItem($_, '%SRCS');$other_srcs{$_}{$file} = $sentry->{$file}if ( defined $sentry->{$file} );}}else{# Add files to the common list#$common_srcs{$file} = $full_name;}}# print Dumper ( \%common_srcs );# print Dumper ( \%other_srcs );## Create various groups of files#print_dsp_group ("Jats Builder", "pl" , "makefile.pl" );print_dsp_group_begin("Source", "*");print_dsp_group ( "Common" , "*" , values %common_srcs );for (@platform){print_dsp_group ( "$_" , "*" , values %{$other_srcs{$_}} );}print_dsp_group_end();# print_dsp_group ( "C Source" , "c" , @{$pdata->{'WIN32'}{'@CSRCS'}} );# print_dsp_group ( "C++ Source" , "cpp" , @{$pdata->{'WIN32'}{'@CXXSRCS'}} );# print_dsp_group ( "Header" , "h" , @{$pdata->{'WIN32'}{'@CHDRS'}} );# print_dsp_group ( "Unknown" , "" , keys(%srcs_left) );print_dsf "# End Target";print_dsf "# End Project";close DSF;}#-------------------------------------------------------------------------------# Function : find_in_path## Description : Find a file within the users path## Inputs : $1 - Name of the file to find## Returns : Full pathname##sub find_in_path{(my $name) = @_;for my $path (split ';', $ENV{ 'PATH' }){my $tn = $path . "/" . $name;return ( $tn ) if ( -f $tn )}return $name;}#-------------------------------------------------------------------------------# Function : print_dsp_group## Description : Print a group entry for a MS DSP file## Inputs : $1 - Name of the group# $2 - Filter string. (c;h)# $3 - Array of files to process## Returns :#sub print_dsp_group_begin{my ($name, $filter) = @_;print_dsf "";print_dsf "# Begin Group \"$name Files\"";print_dsf "# PROP Default_Filter \"$filter\"";}sub print_dsp_group_end{print_dsf "# End Group";}sub print_dsp_group{my ( $name, $filter, @files ) = @_;if ( $#files >= 0 ){print_dsp_group_begin( $name, $filter );for ( @files ){## Convert the filename into a full path#my $full_name = $_;$full_name =~ s~/~\\~g;print_dsf "# Begin Source File";print_dsf "SOURCE=$full_name";print_dsf "# PROP Ignore_Default_Tool 1";print_dsf "# End Source File";print_dsf "";}print_dsp_group_end();}}#-------------------------------------------------------------------------------# Documentation#=pod=head1 NAMEgen_msproject - JATS utility to create and maintain Visual Studio6 projects=head1 SYNOPSISJATS gen_msproject [options] [mode]Options:-help - brief help message-help -help - Detailed help message-man - Full documentation-debug - Create a debug builder (default)-production - Create a production builderModes:create - Create DSW and DSP files (default)build - Rebuild JATS makefiles (internal)make - Run JATS make (internal)clean - Delete generated DSW and DSP files=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<-debug>The makefiles created will build the debug version of the target.This is the default option. It is mutually exclusive with B<-prod>=item B<-production>The makefiles created will build the production version of the target.This is the default option. It is mutually exclusive with B<-debug>=back=head1 MODES=over 8=item B<create>Create a set Visual Studio6 Workspace and Project files based on the JATSbuild.pl and makefile.pl files.Before running this command the JATS workspace MUST be prepared with the "JATSbuild" command as this command saves information used by this program.=item B<build>This mode is used only by the generated projects files to rebuild the JATSmakefiles. It is not intended to be used externally.=item B<make>This mode is used only by the generated projects files to rebuild the JATSmakefiles. It is not intended to be used externally.=item B<clean>This command will delete the Visual Studio6 Workspace, Project files and relatedfiles created by the 'build' process.=back=head1 DESCRIPTIONThis program will build a set Visual Studio6 Workspace and Project files toassist intended the migration from Visual Studio6 to JATS.=for htmlclass NoteNote: gen_msprojects only supports Version 6 of Visual Studio. This is thecompiler used by the B<WIN32> build target.In normal operation the program will:=over 8=item *Create A DSW and DSP file for each JATS makefile.pl=item *Create a global DSW and DSP file for the entire JATS build=item *Create a psude DSP file to allow the user to build the entire project=backThe generated project files allow the components to be rebuilt with JATS.The generated project files allow source browsing of WIN32 components of theproject.=cut