use enum instead of string in more places
[reactos.git] / reactos / tools / rbuild / rbuild.h
1 #ifndef __RBUILD_H
2 #define __RBUILD_H
3
4 #include "pch.h"
5
6 #include "ssprintf.h"
7 #include "exception.h"
8 #include "XML.h"
9
10 #ifdef WIN32
11 #define EXEPOSTFIX ".exe"
12 #define CSEP '\\'
13 #define CBAD_SEP '/'
14 #define SSEP "\\"
15 #define SBAD_SEP "/"
16 #else
17 #define EXEPOSTFIX
18 #define CSEP '/'
19 #define CBAD_SEP '\\'
20 #define SSEP "/"
21 #define SBAD_SEP "\\"
22 #endif
23
24 class Project;
25 class Module;
26 class Include;
27 class Define;
28 class File;
29 class Library;
30 class Invoke;
31 class InvokeFile;
32 class Dependency;
33
34 class Project
35 {
36 public:
37 std::string name;
38 std::string makefile;
39 std::vector<Module*> modules;
40 std::vector<Include*> includes;
41 std::vector<Define*> defines;
42
43 Project ();
44 Project ( const std::string& filename );
45 ~Project ();
46 void ProcessXML ( const std::string& path );
47 Module* LocateModule ( const std::string& name );
48 const Module* LocateModule ( const std::string& name ) const;
49 private:
50 void ReadXml ();
51 XMLFile xmlfile;
52 XMLElement* node;
53 void ProcessXMLSubElement ( const XMLElement& e,
54 const std::string& path );
55 };
56
57
58 enum ModuleType
59 {
60 BuildTool,
61 StaticLibrary,
62 KernelModeDLL
63 };
64
65
66 class Module
67 {
68 public:
69 const Project& project;
70 const XMLElement& node;
71 std::string name;
72 std::string extension;
73 std::string path;
74 ModuleType type;
75 std::vector<File*> files;
76 std::vector<Library*> libraries;
77 std::vector<Include*> includes;
78 std::vector<Define*> defines;
79 std::vector<Invoke*> invocations;
80 std::vector<Dependency*> dependencies;
81
82 Module ( const Project& project,
83 const XMLElement& moduleNode,
84 const std::string& modulePath );
85 ~Module ();
86 ModuleType GetModuleType ( const std::string& location,
87 const XMLAttribute& attribute );
88 std::string GetBasePath() const;
89 std::string GetPath () const;
90 std::string GetTargets () const;
91 std::string GetInvocationTarget ( const int index ) const;
92 void ProcessXML();
93 private:
94 std::string GetDefaultModuleExtension () const;
95 void ProcessXMLSubElement ( const XMLElement& e,
96 const std::string& path );
97 };
98
99
100 class Include
101 {
102 public:
103 const Project& project;
104 const Module* module;
105 const XMLElement& node;
106 std::string directory;
107 const Module* base;
108
109 Include ( const Project& project,
110 const XMLElement& includeNode );
111 Include ( const Project& project,
112 const Module* module,
113 const XMLElement& includeNode );
114 ~Include ();
115 void ProcessXML();
116 private:
117 void Initialize();
118 };
119
120
121 class Define
122 {
123 public:
124 const Project& project;
125 const Module* module;
126 const XMLElement& node;
127 std::string name;
128 std::string value;
129
130 Define ( const Project& project,
131 const XMLElement& defineNode );
132 Define ( const Project& project,
133 const Module* module,
134 const XMLElement& defineNode );
135 ~Define();
136 void ProcessXML();
137 private:
138 void Initialize();
139 };
140
141
142 class File
143 {
144 public:
145 std::string name;
146
147 File ( const std::string& _name );
148
149 void ProcessXML();
150 };
151
152
153 class Library
154 {
155 public:
156 const XMLElement& node;
157 const Module& module;
158 std::string name;
159
160 Library ( const XMLElement& _node,
161 const Module& _module,
162 const std::string& _name );
163
164 void ProcessXML();
165 };
166
167
168 class Invoke
169 {
170 public:
171 const XMLElement& node;
172 const Module& module;
173 const Module* invokeModule;
174 std::vector<InvokeFile*> input;
175 std::vector<InvokeFile*> output;
176
177 Invoke ( const XMLElement& _node,
178 const Module& _module );
179
180 void ProcessXML();
181 std::string GetTargets () const;
182 private:
183 void ProcessXMLSubElement ( const XMLElement& e );
184 void ProcessXMLSubElementInput ( const XMLElement& e );
185 void ProcessXMLSubElementOutput ( const XMLElement& e );
186 };
187
188
189 class InvokeFile
190 {
191 public:
192 const XMLElement& node;
193 std::string name;
194 std::string switches;
195
196 InvokeFile ( const XMLElement& _node,
197 const std::string& _name );
198
199 void ProcessXML ();
200 };
201
202
203 class Dependency
204 {
205 public:
206 const XMLElement& node;
207 const Module& module;
208 const Module* dependencyModule;
209
210 Dependency ( const XMLElement& _node,
211 const Module& _module );
212
213 void ProcessXML();
214 };
215
216 extern std::string
217 FixSeparator ( const std::string& s );
218
219 #endif /* __RBUILD_H */