* Build networking components
[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 class ImportLibrary;
34 class If;
35 class LinkerFlag;
36 class Property;
37
38 class Project
39 {
40 std::string xmlfile;
41 XMLElement *node, *head;
42 public:
43 std::string name;
44 std::string makefile;
45 std::vector<Module*> modules;
46 std::vector<Include*> includes;
47 std::vector<Define*> defines;
48 std::vector<LinkerFlag*> linkerFlags;
49 std::vector<Property*> properties;
50 std::vector<If*> ifs;
51
52 //Project ();
53 Project ( const std::string& filename );
54 ~Project ();
55 void ProcessXML ( const std::string& path );
56 Module* LocateModule ( const std::string& name );
57 const Module* LocateModule ( const std::string& name ) const;
58 private:
59 void ReadXml ();
60 void ProcessXMLSubElement ( const XMLElement& e,
61 const std::string& path,
62 If* pIf = NULL );
63
64 // disable copy semantics
65 Project ( const Project& );
66 Project& operator = ( const Project& );
67 };
68
69
70 enum ModuleType
71 {
72 BuildTool,
73 StaticLibrary,
74 Kernel,
75 KernelModeDLL,
76 KernelModeDriver,
77 NativeDLL,
78 Win32DLL,
79 Win32GUI
80 };
81
82
83 class Module
84 {
85 public:
86 const Project& project;
87 const XMLElement& node;
88 std::string name;
89 std::string extension;
90 std::string path;
91 ModuleType type;
92 ImportLibrary* importLibrary;
93 std::vector<File*> files;
94 std::vector<Library*> libraries;
95 std::vector<Include*> includes;
96 std::vector<Define*> defines;
97 std::vector<Invoke*> invocations;
98 std::vector<Dependency*> dependencies;
99 std::vector<If*> ifs;
100 std::vector<LinkerFlag*> linkerFlags;
101
102 Module ( const Project& project,
103 const XMLElement& moduleNode,
104 const std::string& modulePath );
105 ~Module ();
106 ModuleType GetModuleType ( const std::string& location,
107 const XMLAttribute& attribute );
108 bool HasImportLibrary () const;
109 std::string GetTargetName () const;
110 std::string GetDependencyPath () const;
111 std::string GetBasePath () const;
112 std::string GetPath () const;
113 std::string GetPathWithPrefix ( const std::string& prefix ) const;
114 std::string GetTargets () const;
115 std::string GetInvocationTarget ( const int index ) const;
116 void ProcessXML();
117 private:
118 std::string GetDefaultModuleExtension () const;
119 void ProcessXMLSubElement ( const XMLElement& e,
120 const std::string& path,
121 If* pIf = NULL );
122 };
123
124
125 class Include
126 {
127 public:
128 const Project& project;
129 const Module* module;
130 const XMLElement& node;
131 std::string directory;
132 std::string basePath;
133
134 Include ( const Project& project,
135 const XMLElement& includeNode );
136 Include ( const Project& project,
137 const Module* module,
138 const XMLElement& includeNode );
139 ~Include ();
140 void ProcessXML();
141 private:
142 void Initialize();
143 };
144
145
146 class Define
147 {
148 public:
149 const Project& project;
150 const Module* module;
151 const XMLElement& node;
152 std::string name;
153 std::string value;
154
155 Define ( const Project& project,
156 const XMLElement& defineNode );
157 Define ( const Project& project,
158 const Module* module,
159 const XMLElement& defineNode );
160 ~Define();
161 void ProcessXML();
162 private:
163 void Initialize();
164 };
165
166
167 class File
168 {
169 public:
170 std::string name;
171
172 File ( const std::string& _name );
173
174 void ProcessXML();
175 };
176
177
178 class Library
179 {
180 public:
181 const XMLElement& node;
182 const Module& module;
183 std::string name;
184
185 Library ( const XMLElement& _node,
186 const Module& _module,
187 const std::string& _name );
188
189 void ProcessXML();
190 };
191
192
193 class Invoke
194 {
195 public:
196 const XMLElement& node;
197 const Module& module;
198 const Module* invokeModule;
199 std::vector<InvokeFile*> input;
200 std::vector<InvokeFile*> output;
201
202 Invoke ( const XMLElement& _node,
203 const Module& _module );
204
205 void ProcessXML();
206 std::string GetTargets () const;
207 private:
208 void ProcessXMLSubElement ( const XMLElement& e );
209 void ProcessXMLSubElementInput ( const XMLElement& e );
210 void ProcessXMLSubElementOutput ( const XMLElement& e );
211 };
212
213
214 class InvokeFile
215 {
216 public:
217 const XMLElement& node;
218 std::string name;
219 std::string switches;
220
221 InvokeFile ( const XMLElement& _node,
222 const std::string& _name );
223
224 void ProcessXML ();
225 };
226
227
228 class Dependency
229 {
230 public:
231 const XMLElement& node;
232 const Module& module;
233 const Module* dependencyModule;
234
235 Dependency ( const XMLElement& _node,
236 const Module& _module );
237
238 void ProcessXML();
239 };
240
241
242 class ImportLibrary
243 {
244 public:
245 const XMLElement& node;
246 const Module& module;
247 std::string basename;
248 std::string definition;
249
250 ImportLibrary ( const XMLElement& _node,
251 const Module& module );
252
253 void ProcessXML ();
254 };
255
256
257 class If
258 {
259 public:
260 const XMLElement& node;
261 const Project& project;
262 const Module* module;
263 std::string property, value;
264 std::vector<File*> files;
265 std::vector<Include*> includes;
266 std::vector<Define*> defines;
267 std::vector<Property*> properties;
268 std::vector<If*> ifs;
269
270 If ( const XMLElement& node_,
271 const Project& project_,
272 const Module* module_ );
273 ~If();
274
275 void ProcessXML();
276 };
277
278
279 class LinkerFlag
280 {
281 public:
282 const Project& project;
283 const Module* module;
284 const XMLElement& node;
285 std::string flag;
286
287 LinkerFlag ( const Project& project,
288 const XMLElement& linkerFlagNode );
289 LinkerFlag ( const Project& project,
290 const Module* module,
291 const XMLElement& linkerFlagNode );
292 ~LinkerFlag ();
293 void ProcessXML();
294 private:
295 void Initialize();
296 };
297
298
299 class Property
300 {
301 public:
302 const XMLElement& node;
303 const Project& project;
304 const Module* module;
305 std::string name, value;
306
307 Property ( const XMLElement& node_,
308 const Project& project_,
309 const Module* module_ );
310
311 void ProcessXML();
312 };
313
314 extern std::string
315 FixSeparator ( const std::string& s );
316
317 #endif /* __RBUILD_H */