Code::Blocks  SVN r11506
compilerOW.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: 9011 $
6  * $Id: compilerOW.cpp 9011 2013-04-29 19:32:22Z alpha0010 $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/plugins/compilergcc/compilerOW.cpp $
8  */
9 
10 #include <sdk.h>
11 #include "compilerOW.h"
12 #include <wx/intl.h>
13 #include <wx/regex.h>
14 #include <wx/config.h>
15 #include <wx/utils.h>
16 
17 #include <logmanager.h>
18 #include <manager.h>
19 #include "compilerOWgenerator.h"
20 
21 #include <wx/utils.h>
22 #include <wx/filefn.h>
23 
25  : Compiler(wxT("OpenWatcom (W32) Compiler"), _T("ow"))
26 {
27  m_Weight = 28;
28  Reset();
29 }
30 
32 {
33  //dtor
34 }
35 
37 {
38  return (new CompilerOW(*this));
39 }
40 
42 {
43  // also see hack in: DirectCommands::GetTargetLinkCommands()
45  generator->Init(project);
46  return generator;
47 }
48 
50 {
51  /* Following code is Not necessary as OpenWatcom does not write to
52  Registry anymore */
53  /*wxRegKey key; // defaults to HKCR
54  key.SetName(wxT("HKEY_LOCAL_MACHINE\\Software\\Open Watcom\\c_1.0"));
55  if (key.Open())
56  // found; read it
57  key.QueryValue(wxT("Install Location"), m_MasterPath);*/
58 
59  if (m_MasterPath.IsEmpty())
60  // just a guess; the default installation dir
61  m_MasterPath = wxT("C:\\watcom");
62 
63  if (!m_MasterPath.IsEmpty())
64  {
65  AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h"));
66  AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt"));
67  AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386"));
68  AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386") + wxFILE_SEP_PATH + wxT("nt"));
69  AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h"));
70  AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt"));
71  m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt"));
72  m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binw"));
73  }
74  wxSetEnv(wxT("WATCOM"), m_MasterPath);
75 
76  return wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt") + wxFILE_SEP_PATH + m_Programs.C) ? adrDetected : adrGuessed;
77 }
78 
79 void CompilerOW::LoadSettings(const wxString& baseKey)
80 {
81  Compiler::LoadSettings(baseKey);
82  wxSetEnv(wxT("WATCOM"), m_MasterPath);
83 }
84 
86 {
88  wxSetEnv(wxT("WATCOM"), m_MasterPath);
89 }
Generate command-lines needed to produce a build.
virtual void LoadSettings(const wxString &baseKey)
Load settings.
Definition: compilerOW.cpp:79
bool wxFileExists(const wxString &filename)
virtual AutoDetectResult AutoDetectInstallationDir()
Try to auto-detect the compiler&#39;s installation directory.
Definition: compilerOW.cpp:49
Compiler * CreateCopy()
Implement this in new compilers, to return a new copy.
Definition: compilerOW.cpp:36
virtual void Reset()
Reset settings to defaults.
Definition: compiler.cpp:157
#define _T(string)
virtual void AddIncludeDir(const wxString &option)
CompilerPrograms m_Programs
Definition: compiler.h:412
#define wxT(string)
AutoDetectResult
Definition: compiler.h:190
virtual void LoadSettings(const wxString &baseKey)
Load settings.
Definition: compiler.cpp:584
virtual void Init(cbProject *project)
Initialize for use with the specified project.
virtual CompilerCommandGenerator * GetCommandGenerator(cbProject *project)
This is to be overridden, if compiler needs to alter the default command line generation.
Definition: compilerOW.cpp:41
virtual void AddResourceIncludeDir(const wxString &option)
Represents a Code::Blocks project.
Definition: cbproject.h:96
virtual void AddLibDir(const wxString &option)
wxArrayString m_ExtraPaths
Definition: compiler.h:410
virtual ~CompilerOW()
Definition: compilerOW.cpp:31
virtual void SetMasterPath(const wxString &path)
Set the compiler&#39;s master path (must contain "bin", "include" and "lib")
Definition: compilerOW.cpp:85
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
size_t Add(const wxString &str, size_t copies=1)
int m_Weight
Definition: compiler.h:422
bool wxSetEnv(const wxString &var, const wxString &value)
virtual void SetMasterPath(const wxString &path)
Set the compiler&#39;s master path (must contain "bin", "include" and "lib")
Definition: compiler.h:321