| 1 |
// PreviewPage.cpp : implementation file |
|---|
| 2 |
// |
|---|
| 3 |
|
|---|
| 4 |
#include "stdafx.h" |
|---|
| 5 |
#include "Elephant.h" |
|---|
| 6 |
#include "PreviewPage.h" |
|---|
| 7 |
|
|---|
| 8 |
#ifdef _DEBUG |
|---|
| 9 |
#define new DEBUG_NEW |
|---|
| 10 |
#undef THIS_FILE |
|---|
| 11 |
static char THIS_FILE[] = __FILE__; |
|---|
| 12 |
#endif |
|---|
| 13 |
|
|---|
| 14 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 15 |
// CPreviewPage dialog |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
CPreviewPage::CPreviewPage(CWnd* pParent /*=NULL*/) |
|---|
| 19 |
|
|---|
| 20 |
{ |
|---|
| 21 |
//{{AFX_DATA_INIT(CPreviewPage) |
|---|
| 22 |
m_text = _T(""); |
|---|
| 23 |
//}}AFX_DATA_INIT |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
void CPreviewPage::DoDataExchange(CDataExchange* pDX) |
|---|
| 28 |
{ |
|---|
| 29 |
CDialog::DoDataExchange(pDX); |
|---|
| 30 |
//{{AFX_DATA_MAP(CPreviewPage) |
|---|
| 31 |
DDX_Control(pDX, IDC_BUTTON2, m_generate); |
|---|
| 32 |
DDX_Control(pDX, IDC_BUTTON1, m_clear); |
|---|
| 33 |
DDX_Text(pDX, IDC_EDIT1, m_text); |
|---|
| 34 |
//}}AFX_DATA_MAP |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
BEGIN_MESSAGE_MAP(CPreviewPage, CRHGenericChildDialog) |
|---|
| 39 |
//{{AFX_MSG_MAP(CPreviewPage) |
|---|
| 40 |
ON_BN_CLICKED(IDC_BUTTON1, OnGenerate) |
|---|
| 41 |
ON_BN_CLICKED(IDC_BUTTON2, OnClear) |
|---|
| 42 |
//}}AFX_MSG_MAP |
|---|
| 43 |
END_MESSAGE_MAP() |
|---|
| 44 |
|
|---|
| 45 |
///////////////////////////////////////////////////////////////////////////// |
|---|
| 46 |
// CPreviewPage message handlers |
|---|
| 47 |
|
|---|
| 48 |
BOOL CPreviewPage::OnInitDialog() |
|---|
| 49 |
{ |
|---|
| 50 |
CRHGenericChildDialog::OnInitDialog(); |
|---|
| 51 |
|
|---|
| 52 |
SetupButton(&m_clear); |
|---|
| 53 |
SetupButton(&m_generate); |
|---|
| 54 |
|
|---|
| 55 |
return TRUE; // return TRUE unless you set the focus to a control |
|---|
| 56 |
// EXCEPTION: OCX Property Pages should return FALSE |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
void unused(const string& msg ) |
|---|
| 60 |
{ |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
void CPreviewPage::OnGenerate() |
|---|
| 65 |
{ |
|---|
| 66 |
|
|---|
| 67 |
if ( Globals::currentProject ) |
|---|
| 68 |
{ |
|---|
| 69 |
if ( 1 ) //Globals::currentProject->GetCache("buildType") == "0") |
|---|
| 70 |
{ |
|---|
| 71 |
|
|---|
| 72 |
ProjectSettings* p = Globals::currentProject; |
|---|
| 73 |
string activeConfig = p->GetCache("CurrentConfiguration"); |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
// m_inline = Globals::currentProject->GetCache(currentConfig + "_inline") == "1"; |
|---|
| 77 |
// m_optimize = Globals::currentProject->GetCache(currentConfig + "_optimize") == "1"; |
|---|
| 78 |
// m_allowDeprecated = Globals::currentProject->GetCache(currentConfig + "_allowDeprecated") == "1"; |
|---|
| 79 |
// m_warnings = Globals::currentProject->GetCache(currentConfig + "_warnings") == "1"; |
|---|
| 80 |
// m_verbose = Globals::currentProject->GetCache(currentConfig + "_verbose") == "1"; |
|---|
| 81 |
// m_release = Globals::currentProject->GetCache(currentConfig + "_release") == "1"; |
|---|
| 82 |
// m_debug = Globals::currentProject->GetCache(currentConfig + "_debugG") == "1"; |
|---|
| 83 |
// m_pHooks = Globals::currentProject->GetCache(currentConfig + "_pHooks") == "1"; |
|---|
| 84 |
// m_unittest = Globals::currentProject->GetCache(currentConfig + "_unittest") == "1"; |
|---|
| 85 |
|
|---|
| 86 |
CompilerFlags flags; |
|---|
| 87 |
flags.allowDeprecated = Globals::currentProject->GetCache(activeConfig + "_allowDeprecated") == "1"; |
|---|
| 88 |
flags.debug = Globals::currentProject->GetCache(activeConfig + "_debugG") == "1"; |
|---|
| 89 |
flags.debugInfo = Globals::currentProject->GetCache(activeConfig + "_debugInfo") == "1"; |
|---|
| 90 |
flags.debugIdentifiers = Globals::currentProject->GetCache(activeConfig + "_debugIdentifiers"); |
|---|
| 91 |
flags.debugPHooks = Globals::currentProject->GetCache(activeConfig + "_pHooks") == "1"; |
|---|
| 92 |
flags.inline_ = Globals::currentProject->GetCache(activeConfig + "_inline") == "1"; |
|---|
| 93 |
flags.optimize = Globals::currentProject->GetCache(activeConfig + "_optimize") == "1" ; |
|---|
| 94 |
flags.release = Globals::currentProject->GetCache(activeConfig + "_release") == "1"; |
|---|
| 95 |
//flagsactiveConfig + ._sharedLib = Globals |
|---|
| 96 |
flags.unitTest = Globals::currentProject->GetCache(activeConfig + "_unittest") == "1"; |
|---|
| 97 |
flags.verbose = Globals::currentProject->GetCache(activeConfig + "_verbose") == "1"; |
|---|
| 98 |
flags.versionIdentifiers = Globals::currentProject->GetCache(activeConfig + "_versionIdentifiers"); |
|---|
| 99 |
flags.staticLib = Globals::currentProject->GetCache(activeConfig + "_staticLib") == "1"; |
|---|
| 100 |
flags.sharedLib = Globals::currentProject->GetCache(activeConfig + "_sharedLib") == "1"; |
|---|
| 101 |
flags.warning = Globals::currentProject->GetCache(activeConfig + "_warning") == "1"; |
|---|
| 102 |
Split(Globals::settings->baseSettings->GetCache("importPaths"),",",flags.importPaths ); |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
string compilerLocation , linkLocation , libLocation, libEnvVar, projectLocation , projectName, |
|---|
| 107 |
installPath, objectDir , resourceFile; |
|---|
| 108 |
|
|---|
| 109 |
vector<string> files , libs, linkerFlags, imports; |
|---|
| 110 |
|
|---|
| 111 |
string dmdPath = Globals::settings->baseSettings->GetCache("dmdPath"); |
|---|
| 112 |
compilerLocation = dmdPath ; |
|---|
| 113 |
dmdPath = StripDirPath(dmdPath) + "\\"; |
|---|
| 114 |
linkLocation = dmdPath + "..\\..\\dm\\bin\\link.exe"; |
|---|
| 115 |
libLocation = dmdPath + "..\\..\\dm\\bin\\lib.exe"; |
|---|
| 116 |
libEnvVar = dmdPath + "..\\lib;" + dmdPath + "..\\..\\dm\\lib"; |
|---|
| 117 |
projectLocation = Globals::currentProject->path; |
|---|
| 118 |
projectName = Globals::currentProject->name; |
|---|
| 119 |
installPath = Globals::settings->baseSettings->GetCache("installPath"); |
|---|
| 120 |
|
|---|
| 121 |
// ElephantMessageBox(projectLocation.c_str()); |
|---|
| 122 |
|
|---|
| 123 |
objectDir = shortPathName(objectDir); |
|---|
| 124 |
|
|---|
| 125 |
//ElephantMessageBox(string(projectLocation + "\\" + projectName + "_object").c_str()); |
|---|
| 126 |
|
|---|
| 127 |
//ElephantMessageBox(objectDir.c_str()); |
|---|
| 128 |
|
|---|
| 129 |
Split(Globals::currentProject->GetCache("files"),",",files); |
|---|
| 130 |
Split(Globals::currentProject->GetCache("libraries"),",",libs); |
|---|
| 131 |
Split(Globals::settings->baseSettings->GetCache("importPaths"),",",imports); |
|---|
| 132 |
|
|---|
| 133 |
vector<FileExtensionItem> extensions; |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
BuildFlags f; |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
f.names = p->GetCache(activeConfig + "_names") == "1"; |
|---|
| 141 |
f.full = p->GetCache(activeConfig + "_full") == "1"; |
|---|
| 142 |
f.link = p->GetCache(activeConfig + "_link") == "1"; |
|---|
| 143 |
f.nolink = p->GetCache(activeConfig + "_nolink") == "1"; |
|---|
| 144 |
f.lib = p->GetCache(activeConfig + "_lib") == "1"; |
|---|
| 145 |
f.nolib = p->GetCache(activeConfig + "_nolib") == "1"; |
|---|
| 146 |
f.obj = p->GetCache(activeConfig + "_obj") == "1"; |
|---|
| 147 |
f.silent = p->GetCache(activeConfig + "_silent") == "1"; |
|---|
| 148 |
f.allobj = p->GetCache(activeConfig + "_allobj") == "1"; |
|---|
| 149 |
f.test = p->GetCache(activeConfig + "_test") == "1"; |
|---|
| 150 |
f.dll = p->GetCache(activeConfig + "_dll") == "1"; |
|---|
| 151 |
f.gui = p->GetCache(activeConfig + "_gui") == "1"; |
|---|
| 152 |
f.clean = p->GetCache(activeConfig + "_clean") == "1"; |
|---|
| 153 |
f.v = p->GetCache(activeConfig + "_v") == "1"; |
|---|
| 154 |
f.X = p->GetCache(activeConfig + "_X").c_str(); |
|---|
| 155 |
f.M = p->GetCache(activeConfig + "_M").c_str(); |
|---|
| 156 |
f.verbatim = p->GetCache(activeConfig + "_verbatim").c_str(); |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
BuildProjectCompilerSettings settings2(flags,f,files,compilerLocation , |
|---|
| 163 |
linkLocation, libLocation, libEnvVar, projectLocation, |
|---|
| 164 |
projectName, installPath, objectDir, resourceFile, libs, linkerFlags,imports ); |
|---|
| 165 |
settings2.buildPath = "build.exe"; |
|---|
| 166 |
Globals::buildCompiler->SetSession(settings2,unused); |
|---|
| 167 |
string text = Globals::buildCompiler->AssembleFlags(); |
|---|
| 168 |
m_text = text.c_str(); |
|---|
| 169 |
UpdateData(FALSE); |
|---|
| 170 |
|
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
else if ( Globals::currentProject->GetCache("buildType") == "1") |
|---|
| 174 |
{ |
|---|
| 175 |
string make = Globals::settings->baseSettings->GetCache("makePath"); |
|---|
| 176 |
string makefilePath = Globals::currentProject->GetCache("makefilePath"); |
|---|
| 177 |
string cmd = make + " -f " + makefilePath; |
|---|
| 178 |
|
|---|
| 179 |
m_text = cmd.c_str(); |
|---|
| 180 |
UpdateData(FALSE); |
|---|
| 181 |
|
|---|
| 182 |
} |
|---|
| 183 |
else if ( Globals::currentProject->GetCache("buildType") == "2" ) |
|---|
| 184 |
{ |
|---|
| 185 |
|
|---|
| 186 |
string cmd = Globals::currentProject->GetCache("scriptPath"); |
|---|
| 187 |
m_text = cmd.c_str(); |
|---|
| 188 |
UpdateData(FALSE); |
|---|
| 189 |
|
|---|
| 190 |
} |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
void CPreviewPage::OnClear() |
|---|
| 196 |
{ |
|---|
| 197 |
m_text = ""; |
|---|
| 198 |
UpdateData(FALSE) ; |
|---|
| 199 |
} |
|---|