Build ntdll.dll.
[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
35 class Project
36 {
37 std::string xmlfile;
38 XMLElement *node, *head;
39 public:
40 std::string name;
41 std::string makefile;
42 std::vector<Module*> modules;
43 std::vector<Include*> includes;
44 std::vector<Define*> defines;
45
46 //Project ();
47 Project ( const std::string& filename );
48 ~Project ();
49 void ProcessXML ( const std::string& path );
50 Module* LocateModule ( const std::string& name );
51 const Module* LocateModule ( const std::string& name ) const;
52 private:
53 void ReadXml ();
54 void ProcessXMLSubElement ( const XMLElement& e,
55 const std::string& path );
56
57 // disable copy semantics
58 Project ( const Project& );
59 Project& operator = ( const Project& );
60 };
61
62
63 enum ModuleType
64 {
65 BuildTool,
66 StaticLibrary,
67 Kernel,
68 KernelModeDLL,
69 NativeDLL
70 };
71
72
73 class Module
74 {
75 public:
76 const Project& project;
77 const XMLElement& node;
78 std::string name;
79 std::string extension;
80 std::string path;
81 ModuleType type;
82 ImportLibrary* importLibrary;
83 std::vector<File*> files;
84 std::vector<Library*> libraries;
85 std::vector<Include*> includes;
86 std::vector<Define*> defines;
87 std::vector<Invoke*> invocations;
88 std::vector<Dependency*> dependencies;
89
90 Module ( const Project& project,
91 const XMLElement& moduleNode,
92 const std::string& modulePath );
93 ~Module ();
94 ModuleType GetModuleType ( const std::string& location,
95 const XMLAttribute& attribute );
96 std::string GetTargetName () const;
97 std::string GetDependencyPath () const;
98 std::string GetBasePath() const;
99 std::string GetPath () const;
100 std::string GetPathWithPrefix ( const std::string& prefix ) const;
101 std::string GetTargets () const;
102 std::string GetInvocationTarget ( const int index ) const;
103 void ProcessXML();
104 private:
105 std::string GetDefaultModuleExtension () const;
106 void ProcessXMLSubElement ( const XMLElement& e,
107 const std::string& path );
108 };
109
110
111 class Include
112 {
113 public:
114 const Project& project;
115 const Module* module;
116 const XMLElement& node;
117 std::string directory;
118 const Module* base;
119
120 Include ( const Project& project,
121 const XMLElement& includeNode );
122 Include ( const Project& project,
123 const Module* module,
124 const XMLElement& includeNode );
125 ~Include ();
126 void ProcessXML();
127 private:
128 void Initialize();
129 };
130
131
132 class Define
133 {
134 public:
135 const Project& project;
136 const Module* module;
137 const XMLElement& node;
138 std::string name;
139 std::string value;
140
141 Define ( const Project& project,
142 const XMLElement& defineNode );
143 Define ( const Project& project,
144 const Module* module,
145 const XMLElement& defineNode );
146 ~Define();
147 void ProcessXML();
148 private:
149 void Initialize();
150 };
151
152
153 class File
154 {
155 public:
156 std::string name;
157
158 File ( const std::string& _name );
159
160 void ProcessXML();
161 };
162
163
164 class Library
165 {
166 public:
167 const XMLElement& node;
168 const Module& module;
169 std::string name;
170
171 Library ( const XMLElement& _node,
172 const Module& _module,
173 const std::string& _name );
174
175 void ProcessXML();
176 };
177
178
179 class Invoke
180 {
181 public:
182 const XMLElement& node;
183 const Module& module;
184 const Module* invokeModule;
185 std::vector<InvokeFile*> input;
186 std::vector<InvokeFile*> output;
187
188 Invoke ( const XMLElement& _node,
189 const Module& _module );
190
191 void ProcessXML();
192 std::string GetTargets () const;
193 private:
194 void ProcessXMLSubElement ( const XMLElement& e );
195 void ProcessXMLSubElementInput ( const XMLElement& e );
196 void ProcessXMLSubElementOutput ( const XMLElement& e );
197 };
198
199
200 class InvokeFile
201 {
202 public:
203 const XMLElement& node;
204 std::string name;
205 std::string switches;
206
207 InvokeFile ( const XMLElement& _node,
208 const std::string& _name );
209
210 void ProcessXML ();
211 };
212
213
214 class Dependency
215 {
216 public:
217 const XMLElement& node;
218 const Module& module;
219 const Module* dependencyModule;
220
221 Dependency ( const XMLElement& _node,
222 const Module& _module );
223
224 void ProcessXML();
225 };
226
227
228 class ImportLibrary
229 {
230 public:
231 const XMLElement& node;
232 const Module& module;
233 std::string basename;
234 std::string definition;
235
236 ImportLibrary ( const XMLElement& _node,
237 const Module& module );
238
239 void ProcessXML ();
240 };
241
242 extern std::string
243 FixSeparator ( const std::string& s );
244
245 #endif /* __RBUILD_H */