// SimpleApplicationWizardaw.cpp : implementation file
//
#include "stdafx.h"
#include "SimpleApplicationWizard.h"
#include "SimpleApplicationWizardaw.h"
#include "chooser.h"
#ifdef _PSEUDO_DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// This is called immediately after the custom AppWizard is loaded. Initialize
// the state of the custom AppWizard here.
void CSimpleApplicationWizardAppWiz::InitCustomAppWiz()
{
// Create a new dialog chooser; CDialogChooser's constructor initializes
// its internal array with pointers to the steps.
m_pChooser = new CDialogChooser;
// Set the maximum number of steps.
SetNumberOfSteps(LAST_DLG);
// TODO: Add any other custom AppWizard-wide initialization here.
}
// This is called just before the custom AppWizard is unloaded.
void CSimpleApplicationWizardAppWiz::ExitCustomAppWiz()
{
// Deallocate memory used for the dialog chooser
ASSERT(m_pChooser != NULL);
delete m_pChooser;
m_pChooser = NULL;
// TODO: Add code here to deallocate resources used by the custom AppWizard
}
// This is called when the user clicks "Create..." on the New Project dialog
// or "Next" on one of the custom AppWizard's steps.
CAppWizStepDlg* CSimpleApplicationWizardAppWiz::Next(CAppWizStepDlg* pDlg)
{
// Delegate to the dialog chooser
return m_pChooser->Next(pDlg);
}
// This is called when the user clicks "Back" on one of the custom
// AppWizard's steps.
CAppWizStepDlg* CSimpleApplicationWizardAppWiz::Back(CAppWizStepDlg* pDlg)
{
// Delegate to the dialog chooser
return m_pChooser->Back(pDlg);
}
void CSimpleApplicationWizardAppWiz::CustomizeProject(IBuildProject* pProject)
{
CComPtr<IConfigurations> pConfigs;
HRESULT hr=pProject->get_Configurations(&pConfigs);
if(FAILED(hr))
{
AfxMessageBox("An error occurred while obtaining the IConfigurations interface pointer");
return;
}
CComPtr<IConfiguration> pConfig;
CComVariant index;
VARIANT dummy = {0};
CComBSTR Name;
CString text;
CString output;
long Count=0;
pConfigs->get_Count(&Count);
// Iterate through all the configurations of the project
for(int i=1; i <= Count; i++)
{
index=i;
hr=pConfigs->Item(index, &pConfig);
if(FAILED(hr))
{
AfxMessageBox("An error occurred while obtaining the IConfiguration pointer");
return;
}
pConfig->get_Name(&Name);
text = Name;
if (text.Find("Debug") == -1)
output = "Release";
else
output = "Debug";
text.Format("/out:\"%s/%s.exe\"",output,m_Dictionary["Root"]);
pConfig->AddToolSettings(L"link.exe", text.AllocSysString(), dummy);
pConfig->AddToolSettings(L"mfc", L"0", dummy);
pConfig->AddToolSettings(L"link.exe", L"/subsystem:windows", dummy);
pConfig->AddToolSettings(L"link.exe", L"/incremental:yes", dummy);
pConfig->AddToolSettings(L"link.exe", L"/machine:I386", dummy);
pConfig->AddToolSettings(L"link.exe", L"/nodefaultlib:\"MSVCRTD\"", dummy);
// change the preprocessor definitions
pConfig->AddToolSettings(L"cl.exe", L"/D \"_WINDOWS\"", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/nologo", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/D \"_MBCS\"", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/D \"WIN32\"", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/Od", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/MD", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/W3", dummy);
pConfig->AddToolSettings(L"cl.exe", L"/ZI", dummy); // Program Database for "Edit & Continue" can not be defined when /driver option is defined
pConfig->AddToolSettings(L"cl.exe", L"/GZ", dummy); //GZ initializes all local variables not explicitly initialized by the program. It fills all memory used by these variables with 0xCC
pConfig->AddToolSettings(L"cl.exe", L"/Zi", dummy); // Program Database
pConfig->AddToolSettings(L"cl.exe", L"/Oi", dummy); //
pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy); // __stdcall calling convention
pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy);
// Change the libraries
pConfig->AddToolSettings(L"link.exe", L"kernel32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"user32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"gdi32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"winspool.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"comdlg32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"advapi32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"shell32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"ole32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"oleaut32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"uuid.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"odbc32.lib", dummy);
pConfig->AddToolSettings(L"link.exe", L"odbccp32.lib", dummy);
CString cstr;
if(m_Dictionary.Lookup(TEXT("INIT_COMMON_CONTROLS"),cstr))
{
pConfig->AddToolSettings(L"link.exe", L"comctl32.lib", dummy);
}
if(m_Dictionary.Lookup(TEXT("USE_WINSOCK"),cstr))
{
pConfig->AddToolSettings(L"link.exe", L"ws2_32.lib", dummy);
}
pConfig=NULL;
}
pConfigs=NULL;
}
// Here we define one instance of the CSimpleApplicationWizardAppWiz class. You can access
// m_Dictionary and any other public members of this class through the
// global SimpleApplicationWizardaw.
CSimpleApplicationWizardAppWiz SimpleApplicationWizardaw;