[GME-commit] GMESRC/SDK/BON/tools/ComponentConfig
ComponentConfig.vcproj,NONE,1.1 VcprojHandler.cpp,NONE,1.1
VcprojHandler.h,NONE,1.1 EventMaskDialog.h,1.1,1.2
InterpreterConfigDlg.cpp,1.14,1.15 InterpreterConfigDlg.h,1.9,1.10
RenameComponent.h,1.4,1.5 ComponentConfig.dsp,1.4,NONE
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Mon Jan 31 14:23:32 CST 2005
Update of /var/lib/gme/GMESRC/SDK/BON/tools/ComponentConfig
In directory braindrain:/tmp/cvs-serv19663
Modified Files:
EventMaskDialog.h InterpreterConfigDlg.cpp
InterpreterConfigDlg.h RenameComponent.h
Added Files:
ComponentConfig.vcproj VcprojHandler.cpp VcprojHandler.h
Removed Files:
ComponentConfig.dsp
Log Message:
New version of Componentconfig is updated for Visual Studio 7
CVS User: zolmol
--- NEW FILE: ComponentConfig.vcproj ---
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="InterpreterConfig"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(VCInstallDir)\vcpackages"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/ComponentConfig.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="Debug/ConfigureComponent.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/ConfigureComponent.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/ComponentConfig.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="echo WARNING: A DEBUG version has been built. The RELEASE version is put into the CreateNewComponent package"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="$(VCInstallDir)\vcpackages"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/ComponentConfig.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="Release/ConfigureComponent.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/ConfigureComponent.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/ComponentConfig.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="EventMaskDialog.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="InterpreterConfig.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="hlp\InterpreterConfig.hpj">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath="InterpreterConfig.rc">
</File>
<File
RelativePath="InterpreterConfigDlg.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="StdAfx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
UsePrecompiledHeader="1"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
UsePrecompiledHeader="1"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\VcprojHandler.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="EventMaskDialog.h">
</File>
<File
RelativePath="InterpreterConfig.h">
</File>
<File
RelativePath="InterpreterConfigDlg.h">
</File>
<File
RelativePath="RenameComponent.h">
</File>
<File
RelativePath="Resource.h">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Making help include file..."
CommandLine="echo. >"hlp\$(TargetName).hm"
echo // Commands (ID_* and IDM_*) >>"hlp\$(TargetName).hm"
makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Prompts (IDP_*) >>"hlp\$(TargetName).hm"
makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Resources (IDR_*) >>"hlp\$(TargetName).hm"
makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Dialogs (IDD_*) >>"hlp\$(TargetName).hm"
makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Frame Controls (IDW_*) >>"hlp\$(TargetName).hm"
makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\$(TargetName).hm"
"
Outputs="hlp\$(TargetName).hm"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Making help include file..."
CommandLine="echo. >"hlp\$(TargetName).hm"
echo // Commands (ID_* and IDM_*) >>"hlp\$(TargetName).hm"
makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Prompts (IDP_*) >>"hlp\$(TargetName).hm"
makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Resources (IDR_*) >>"hlp\$(TargetName).hm"
makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Dialogs (IDD_*) >>"hlp\$(TargetName).hm"
makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\$(TargetName).hm"
echo. >>"hlp\$(TargetName).hm"
echo // Frame Controls (IDW_*) >>"hlp\$(TargetName).hm"
makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\$(TargetName).hm"
"
Outputs="hlp\$(TargetName).hm"/>
</FileConfiguration>
</File>
<File
RelativePath="StdAfx.h">
</File>
<File
RelativePath=".\VcprojHandler.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
<File
RelativePath="res\InterpreterConfig.ico">
</File>
<File
RelativePath="res\InterpreterConfig.rc2">
</File>
</Filter>
<Filter
Name="Help Files"
Filter="cnt;rtf">
<File
RelativePath="hlp\AfxDlg.rtf">
</File>
<File
RelativePath="hlp\InterpreterConfig.cnt">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Copying contents file..."
CommandLine="copy "hlp\$(InputName).cnt" "$(OutDir)"
"
Outputs="$(OutDir)\$(InputName).cnt"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Copying contents file..."
CommandLine="copy "hlp\$(InputName).cnt" "$(OutDir)"
"
Outputs="$(OutDir)\$(InputName).cnt"/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
--- NEW FILE: VcprojHandler.cpp ---
#include "stdafx.h"
#include "VcprojHandler.h"
#include "Afxwin.h"
void VcprojHandler::BSTRreplace( const CComBSTR& outf, CComBSTR& outf_new, const CString& old_n, const CString& new_n)
{
CString r = outf;
r.Replace( old_n, new_n);
outf_new = (LPCTSTR) r;
}
int VcprojHandler::swapFiles( CComPtr<VCFile>& spOldFile, const CComBSTR& oldf, const CComBSTR& newf, CComPtr<VCProject>& spProject)
{
strstream scout;
HRESULT hr;
CComQIPtr<VCFile> spNewFile;
// add the new file
VARIANT_BOOL var;
hr = spProject->CanAddFile( newf, &var );
if( SUCCEEDED( hr ) && var )
{
CComPtr<IDispatch> spDispFile;
hr = spProject->AddFile( newf, &spDispFile );
if( FAILED( hr ) )
{
scout << "Error: cannot add the new source file." << endl;
return 1;
}
spNewFile = spDispFile;
}
else
return 1;
if( !spNewFile)
{
int i = 0;
++i;
return 1;
}
// Access FileConfigurations collection of the OLD and NEW file
CComPtr<IDispatch> spDispColOld;
CComPtr<IDispatch> spDispColNew;
hr = spOldFile->get_FileConfigurations( &spDispColOld );
hr = spNewFile->get_FileConfigurations( &spDispColNew );
if( SUCCEEDED( hr ) )
{
CComQIPtr<IVCCollection> spFileConfigsCollOld = spDispColOld;
CComQIPtr<IVCCollection> spFileConfigsCollNew = spDispColNew;
// Iterator through the configurations of the NEW file
long ee = 0;
hr = spFileConfigsCollNew->get_Count( &ee);
for( long ii = 1; ii <= ee; ++ii)
{
CComPtr<IDispatch> spDispFileConfigNew;
// Inquire the ii-th configuration
hr = spFileConfigsCollNew->Item( CComVariant( (long) ii ), &spDispFileConfigNew );
if( SUCCEEDED( hr ) )
{
CComQIPtr<VCFileConfiguration> spFileConfigNew = spDispFileConfigNew;
// inquire the configuration's name
CComBSTR configNameNew;
spFileConfigNew->get_Name( &configNameNew);
// inquire (based on name) this specific configuration of the OLD file
CComPtr<IDispatch> spDispFileConfigOld;
CComQIPtr<VCFileConfiguration> spFileConfigOld;
hr = spFileConfigsCollOld->Item( CComVariant( configNameNew), &spDispFileConfigOld);
if( SUCCEEDED( hr) )
{
spFileConfigOld = spDispFileConfigOld;
}
if( spFileConfigOld) // copy settings if old config is available
{
// Get the default tool associated with this configuration of this file
CComPtr<IDispatch> spDispFileToolNew;
CComPtr<IDispatch> spDispFileToolOld;
hr = spFileConfigNew->get_Tool( &spDispFileToolNew );
hr = spFileConfigOld->get_Tool( &spDispFileToolOld );
if( SUCCEEDED( hr ) )
{
CString fname = oldf;
if( -1 != fname.Find(".cpp")) // found
{
CComDispatchDriver fileToolOld( spDispFileToolOld );
CComDispatchDriver fileToolNew( spDispFileToolNew );
copyCppSettings( fileToolOld, fileToolNew);
}
else if( -1 != fname.Find(".idl"))
{
// which tool is set for the new file?
CComPtr<VCCustomBuildTool> spCustomBuildToolNew;
CComPtr<VCMidlTool> spMidlToolNew;
int k = whichIDLTool( spDispFileToolNew, spCustomBuildToolNew, spMidlToolNew);
if( k == 0) { ASSERT( 0); }
else if( k == 1) // custom built
{}
else if( k == 2) // midl built
{
prepareIdlSettingsForMIDL( spMidlToolNew);
}
}
}
else
scout << "Error: cannot get the tool associated with the source file." << endl;
}
}
else
scout << "Error: cannot get the configuration of the source file." << endl;
}
}
//-
// remove the old file
hr = spProject->RemoveFile( spOldFile);
if( FAILED( hr))
{
scout << "Error: cannot remove old file from project." << endl;
}
return 0;
}
int VcprojHandler::whichIDLTool(CComPtr<IDispatch>& spDispFileTool, CComPtr<VCCustomBuildTool>& spCustomBuildTool, CComPtr<VCMidlTool>& spMidlTool)
{
strstream scout;
HRESULT hr;
hr = spDispFileTool->QueryInterface( __uuidof( VCCustomBuildTool ), (void**)&spCustomBuildTool );
if( FAILED( hr ) || !spCustomBuildTool )
{
scout << "Error: cannot get the raw interface of the custom build tool." << endl;
hr = spDispFileTool->QueryInterface( __uuidof( VCMidlTool ), (void**)&spMidlTool );
if( FAILED( hr ) || !spMidlTool )
{
scout << "Error: cannot get the raw interface of the midl tool." << endl;
}
else
{
return 2; // IDL file is "MIDL" built
}
}
else
{
return 1; // IDL file is "custom built"
}
return 0;
}
// called when settings from CPP file need to be copied to another CPP file
int VcprojHandler::copyCppSettings( CComDispatchDriver& dOld, CComDispatchDriver& dNew)
{
HRESULT hr;
static const int len = 6;
static char* props[ len ] =
{ "Optimization"
, "AdditionalIncludeDirectories"
, "PreprocessorDefinitions"
, "UsePrecompiledHeader"
, "BrowseInformation"
, "BasicRuntimeChecks"
};
// these option-set could be used to accomplish a complete copy of the deleted cpp file
static char * all_properties[] =
{ "AdditionalOptions"
, "Optimization"
, "GlobalOptimizations"
, "InlineFunctionExpansion"
, "EnableIntrinsicFunctions"
, "ImproveFloatingPointConsistency"
, "FavorSizeOrSpeed"
, "OmitFramePointers"
, "EnableFiberSafeOptimizations"
, "OptimizeForProcessor"
, "OptimizeForWindowsApplication"
, "AdditionalIncludeDirectories"
, "AdditionalUsingDirectories"
, "PreprocessorDefinitions"
, "IgnoreStandardIncludePath"
, "GeneratePreprocessedFile"
, "KeepComments"
, "StringPooling"
, "MinimalRebuild"
, "ExceptionHandling"
, "BasicRuntimeChecks"
, "SmallerTypeCheck"
, "RuntimeLibrary"
, "StructMemberAlignment"
, "BufferSecurityCheck"
, "EnableFunctionLevelLinking"
, "EnableEnhancedInstructionSet"
, "DisableLanguageExtensions"
, "DefaultCharIsUnsigned"
, "TreatWChar_tAsBuiltInType"
, "ForceConformanceInForLoopScope"
, "RuntimeTypeInfo"
, "UsePrecompiledHeader"
, "PrecompiledHeaderThrough"
, "PrecompiledHeaderFile"
, "ExpandAttributedSource"
, "AssemblerOutput"
, "AssemblerListingLocation"
, "ObjectFile"
, "ProgramDataBaseFileName"
, "BrowseInformation"
, "BrowseInformationFile"
, "WarningLevel"
, "WarnAsError"
, "SuppressStartupBanner"
, "Detect64BitPortabilityProblems"
, "DebugInformationFormat"
, "CompileAsManaged"
, "CallingConvention"
, "CompileAs"
, "DisableSpecificWarnings"
, "ForcedIncludeFiles"
, "ForcedUsingFiles"
, "ShowIncludes"
, "UndefinePreprocessorDefinitions"
, "UndefineAllPreprocessorDefinitions"
};
for( int i = 0; i < len; ++i)
{
CComVariant var;
hr = dOld.GetPropertyByName( CComBSTR( props[i]), &var);
hr = dNew.PutPropertyByName( CComBSTR( props[i]), &var);
}
return 0;
}
// called when settings from one custom built IDL file need to be copied to another custom built IDL file
int VcprojHandler::copyIdlSettings( CComDispatchDriver& dOld, CComDispatchDriver& dNew)
{
HRESULT hr;
static const int len = 3;
static char* props[ len ] =
{ "Description"
, "CommandLine"
, "Outputs"
};
for( int i = 0; i < len; ++i)
{
CComVariant var;
hr = dOld.GetPropertyByName( CComBSTR( props[i]), &var);
hr = dNew.PutPropertyByName( CComBSTR( props[i]), &var);
}
return 0;
}
// called when a MIDL built IDL file needs settings to be added (does not regard the old settings)
int VcprojHandler::prepareIdlSettingsForMIDL( CComPtr<VCMidlTool>& spMidlToolNew)
{
strstream scout;
HRESULT hr;
CComBSTR inc_path;
hr = spMidlToolNew->get_AdditionalIncludeDirectories( &inc_path);
if( SUCCEEDED( hr))
{
CString ip = inc_path;
if( -1 == ip.Find(".\\") && -1 == ip.Find("./"))
{
if( !ip.IsEmpty()) ip += ",";
ip += ".\\";
}
CComBSTR new_inc_path = ip;
hr = spMidlToolNew->put_AdditionalIncludeDirectories( new_inc_path);
if( FAILED( hr))
{
scout << "Error: could not set AdditionalIncludeDirectories property for MIDLTool." << endl;
}
}
else
{
scout << "Error: could not get AdditionalIncludeDirectories property for MIDLTool." << endl;
}
CComBSTR tlb_outputfile;
hr = spMidlToolNew->get_TypeLibraryName( &tlb_outputfile);
if( SUCCEEDED( hr))
{
CComBSTR new_tlb_outputfile("ComponentLib.tlb");
hr = spMidlToolNew->put_TypeLibraryName( new_tlb_outputfile);
if( FAILED( hr))
{
scout << "Error: could not set TypeLibraryName property for MIDLTool." << endl;
}
}
CComBSTR h_outputfile;
hr = spMidlToolNew->get_HeaderFileName( &h_outputfile);
if( SUCCEEDED( hr))
{
CComBSTR new_h_outputfile("ComponentLib.h");
hr = spMidlToolNew->put_HeaderFileName( new_h_outputfile);
if( FAILED( hr))
{
scout << "Error: could not set HeaderFileName property for MIDLTool." << endl;
}
}
return 1;
}
int VcprojHandler::doCompRenameAndGmeRelocate
( bool gme_loc_changed
, bool name_changed
, const CString& old_n
, const CString& new_n
, const CString& old_proj_name
, const CString& new_proj_name
, std::vector<std::string>& m_gmeSourceFiles
, std::string& strBONPath)
{
ostrstream scout;
HRESULT hr = S_OK;
// Create the VCProjectEngine
CComPtr<VCProjectEngine> spEngine;
hr = CoCreateInstance( __uuidof(VCProjectEngineObject), NULL, CLSCTX_INPROC_SERVER, __uuidof(VCProjectEngine), (void**)&spEngine );
if( FAILED( hr ) || !spEngine )
{
scout << "Error: cannot create VCProjectEngine object." << endl;
return 1;
}
// Open an existing project.
CComPtr<IDispatch> spDispProj;
hr = spEngine->LoadProject( CComBSTR( (LPCTSTR) old_proj_name ), &spDispProj );
if( FAILED( hr ) || !spDispProj )
{
scout << "Error: cannot open the specified project." << endl;
return 1;
}
CComQIPtr<VCProject> spProject = spDispProj;
if( !spProject )
{
scout << "Error: cannot query VCProject interface." << endl;
return 1;
}
if( name_changed) // if needed only
{
// Change the project's name
CComBSTR name, name_new(new_n);
hr = spProject->get_Name( &name);
if( SUCCEEDED( hr) && name == (LPCTSTR) old_n)
{
hr = spProject->put_Name( name_new );
if( FAILED( hr ) )
{
scout << "Error: cannot change project name." << endl;
}
}
}
//
// Access the configurations collection of the project
CComPtr<IDispatch> spDispConfigs;
hr = spProject->get_Configurations( &spDispConfigs );
if( FAILED( hr ) || !spDispConfigs )
{
scout << "Error: cannot access the configurations collecion." << endl;
return 1;
}
CComQIPtr<IVCCollection> spConfigCol = spDispConfigs;
long e = 0;
spConfigCol->get_Count( &e);
for( long i = 1; i <= e; ++i) // for each configuration
{
CComPtr<IDispatch> spDispConfig;
hr = spConfigCol->Item( CComVariant( (long) i), &spDispConfig );
if( FAILED( hr ) || !spDispConfig )
{
scout << "Error: cannot get the Debug configuraion." << endl;
return 1;
}
CComQIPtr<VCConfiguration> spConfig = spDispConfig;
// Access the Tools collection for this configuration
CComPtr<IDispatch> spDispTools;
hr = spConfig->get_Tools( &spDispTools );
if( FAILED( hr ) )
{
scout << "Error: cannot access the tools collection." << endl;
return 1;
}
CComQIPtr<IVCCollection> spToolCol = spDispTools;
{
// Enumerate the Tools collection
CComPtr<IDispatch> spDispTool1;
hr = spToolCol->Item( CComVariant( L"VCCLCompilerTool" ), &spDispTool1 );
if( FAILED( hr ) )
{
scout << "Error: cannot get IDispatch interface of the compiler tool." << endl;
}
else
{
// Get the VCCLCompilerTool interface and directly change a property
CComPtr<VCCLCompilerTool> spCLCompiler;
hr = spDispTool1->QueryInterface( __uuidof( VCCLCompilerTool ), (void**)&spCLCompiler );
if( FAILED( hr ) || !spCLCompiler )
{
scout << "Error: cannot get the raw interface of the compiler tool." << endl;
}
else
{
if( name_changed) // if needed only
{
//
// PrecompiledHeaderFile attribute
CComBSTR outf, outf_new;
hr = spCLCompiler->get_PrecompiledHeaderFile( &outf);
if( FAILED( hr ) )
{
scout << "Error: cannot get the PrecompiledHeaderFile property." << endl;
}
else
{
BSTRreplace( outf, outf_new, old_n, new_n);
hr = spCLCompiler->put_PrecompiledHeaderFile( outf_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the PrecompiledHeaderFile property." << endl;
}
}
}
if( gme_loc_changed) // if needed only
{
//
// AdditionalIncludeDirectories attribute
CComBSTR inc;
hr = spCLCompiler->get_AdditionalIncludeDirectories( &inc);
if( FAILED( hr ) )
{
scout << "Error: cannot get the AdditionalIncludeDirectories property." << endl;
}
else
{
CComBSTR inc_new( inc);
CString inc_d = inc;
if( inc_d.IsEmpty())
{
inc_new.Append("./,");
inc_new.Append( strBONPath.c_str() );
}
else
{
if( inc_d.Find("./") == -1 && inc_d.Find(".\\") == -1)
inc_new.Append(",./");
if( inc_d.Find( strBONPath.c_str()) == -1) // if it is not there already
{
inc_new.Append( ",");
inc_new.Append( strBONPath.c_str() );
}
}
hr = spCLCompiler->put_AdditionalIncludeDirectories( inc_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the AdditionalIncludeDirectories property." << endl;
}
}
}
}
}
}
{
CComPtr<IDispatch> spDispTool2;
hr = spToolCol->Item( CComVariant( L"VCLinkerTool" ), &spDispTool2 );
if( FAILED( hr ) )
{
scout << "Error: cannot get IDispatch interface of the linker tool." << endl;
}
else
{
if( name_changed) // if needed only
{
// Get the VCLinkerTool interface and directly change a property
CComPtr<VCLinkerTool> spLinker;
hr = spDispTool2->QueryInterface( __uuidof( VCLinkerTool ), (void**)&spLinker );
if( FAILED( hr ) || !spLinker )
{
scout << "Error: cannot get the raw interface of the linker tool." << endl;
}
else
{
// changing the OutputFile property
CComBSTR outf, outf_new;
hr = spLinker->get_OutputFile( &outf);
if( FAILED( hr ) )
{
scout << "Error: cannot get the OutputFile property." << endl;
}
else
{
BSTRreplace( outf, outf_new, old_n, new_n);
hr = spLinker->put_OutputFile( outf_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the OutputFile property." << endl;
}
}
// changing the ProgramDatabaseFile property
CComBSTR pdbf, pdbf_new;
hr = spLinker->get_ProgramDatabaseFile( &pdbf);
if( FAILED( hr ) )
{
scout << "Error: cannot get the ProgramDatabaseFile property." << endl;
}
else
{
BSTRreplace( pdbf, pdbf_new, old_n, new_n);
hr = spLinker->put_ProgramDatabaseFile( pdbf_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the ProgramDatabaseFile property." << endl;
}
}
// changing the ImportLibrary property
CComBSTR imlf, imlf_new;
hr = spLinker->get_ImportLibrary( &imlf);
if( FAILED( hr ) )
{
scout << "Error: cannot get the ImportLibrary property." << endl;
}
else
{
BSTRreplace( imlf, imlf_new, old_n, new_n);
hr = spLinker->put_ImportLibrary( imlf_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the ImportLibrary property." << endl;
}
}
}
}
}
}
{
CComPtr<IDispatch> spDispTool3;
hr = spToolCol->Item( CComVariant( L"VCMIDLTool" ), &spDispTool3 );
if( FAILED( hr ) )
{
scout << "Error: cannot get IDispatch interface of the MIDL tool." << endl;
}
else
{
if( name_changed) // if needed only
{
// Get the VCMIDLTool interface and directly change a property
CComPtr<VCMidlTool> spMidl;
hr = spDispTool3->QueryInterface( __uuidof( VCMidlTool ), (void**)&spMidl );
if( FAILED( hr ) || !spMidl )
{
scout << "Error: cannot get the raw interface of the MIDL tool." << endl;
}
else
{
CComBSTR tlbf, tlbf_new;
hr = spMidl->get_TypeLibraryName( &tlbf);
if( FAILED( hr ) )
{
scout << "Error: cannot get the TypeLibraryName property." << endl;
}
else
{
BSTRreplace( tlbf, tlbf_new, old_n, new_n);
hr = spMidl->put_TypeLibraryName( tlbf_new);
if( FAILED( hr ) )
{
scout << "Error: cannot set the TypeLibraryName property." << endl;
}
}
}
}
}
}
}
//
// Access Files collection
CComPtr<IDispatch> spDispFiles;
hr = spProject->get_Files( &spDispFiles );
if( SUCCEEDED( hr ) )
{
CComQIPtr<IVCCollection> spCol = spDispFiles;
// Access all files in the project
long e1 = 0;
spCol->get_Count( &e1);
for( long i1 = 1; i1 <= e1; ++i1)
{
CComPtr<IDispatch> spDispFile;
hr = spCol->Item( CComVariant( (long) i1), &spDispFile );
if( SUCCEEDED( hr ) )
{
CComQIPtr<VCFile> spFile = spDispFile;
CComBSTR rp;
hr = spFile->get_RelativePath( &rp);
if( SUCCEEDED( hr))
{
CString r = rp;
bool found = false;
for( unsigned int j = 0; !found && j < m_gmeSourceFiles.size(); ++j)
{
CString mmm = m_gmeSourceFiles[j].c_str();
if( -1 != r.Find( m_gmeSourceFiles[j].c_str()))
found = true;
}
if( found && --j < m_gmeSourceFiles.size())
{
// found, so change its relative path
CString new_str = strBONPath.c_str();
new_str += m_gmeSourceFiles[j].c_str();
new_str.Replace( "/", "\\");
CComBSTR new_rp = new_str;
if( 0 != r.CompareNoCase( new_str))
{
swapFiles( spFile, rp, new_rp, spProject); // spFile will be deleted
}
}
}
}
}
}
// ---------- DONE with transformations, must save it--------
// the name may be equal with the old name since the name must not change
// so the file might exist
hr = spProject->put_ProjectFile( CComBSTR( (LPCTSTR) new_proj_name ) );
if( FAILED( hr ) )
{
scout << "Error: cannot set new project file name." << endl;
}
bool save_failed = false;
hr = spProject->Save( );
if( FAILED( hr ) )
{
scout << "Error: cannot save project." << endl;
save_failed = true;
}
spEngine->RemoveProject( spDispProj );
if( save_failed && scout.pcount() > 0) // any errors on the stream ?
{
return 1;
}
return 0;
}
--- NEW FILE: VcprojHandler.h ---
#include "afx.h"
#include <atlbase.h>
#import <VCProjectEngine.dll> raw_interfaces_only raw_native_types
using namespace VCProjectEngineLibrary;
#include <strstream>
#include <map>
#include <vector>
#include <cassert>
using namespace std;
class VcprojHandler
{
public:
static int doCompRenameAndGmeRelocate
( bool gme_loc_changed
, bool name_changed
, const CString& old_n
, const CString& new_n
, const CString& old_proj_name
, const CString& new_proj_name
//, const CString& proj_name
, std::vector<std::string>& m_gmeSourceFiles
, std::string& strBONPath
);
protected:
static void BSTRreplace( const CComBSTR& outf, CComBSTR& outf_new, const CString& old_n, const CString& new_n);
static int swapFiles( CComPtr<VCFile>& spOldFile, const CComBSTR& oldf, const CComBSTR& newf, CComPtr<VCProject>& spProject);
static int copyCppSettings( CComDispatchDriver& dOld, CComDispatchDriver& dNew);
static int whichIDLTool( CComPtr<IDispatch>& spDispFileTool, CComPtr<VCCustomBuildTool>& spCustomBuildTool, CComPtr<VCMidlTool>& spMidlTool);
static int copyIdlSettings( CComDispatchDriver& dOld, CComDispatchDriver& dNew);
static int prepareIdlSettingsForMIDL( CComPtr<VCMidlTool>& spMidlToolNew);
};
Index: EventMaskDialog.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/tools/ComponentConfig/EventMaskDialog.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** EventMaskDialog.h 30 May 2001 15:48:00 -0000 1.1
--- EventMaskDialog.h 31 Jan 2005 20:23:28 -0000 1.2
***************
*** 7,11 ****
// EventMaskDialog.h : header file
//
! #include <fstream.h>
/////////////////////////////////////////////////////////////////////////////
--- 7,12 ----
// EventMaskDialog.h : header file
//
! #include <fstream>
! using namespace std;
/////////////////////////////////////////////////////////////////////////////
Index: InterpreterConfigDlg.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/tools/ComponentConfig/InterpreterConfigDlg.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** InterpreterConfigDlg.cpp 16 Apr 2004 10:45:08 -0000 1.14
--- InterpreterConfigDlg.cpp 31 Jan 2005 20:23:28 -0000 1.15
***************
*** 88,91 ****
--- 88,97 ----
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+ CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+ }
+
+ CInterpreterConfigDlg::~CInterpreterConfigDlg()
+ {
+ CoUninitialize();
}
***************
*** 188,191 ****
--- 194,198 ----
if(!ReadConfig()) exit(-1);
+ m_initialGMEPath = m_strGmePath; // save it, to check it later if it changes
GetDlgItem(IDC_PARNAME)->EnableWindow(!m_parindep);
***************
*** 452,464 ****
}
! void CInterpreterConfigDlg::updateDSPFile( const char * dspFileName )
{
! int i;
!
! std::ifstream is( dspFileName );
if( !is.good() )
return;
! std::ofstream os( "temp.dsp" );
std::string sdkBONPath = m_strGmePath;
--- 459,504 ----
}
! void CInterpreterConfigDlg::updateVcprojFile( const char * vcprojFileName )
{
! std::ifstream is( vcprojFileName );
if( !is.good() )
return;
+ is.close();
!
! bool is_gmeloc_changed = false, is_compname_changed = false;
!
! CString t1 = m_initialGMEPath;
! CString t2 = m_strGmePath;
! t1.Replace("\\","/");
! t2.Replace("\\","/");
!
! if( t1.CompareNoCase( t2) != 0) // the location of GME has changed
! is_gmeloc_changed = true;
! if( m_CompName != sPreviousComponentName) // the component name has changed
! is_compname_changed = true;
!
! try
! {
! std::string sdkBONPath = m_strGmePath;
! sdkBONPath += "/sdk/BON/";
!
! RenameComponent7 component
! ( is_gmeloc_changed
! , is_compname_changed
! , m_gmeSourceFiles
! , sdkBONPath
! , (LPCTSTR)vcprojFileName
! , (LPCTSTR)m_CompName
! , (LPCTSTR)sPreviousComponentName
! );
!
! }
! catch(...)
! {
! AfxMessageBox( "Could not perform component rename");
! }
!
! /* std::ofstream os( "temp.dsp" );
std::string sdkBONPath = m_strGmePath;
***************
*** 522,527 ****
CopyFile( "temp.dsp", dspFileName, FALSE );
! DeleteFile( "temp.dsp" );
! RenameComponent component( (LPCTSTR)m_CompName, (LPCTSTR)dspFileName, (LPCTSTR)sPreviousComponentName );
}
--- 562,566 ----
CopyFile( "temp.dsp", dspFileName, FALSE );
! DeleteFile( "temp.dsp" );*/
}
***************
*** 623,639 ****
close(f);
! updateDSPFile( "BONComponent.dsp" );
! updateDSPFile( "Component.dsp" );
! updateDSPFile( "OLDBONComponent.dsp" );
! updateDSPFile( "BON2Component.dsp" );
! updateDSPFile( sPreviousComponentName + "BONComponent.dsp" );
! updateDSPFile( sPreviousComponentName + "Component.dsp" );
! updateDSPFile( sPreviousComponentName + "OLDBONComponent.dsp" );
! updateDSPFile( sPreviousComponentName + "BON2Component.dsp" );
CDialog::OnOK();
MessageBox(configfilename + " has been successfully created.\n"
! "You may open the ...component.dsw workspace now.\n", "ConfigureComponent");
}
--- 662,679 ----
close(f);
! updateVcprojFile( "BONComponent.vcproj" );
! updateVcprojFile( "Component.vcproj" );
! updateVcprojFile( "OLDBONComponent.vcproj" );
! updateVcprojFile( "BON2Component.vcproj" );
! updateVcprojFile( sPreviousComponentName + "BONComponent.vcproj" );
! updateVcprojFile( sPreviousComponentName + "Component.vcproj" );
! updateVcprojFile( sPreviousComponentName + "OLDBONComponent.vcproj" );
! updateVcprojFile( sPreviousComponentName + "BON2Component.vcproj" );
CDialog::OnOK();
MessageBox(configfilename + " has been successfully created.\n"
! "You may open the ...component.sln solution now.\n", "ConfigureComponent");
!
}
Index: InterpreterConfigDlg.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/tools/ComponentConfig/InterpreterConfigDlg.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** InterpreterConfigDlg.h 6 Oct 2003 14:57:58 -0000 1.9
--- InterpreterConfigDlg.h 31 Jan 2005 20:23:28 -0000 1.10
***************
*** 23,26 ****
--- 23,27 ----
int componenttechnology;
CInterpreterConfigDlg(CWnd* pParent = NULL); // standard constructor
+ virtual ~CInterpreterConfigDlg();
CString sPreviousComponentName;
***************
*** 58,61 ****
--- 59,63 ----
CString m_gmeSourcePath;
std::vector<std::string> m_gmeSourceFiles;
+ CString m_initialGMEPath;
// Generated message map functions
***************
*** 88,92 ****
void readGmeSourceFileList ();
! void updateDSPFile ( const char * dspFileName );
};
--- 90,94 ----
void readGmeSourceFileList ();
! void updateVcprojFile ( const char * vcprojFileName );
};
Index: RenameComponent.h
===================================================================
RCS file: /var/lib/gme/GMESRC/SDK/BON/tools/ComponentConfig/RenameComponent.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RenameComponent.h 16 Apr 2004 11:13:23 -0000 1.4
--- RenameComponent.h 31 Jan 2005 20:23:28 -0000 1.5
***************
*** 1,4 ****
--- 1,5 ----
#pragma warning ( disable : 4786 )
+ #include "VcprojHandler.h"
#include <fstream>
#include <map>
***************
*** 94,97 ****
--- 95,234 ----
// end class SearchAndReplace
+ /************************RenameComponent7 class*************************
+ ReWritten by Zoltan Molnar
+
+ Purpose: Similar to RenameComponent, for Visual Studio 7
+
+ Files modified:
+ - *.vcproj --> becomes [componentName]originalName.vcproj
+ --> changes all calls to the component identity
+ to match that of 'componentName' instead of 'Component'
+ - *.def --> sets file access rights to normal
+ --> changes the name of the output .DLL
+ --> resets file access rights to readonly
+ - *.sln --> changes the name of the .vcproj file included, and
+ the name of the component it represents to reflect
+ the wishes of the interpreter writer
+
+ **********************************************************************/
+ class RenameComponent7
+ {
+ public:
+ RenameComponent7
+ ( bool is_gmeloc_changed
+ , bool is_compname_changed
+ , std::vector<std::string>& m_gmeSourceFiles
+ , std::string& strBONPath
+ , string _vcprojFileName
+ , string _componentName // new component name
+ , string _oldComponentName="Component"
+ )
+
+ : oldVcprojFileName( _vcprojFileName )
+ , componentName( _componentName )
+ , oldComponentName( _oldComponentName )
+ {
+ if( oldComponentName == "" ) oldComponentName = "Component";
+
+ // calculate the new vcproj filename
+ newVcprojFileName = oldVcprojFileName;
+ int pos = newVcprojFileName.find( oldComponentName);
+ if( pos != string::npos) // found
+ {
+ newVcprojFileName.replace( pos, oldComponentName.length(), componentName);
+ if( newVcprojFileName.length() >= 7
+ && newVcprojFileName.substr( newVcprojFileName.length() - 7, 7).compare( ".vcproj") != 0)
+ {
+ newVcprojFileName += ".vcproj"; // make sure the extension is there
+ }
+ }
+
+ proj2sln["Component.vcproj"] = "Component.sln";
+ proj2sln["BONComponent.vcproj"] = "BONComponent.sln";
+ proj2sln["BON2Component.vcproj"] = "BON2Component.sln";
+ if( oldComponentName.compare( "Component" ) != 0 )
+ {
+ if( oldVcprojFileName.find( "BON2" ) != -1 )
+ {
+ proj2sln[oldComponentName + "BON2Component.vcproj"] = "BON2Component.sln";
+ }
+ else if( oldVcprojFileName.find( "BON" ) != -1 )
+ {
+ proj2sln[oldComponentName + "BONComponent.vcproj"] = "BONComponent.sln";
+ }
+ else
+ {
+ proj2sln[oldComponentName + "Component.vcproj"] = "Component.sln";
+ }
+ }
+
+ if( is_gmeloc_changed || is_compname_changed)
+ {
+ // make a backup file is we are going to touch the project file
+ bool can_delete = false;
+ CString backup = oldVcprojFileName.c_str();
+ backup += ".old";
+ SetLastError( 0);
+
+ // make a copy of the original project file with ".old" extension
+ CopyFile( oldVcprojFileName.c_str(), (LPCTSTR)backup, FALSE); // FALSE: don't fail if ".old" already exists, overwrite it
+
+ if( 0 == GetLastError()) // success
+ can_delete = true;
+
+ if( 0 == VcprojHandler::doCompRenameAndGmeRelocate
+ ( is_gmeloc_changed
+ , is_compname_changed
+ , oldComponentName.c_str()
+ , componentName.c_str()
+ , oldVcprojFileName.c_str()
+ , newVcprojFileName.c_str()
+ , m_gmeSourceFiles
+ , strBONPath))
+ {
+ if( is_compname_changed && can_delete) // delete the old project file only if the name has changed, and the backup was successful
+ {
+ DeleteFile( oldVcprojFileName.c_str());
+ }
+
+ if( is_compname_changed) // these are changing only if compname_changed
+ {
+ doSln();
+ doDef();
+ }
+ }
+ else
+ throw "Component Rename failed";
+ }
+ }
+
+ string getComponentName( ) { return componentName; }
+
+ protected:
+ string oldVcprojFileName;
+ string newVcprojFileName;
+ string componentName;
+ string oldComponentName;
+ map<string, string> proj2sln;
+
+ void doDef( )
+ {
+ map<string,string> _s_r;
+ _s_r[oldComponentName + ".DLL"] = componentName + ".DLL";
+ SetFileAttributes( "component.def", FILE_ATTRIBUTE_NORMAL );
+ SearchAndReplace::replace( _s_r, "component.def" );
+ SetFileAttributes( "component.def", FILE_ATTRIBUTE_READONLY );
+ }
+ void doSln( )
+ {
+ assert( proj2sln.find(oldVcprojFileName) != proj2sln.end( ) );
+ string slnName = proj2sln[oldVcprojFileName];
+ map<string,string> _s_r;
+ _s_r["\"" + oldComponentName + "\""] = "\"" + componentName + "\"";
+ _s_r[oldVcprojFileName] = newVcprojFileName;
+ SearchAndReplace::replace( _s_r, slnName );
+ }
+ };
+
/************************RenameComponent class*************************
Written by Jonathan Sprinkle
***************
*** 116,120 ****
**********************************************************************/
! class RenameComponent
{
public:
--- 253,257 ----
**********************************************************************/
! class RenameComponent // obsolete, please use RenameComponent7 instead
{
public:
--- ComponentConfig.dsp DELETED ---
More information about the GME-commit
mailing list