Code::Blocks  SVN r11506
compilerKeilC51.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: 9263 $
6  * $Id: compilerKeilC51.cpp 9263 2013-08-17 09:20:28Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/compilergcc/compilerKeilC51.cpp $
8  */
9 
10 #include <sdk.h>
11 #include <prep.h>
12 #include "compilerKeilC51.h"
13 #include <wx/intl.h>
14 #include <wx/regex.h>
15 #include <wx/config.h>
16 #include <wx/fileconf.h>
17 #include <wx/msgdlg.h>
18 
19 #ifdef __WXMSW__
20  #include <wx/msw/registry.h>
21 #endif
22 
24  : Compiler(_("Keil C51 Compiler"), _T("keilc51"))
25 {
26  m_Weight = 73;
27  Reset();
28 }
29 
31  : Compiler(name, ID)
32 {
33  Reset();
34 }
35 
37 {
38  //dtor
39 }
40 
42 {
43  return (new CompilerKeilC51(*this));
44 }
45 
47 {
48  if (platform::windows)
49  {
50 #ifdef __WXMSW__ // for wxRegKey
51  wxRegKey key; // defaults to HKCR
52  key.SetName(wxT("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Keil \265Vision3")); // 'backslash265' is the mu character
53  if (key.Exists() && key.Open(wxRegKey::Read)) // found; read it
54  key.QueryValue(wxT("LastInstallDir"), m_MasterPath);
55 #endif // __WXMSW__
56 
57  if (m_MasterPath.IsEmpty())
58  {
59  // just a guess; the default installation dir
60  m_MasterPath = wxT("C:\\Keil");
61  }
62 
63  m_MasterPath = m_MasterPath + wxFILE_SEP_PATH + wxT("C51");
64 
66  {
67  AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("inc"));
68  AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib"));
69  m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("bin"));
70  }
71  }
72  else
73  m_MasterPath=_T("/usr/local"); // default
74 
75  return wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("bin") + wxFILE_SEP_PATH + m_Programs.C) ? adrDetected : adrGuessed;
76 }
77 
78 //------------------------------------------------------------
79 
81  : CompilerKeilC51(_("Keil CX51 Compiler"), _T("keilcx51"))
82 {
83  m_Weight = 74;
84 }
85 
87 {
88  //dtor
89 }
90 
92 {
93  return (new CompilerKeilCX51(*this));
94 }
virtual ~CompilerKeilC51()
virtual AutoDetectResult AutoDetectInstallationDir()
Try to auto-detect the compiler&#39;s installation directory.
bool wxFileExists(const wxString &filename)
bool wxDirExists(const wxString &dirname)
virtual void Reset()
Reset settings to defaults.
Definition: compiler.cpp:157
#define _T(string)
virtual void AddIncludeDir(const wxString &option)
bool QueryValue(const wxString &szValue, wxString &strValue, bool raw) const
CompilerPrograms m_Programs
Definition: compiler.h:412
#define wxT(string)
AutoDetectResult
Definition: compiler.h:190
virtual void AddLibDir(const wxString &option)
virtual Compiler * CreateCopy()
Implement this in new compilers, to return a new copy.
wxArrayString m_ExtraPaths
Definition: compiler.h:410
virtual Compiler * CreateCopy()
Implement this in new compilers, to return a new copy.
const wxString & _(const wxString &string)
Definition: id.h:15
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)
int m_Weight
Definition: compiler.h:422
void SetName(const wxString &strKey)
virtual ~CompilerKeilCX51()