Code::Blocks  SVN r11506
compilerMSVC.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  *
5  * $Revision: 8649 $
6  * $Id: compilerMSVC.cpp 8649 2012-12-12 19:18:18Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/compilergcc/compilerMSVC.cpp $
8  */
9 
10 #include <sdk.h>
11 #include "compilerMSVC.h"
12 #include <wx/wx.h>
13 #include <wx/intl.h>
14 #include <wx/regex.h>
15 #include <wx/config.h>
16 #ifdef __WXMSW__
17  #include <wx/msw/registry.h>
18 #endif // __WXMSW__
19 
21  : Compiler(_("Microsoft Visual C++ Toolkit 2003"), _T("msvctk"))
22 {
23  m_Weight = 8;
24  Reset();
25 }
26 
28 {
29  //dtor
30 }
31 
33 {
34  return (new CompilerMSVC(*this));
35 }
36 
38 {
40 
41  // Read the VCToolkitInstallDir environment variable
42  wxGetEnv(_T("VCToolkitInstallDir"), &m_MasterPath);
43 
44  if (m_MasterPath.IsEmpty())
45  {
46  // just a guess; the default installation dir
47  wxString Programs = _T("C:\\Program Files");
48  // what's the "Program Files" location
49  // TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)"
50  // 64 bit apps are in "ProgramFiles"
51  wxGetEnv(_T("ProgramFiles"), &Programs);
52  m_MasterPath = Programs + _T("\\Microsoft Visual C++ Toolkit 2003");
53  }
54  if (!m_MasterPath.IsEmpty())
55  {
56  AddIncludeDir(m_MasterPath + sep + _T("include"));
57  AddLibDir(m_MasterPath + sep + _T("lib"));
58 
59 #ifdef __WXMSW__
60  // add include dirs for MS Platform SDK too
61  wxRegKey key; // defaults to HKCR
62  key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\Win32SDK\\Directories"));
63  if (key.Exists() && key.Open(wxRegKey::Read))
64  {
65  wxString dir;
66  key.QueryValue(_T("Install Dir"), dir);
67  if (!dir.IsEmpty())
68  {
69  if (dir.GetChar(dir.Length() - 1) != '\\')
70  dir += sep;
71  AddIncludeDir(dir + _T("include"));
72  AddLibDir(dir + _T("lib"));
73  m_ExtraPaths.Add(dir + _T("bin"));
74  }
75  }
76 
77  // add extra paths for "Debugging tools" too
78  key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\DebuggingTools"));
79  if (key.Exists() && key.Open(wxRegKey::Read))
80  {
81  wxString dir;
82  key.QueryValue(_T("WinDbg"), dir);
83  if (!dir.IsEmpty())
84  {
85  if (dir.GetChar(dir.Length() - 1) == '\\')
86  dir.Remove(dir.Length() - 1, 1);
87  m_ExtraPaths.Add(dir);
88  }
89  }
90 #endif // __WXMSW__
91  }
92 
93  return wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed;
94 }
virtual ~CompilerMSVC()
bool wxGetEnv(const wxString &var, wxString *value)
bool wxFileExists(const wxString &filename)
size_t Length() const
virtual void Reset()
Reset settings to defaults.
Definition: compiler.cpp:157
#define _T(string)
virtual void AddIncludeDir(const wxString &option)
virtual AutoDetectResult AutoDetectInstallationDir()
Try to auto-detect the compiler&#39;s installation directory.
bool QueryValue(const wxString &szValue, wxString &strValue, bool raw) const
CompilerPrograms m_Programs
Definition: compiler.h:412
wxString & Remove(size_t pos)
AutoDetectResult
Definition: compiler.h:190
virtual void AddLibDir(const wxString &option)
static const wxString sep
wxArrayString m_ExtraPaths
Definition: compiler.h:410
static wxUniChar GetPathSeparator(wxPathFormat format=wxPATH_NATIVE)
const wxString & _(const wxString &string)
Abstract base class for compilers.
Definition: compiler.h:274
bool IsEmpty() const
wxString C
Definition: compiler.h:199
wxString m_MasterPath
Definition: compiler.h:409
bool Exists() const
size_t Add(const wxString &str, size_t copies=1)
bool Open(AccessMode mode=Write)
wxUniChar GetChar(size_t n) const
int m_Weight
Definition: compiler.h:422
void SetName(const wxString &strKey)
Compiler * CreateCopy()
Implement this in new compilers, to return a new copy.