cbp2make
Makefile generation tool for Code::Blocks IDE
makefile.h
Go to the documentation of this file.
1 /*
2  cbp2make : Makefile generation tool for the Code::Blocks IDE
3  Copyright (C) 2010-2013 Mirai Computing (mirai.computing@gmail.com)
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 //------------------------------------------------------------------------------
20 #ifndef MAKEFILE_H
21 #define MAKEFILE_H
22 //------------------------------------------------------------------------------
23 #include "stlstrings.h"
24 #include "stlconfig.h"
25 //------------------------------------------------------------------------------
26 
28 {
29  private:
33  public:
34  CString& Name(void) { return m_Name; }
35  CStringList& Values(void) { return m_Values; }
36  CString GetValue(const int Index = 0);
37  void SetValue(const CString& NewValue, const int Index = 0);
38  void AddValue(const CString& NewValue);
39  bool& Multiline(void) { return m_Multiline; }
40  CString JoinValues(void);
41  public:
42  void Clear(void);
43  void Show(void);
44  public:
45  CMakefileVariable(void);
46  ~CMakefileVariable(void);
47 };
48 
50 {
51  private:
56  public:
57  CString& Target(void) { return m_Target; }
59  CStringList& Commands(void) { return m_Commands; }
60  bool& Multiline(void) { return m_Multiline; }
62  public:
63  void Clear(void);
64  void Show(void);
65  public:
66  CMakefileRule(void);
67  ~CMakefileRule(void);
68 };
69 
71 {
72  private:
74  std::vector<CMakefileVariable *> m_Macros;
75  std::vector<CMakefileVariable *> m_EnvVars;
76  std::vector<CMakefileRule *> m_Rules;
79  protected:
80  CMakefileVariable *FindMacro(const CString& Name);
81  CMakefileVariable *FindEnvVar(const CString& Name);
82  public:
83  void Clear(void);
84  void Show(void);
85  public:
86  CStringList& Header(void);
87  std::vector<CMakefileVariable *>& Macros(void);
88  std::vector<CMakefileVariable *>& EnvVars(void);
89  CMakefileVariable& AddMacro(const CString& Name, const CString& Value);
90  CMakefileVariable& AddEnvVar(const CString& Name, const CString& Value);
91  size_t RulesCount(void) const;
92  CMakefileRule& GetRule(const size_t Index);
93  CMakefileRule& AddRule(const CString& TargetName);
94  public:
95  CMakefileSection(void);
96  ~CMakefileSection(void);
97 };
98 
99 class CMakefile
100 {
101  private:
102  std::vector<CMakefileSection *> m_Sections;
104  public:
105  void Clear(void);
106  void Show(void);
107  public:
108  size_t SectionCount(void) const;
109  CMakefileSection& GetSection(const size_t Section);
110  CStringList& Header(const size_t Section = 0);
111  CMakefileSection& AddSection(size_t *Section = 0);
112  CMakefileVariable& AddMacro(const CString& Name, const CString& Value, const size_t Section = 0);
113  CMakefileVariable& AddEnvVar(const CString& Name, const CString& Value, const size_t Section = 0);
114  size_t RulesCount(const size_t Section = 0);
115  CMakefileRule& GetRule(const size_t Index, const size_t Section = 0);
116  CMakefileRule& AddRule(const CString& TargetName, const size_t Section = 0);
117  CStringList& GetText(void);
118  CStringList& Update(void);
119  public:
120  CMakefile(void);
121  ~CMakefile(void);
122 };
123 
124 #endif
125 //------------------------------------------------------------------------------
CString JoinDependencies(void)
Returns dependencies as a single string.
Definition: makefile.cpp:97
size_t RulesCount(const size_t Section=0)
Counts makefile rules in a section number Section.
Definition: makefile.cpp:335
size_t SectionCount(void) const
Counts makefile sections.
Definition: makefile.cpp:284
CStringList & Header(const size_t Section=0)
Header of a makefile section number Section.
Definition: makefile.cpp:312
CStringList m_Commands
A list of commands to be executed to build the target.
Definition: makefile.h:54
CMakefile(void)
Creates makefile.
Definition: makefile.cpp:261
std::vector< CMakefileVariable * > & EnvVars(void)
A list of environment variables in the section.
Definition: makefile.cpp:169
bool & Multiline(void)
Allows line-wrapping of the list of dependencies.
Definition: makefile.h:60
CString m_Target
Name of a makefile target.
Definition: makefile.h:52
CMakefileVariable * FindEnvVar(const CString &Name)
Searches environment variables by name.
Definition: makefile.cpp:184
CMakefileVariable & AddMacro(const CString &Name, const CString &Value, const size_t Section=0)
Creates a new macro variable and adds it to a section number Section.
Definition: makefile.cpp:325
Makefile rule definition.
Definition: makefile.h:49
CMakefileVariable & AddMacro(const CString &Name, const CString &Value)
Creates a new macro variable and adds it to the section.
Definition: makefile.cpp:194
std::vector< CMakefileVariable * > m_Macros
A list of macro variables in the section.
Definition: makefile.h:74
bool m_Multiline
Allows line-wrapping of variable's value text.
Definition: makefile.h:32
~CMakefileSection(void)
Destroys makefile section.
Definition: makefile.cpp:117
CMakefileRule(void)
Creates makefile rule.
Definition: makefile.cpp:79
void Show(void)
Prints properties of the macro variable to the standard output.
Definition: makefile.cpp:71
~CMakefileVariable(void)
Destroys macro variable.
Definition: makefile.cpp:34
Makefile macro variable definition.
Definition: makefile.h:27
CStringList & Commands(void)
A list of commands to be executed to build the target.
Definition: makefile.h:59
CMakefileRule m_NullRule
A substitute rule, it is returned when no rule satisfies search conditions.
Definition: makefile.h:78
void Show(void)
Prints contents of the makefile to the standard output.
Definition: makefile.cpp:279
bool & Multiline(void)
Allows line-wrapping of variable's value text.
Definition: makefile.h:39
Definition: stlstrings.h:98
~CMakefileRule(void)
Destroys makefile rule.
Definition: makefile.cpp:84
std::vector< CMakefileVariable * > & Macros(void)
A list of macro variables in the section.
Definition: makefile.cpp:164
CStringList & Dependencies(void)
A list of dependencies (prerequirements) for the target.
Definition: makefile.h:58
void SetValue(const CString &NewValue, const int Index=0)
Replaces a string number Index in the value strings with the NewValue string.
Definition: makefile.cpp:44
CMakefileRule & GetRule(const size_t Index, const size_t Section=0)
Returns makefile rule by the Index number in a section number Section.
Definition: makefile.cpp:340
CMakefileVariable(void)
Creates macro variable.
Definition: makefile.cpp:29
CStringList m_Dependencies
A list of dependencies (prerequirements) for the target.
Definition: makefile.h:53
CMakefileSection & AddSection(size_t *Section=0)
Creates a new makefile section and adds it to the makefile.
Definition: makefile.cpp:317
CStringList & Values(void)
Returns the value of the macro variable as a list of strings.
Definition: makefile.h:35
bool m_Multiline
Allows line-wrapping of the list of dependencies.
Definition: makefile.h:55
CMakefileSection & GetSection(const size_t Section)
Returns a makefile section by a number.
Definition: makefile.cpp:289
~CMakefile(void)
Destroys makefile.
Definition: makefile.cpp:267
CString GetValue(const int Index=0)
Returns a string number Index from the value strings.
Definition: makefile.cpp:39
Definition: stlstrings.h:32
void Clear(void)
Resets the makefile section to the initial state.
Definition: makefile.cpp:122
void Clear(void)
Resets the makefile rule to the initial state.
Definition: makefile.cpp:89
CMakefileRule & GetRule(const size_t Index)
Returns makefile rule by the Index number.
Definition: makefile.cpp:233
CMakefileVariable & AddEnvVar(const CString &Name, const CString &Value, const size_t Section=0)
Creates a new environment variable and adds it to a section number Section.
Definition: makefile.cpp:330
Makefile definition.
Definition: makefile.h:99
CString m_Name
Name of the makefile macro variable.
Definition: makefile.h:30
std::vector< CMakefileVariable * > m_EnvVars
A list of environment variables in the section.
Definition: makefile.h:75
CMakefileRule & AddRule(const CString &TargetName, const size_t Section=0)
Creates a new makefile rule and adds it to a section number Section.
Definition: makefile.cpp:345
std::vector< CMakefileSection * > m_Sections
A list of makefile sections.
Definition: makefile.h:102
CStringList & Update(void)
Creates plain text representation of the makefile from objects.
Definition: makefile.cpp:355
CStringList & GetText(void)
Returns a plain text representation of the makefile.
Definition: makefile.cpp:350
CString & Target(void)
Name of a makefile target.
Definition: makefile.h:57
CStringList m_Text
Plain text representation of the makefile.
Definition: makefile.h:103
void Show(void)
Prints the makefile rule properties to the standard output.
Definition: makefile.cpp:103
CStringList m_Header
Section header, describes makefile section contents.
Definition: makefile.h:73
CMakefileVariable & AddEnvVar(const CString &Name, const CString &Value)
Creates a new environment variable and adds it to the section.
Definition: makefile.cpp:211
CMakefileVariable * FindMacro(const CString &Name)
Searches macro variables by name.
Definition: makefile.cpp:174
CString & Name(void)
Returns the name of the macro variable.
Definition: makefile.h:34
void Clear(void)
Resets the makefile to the initial state.
Definition: makefile.cpp:272
CMakefileRule & AddRule(const CString &TargetName)
Creates a new makefile rule and adds it to the section.
Definition: makefile.cpp:242
void Clear(void)
Resets the macro variable to the initial state.
Definition: makefile.cpp:64
std::vector< CMakefileRule * > m_Rules
A list of makefile rules in the section.
Definition: makefile.h:76
CMakefileSection(void)
Creates makefile section.
Definition: makefile.cpp:112
CMakefileVariable m_NullVariable
A substitute variable, it is returned when no variable satisfies search conditions.
Definition: makefile.h:77
size_t RulesCount(void) const
Counts makefile rules in the section.
Definition: makefile.cpp:228
CStringList & Header(void)
Section header, describes makefile section contents.
Definition: makefile.cpp:159
CString JoinValues(void)
Returns the variable value as a single string.
Definition: makefile.cpp:53
void AddValue(const CString &NewValue)
Appends a list of value strings with the NewValue string.
Definition: makefile.cpp:59
CStringList m_Values
A list of strings which concatenation gives the actual value of the macro variable.
Definition: makefile.h:31
Makefile section definition.
Definition: makefile.h:70
void Show(void)
Prints contents of the makefile section to the standard output.
Definition: makefile.cpp:133