add 'location' information to a couple exceptions that should have it
[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 etype;
75 std::string stype;
76 std::vector<File*> files;
77 std::vector<Library*> libraries;
78 std::vector<Include*> includes;
79 std::vector<Define*> defines;
80 std::vector<Invoke*> invocations;
81 std::vector<Dependency*> dependencies;
82
83 Module ( const Project& project,
84 const XMLElement& moduleNode,
85 const std::string& modulePath );
86 ~Module ();
87 ModuleType GetModuleType ( const std::string& location,
88 const XMLAttribute& attribute );
89 std::string GetBasePath() const;
90 std::string GetPath () const;
91 std::string GetTargets () const;
92 std::string GetInvocationTarget ( const int index ) const;
93 void ProcessXML();
94 private:
95 std::string GetDefaultModuleExtension () const;
96 void ProcessXMLSubElement ( const XMLElement& e,
97 const std::string& path );
98 };
99
100
101 class Include
102 {
103 public:
104 const Project& project;
105 const Module* module;
106 const XMLElement& node;
107 std::string directory;
108 const Module* base;
109
110 Include ( const Project& project,
111 const XMLElement& includeNode );
112 Include ( const Project& project,
113 const Module* module,
114 const XMLElement& includeNode );
115 ~Include ();
116 void ProcessXML();
117 private:
118 void Initialize();
119 };
120
121
122 class Define
123 {
124 public:
125 const Project& project;
126 const Module* module;
127 const XMLElement& node;
128 std::string name;
129 std::string value;
130
131 Define ( const Project& project,
132 const XMLElement& defineNode );
133 Define ( const Project& project,
134 const Module* module,
135 const XMLElement& defineNode );
136 ~Define();
137 void ProcessXML();
138 private:
139 void Initialize();
140 };
141
142
143 class File
144 {
145 public:
146 std::string name;
147
148 File ( const std::string& _name );
149
150 void ProcessXML();
151 };
152
153
154 class Library
155 {
156 public:
157 const XMLElement& node;
158 const Module& module;
159 std::string name;
160
161 Library ( const XMLElement& _node,
162 const Module& _module,
163 const std::string& _name );
164
165 void ProcessXML();
166 };
167
168
169 class Invoke
170 {
171 public:
172 const XMLElement& node;
173 const Module& module;
174 const Module* invokeModule;
175 std::vector<InvokeFile*> input;
176 std::vector<InvokeFile*> output;
177
178 Invoke ( const XMLElement& _node,
179 const Module& _module );
180
181 void ProcessXML();
182 std::string GetTargets () const;
183 private:
184 void ProcessXMLSubElement ( const XMLElement& e );
185 void ProcessXMLSubElementInput ( const XMLElement& e );
186 void ProcessXMLSubElementOutput ( const XMLElement& e );
187 };
188
189
190 class InvokeFile
191 {
192 public:
193 const XMLElement& node;
194 std::string name;
195 std::string switches;
196
197 InvokeFile ( const XMLElement& _node,
198 const std::string& _name );
199
200 void ProcessXML ();
201 };
202
203
204 class Dependency
205 {
206 public:
207 const XMLElement& node;
208 const Module& module;
209 const Module* dependencyModule;
210
211 Dependency ( const XMLElement& _node,
212 const Module& _module );
213
214 void ProcessXML();
215 };
216
217 extern std::string
218 FixSeparator ( const std::string& s );
219
220 #endif /* __RBUILD_H */