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; }
58  CStringList& Dependencies(void) { return m_Dependencies; }
59  CStringList& Commands(void) { return m_Commands; }
60  bool& Multiline(void) { return m_Multiline; }
61  CString JoinDependencies(void);
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 //------------------------------------------------------------------------------
CStringList m_Commands
A list of commands to be executed to build the target.
Definition: makefile.h:54
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
Makefile rule definition.
Definition: makefile.h:49
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&#39;s value text.
Definition: makefile.h:32
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
bool & Multiline(void)
Allows line-wrapping of variable&#39;s value text.
Definition: makefile.h:39
Definition: stlstrings.h:98
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
CMakefileVariable(void)
Creates macro variable.
Definition: makefile.cpp:29
CStringList m_Dependencies
A list of dependencies (prerequirements) for the target.
Definition: makefile.h:53
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
CString GetValue(const int Index=0)
Returns a string number Index from the value strings.
Definition: makefile.cpp:39
Definition: stlstrings.h:32
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
std::vector< CMakefileSection * > m_Sections
A list of makefile sections.
Definition: makefile.h:102
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
CStringList m_Header
Section header, describes makefile section contents.
Definition: makefile.h:73
CString & Name(void)
Returns the name of the macro variable.
Definition: makefile.h:34
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
CMakefileVariable m_NullVariable
A substitute variable, it is returned when no variable satisfies search conditions.
Definition: makefile.h:77
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