Code::Blocks  SVN r11506
projectbuildtarget.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 8113 $
6  * $Id: projectbuildtarget.cpp 8113 2012-07-14 07:53:51Z mortenmacfly $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/projectbuildtarget.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13  #include "projectbuildtarget.h" // class's header file
14  #include "cbproject.h"
15  #include "manager.h"
16  #include "projectmanager.h"
17  #include "macrosmanager.h"
18  #include "globals.h"
19 #endif
20 
21 
22 
23 // class constructor
25  : m_Project(parentProject),
26  m_FileArray(ProjectFile::CompareProjectFiles)
27 {
28  m_BuildWithAll = false;
29  m_CreateStaticLib = true;
30  m_CreateDefFile = true;
31  m_UseConsoleRunner = true;
32  m_FileArray.Clear();
33 }
34 
35 // class destructor
37 {
38 }
39 
41 {
42  return m_Project;
43 }
44 
46 {
47  return m_Project->GetTitle() + _T(" - ") + GetTitle();
48 }
49 
51 {
52  return m_ExternalDeps;
53 }
54 
56 {
57  if (m_ExternalDeps != deps)
58  {
59  m_ExternalDeps = deps;
60  SetModified(true);
61  }
62 }
63 
65 {
67 }
68 
70 {
71  if (m_AdditionalOutputFiles != files)
72  {
74  SetModified(true);
75  }
76 }
77 
79 {
80  return m_BuildWithAll;
81 }
82 
84 {
85  if (m_BuildWithAll != buildIt)
86  {
87  m_BuildWithAll = buildIt;
88  SetModified(true);
89  }
90 }
91 
93 {
94  return m_CreateDefFile;
95 }
96 
98 {
99  if (m_CreateDefFile != createIt)
100  {
101  m_CreateDefFile = createIt;
102  SetModified(true);
103  }
104 }
105 
107 {
108  return m_CreateStaticLib;
109 }
110 
112 {
113  if (m_CreateStaticLib != createIt)
114  {
115  m_CreateStaticLib = createIt;
116  SetModified(true);
117  }
118 }
119 
121 {
123  return m_UseConsoleRunner;
124 
125  return false;
126 }
127 
129 {
130  if (GetTargetType() == ttConsoleOnly && useIt != m_UseConsoleRunner)
131  {
132  m_UseConsoleRunner = useIt;
133  SetModified(true);
134  }
135 }
136 
138 {
139  TargetType ttold = GetTargetType();
141  if (ttold != GetTargetType() && GetTargetType() == ttConsoleOnly)
142  SetUseConsoleRunner(true); // by default, use console runner
143 }
144 
145 // target dependencies: targets to be compiled (if necessary) before this one
147 {
148  m_TargetDeps.Add(target);
149 }
150 
151 // get the list of dependency targets of this target
153 {
154  return m_TargetDeps;
155 }
156 
158 {
159  if (m_FileArray.GetCount() == 0)
160  {
161  for (FilesList::iterator it = m_Files.begin(); it != m_Files.end(); ++it)
162  {
163  if (!*it)
164  continue;
165  m_FileArray.Add(*it);
166  }
167  }
168 
169  if (index < 0 || static_cast<size_t>(index) >= m_FileArray.GetCount())
170  return NULL;
171 
172  return m_FileArray.Item(index);
173 }
174 
176 {
177  if (!pf)
178  return false;
179  m_Files.erase(pf);
180  if (m_FileArray.GetCount() > 0)
181  m_FileArray.Remove(pf);
182 
183  return true;
184 }
virtual bool GetCreateDefFile() const
Valid only for targets generating dynamic libraries (DLLs or SOs).
virtual bool GetUseConsoleRunner() const
Valid only for targets generating a console executable.
virtual const wxString & GetAdditionalOutputFiles() const
virtual void AddTargetDep(ProjectBuildTarget *target)
Targets to be compiled (if necessary) before this one.
bool RemoveFile(ProjectFile *pf)
Remove a file from the target.
virtual void SetCreateDefFile(bool createIt)
Set if the target creates a DEF imports file.
virtual const wxString & GetExternalDeps() const
#define _T(string)
virtual void SetIncludeInTargetAll(bool buildIt)
Deprecated, do not use at all! Set if this target should be built when the virtual target "All" is se...
virtual void SetUseConsoleRunner(bool useIt)
Set if ConsoleRunner should be used.
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
virtual bool GetCreateStaticLib()
Valid only for targets generating dynamic libraries (DLLs or SOs).
ProjectFileArray m_FileArray
virtual cbProject * GetParentProject()
virtual wxString GetFullTitle() const
virtual bool GetRunHostApplicationInTerminal() const
Get the flag if the host app should be run in terminal.
virtual TargetType GetTargetType() const
Read the target&#39;s type.
ProjectFile * GetFile(int index)
Access a file of the target.
Represents a Code::Blocks project.
Definition: cbproject.h:96
virtual const wxString & GetTitle() const
Read the target&#39;s title.
virtual void SetModified(bool modified)
virtual void SetExternalDeps(const wxString &deps)
Set a list of all the external files this targets depends on.
virtual void SetCreateStaticLib(bool createIt)
Set if an import library should be created.
Target produces a console executable (without GUI) (distinction between ttExecutable and ttConsoleOnl...
ProjectBuildTarget(cbProject *parentProject)
Constructor.
void SetTargetType(TargetType pt) override
Set the target&#39;s type to pt.
Represents a Code::Blocks project build target.
virtual void SetTargetType(TargetType pt)
Set the target&#39;s type to pt.
virtual BuildTargets & GetTargetDeps()
TargetType
Enum to define the type of output the target produces.
#define NULL
Definition: prefix.cpp:59
~ProjectBuildTarget() override
Destructor.
virtual bool GetIncludeInTargetAll() const
Deprecated, do not use at all!
virtual void SetAdditionalOutputFiles(const wxString &files)
Set a list of all additional output files this targets creates, besides its main output.