717921bf0199f7c235ed6e5bbb67d521df60d291
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.h
1 #ifndef MINGW_MODULEHANDLER_H
2 #define MINGW_MODULEHANDLER_H
3
4 #include "../backend.h"
5
6 extern std::string
7 ReplaceExtension ( const std::string& filename,
8 const std::string& newExtension );
9
10
11 class MingwModuleHandler
12 {
13 public:
14 static std::map<ModuleType,MingwModuleHandler*>* handler_map;
15 static int ref;
16
17 MingwModuleHandler ( ModuleType moduletype );
18 virtual ~MingwModuleHandler();
19
20 static void SetMakefile ( FILE* f );
21 static MingwModuleHandler* LookupHandler ( const std::string& location,
22 ModuleType moduletype_ );
23 virtual void Process ( const Module& module ) = 0;
24 bool IncludeDirectoryTarget ( const std::string& directory ) const;
25 void GenerateDirectoryTargets () const;
26 static std::string GetObjectFilename ( const std::string& sourceFilename );
27 protected:
28 const std::string &PassThruCacheDirectory ( const std::string &f ) const;
29 std::string GetWorkingDirectory () const;
30 std::string GetBasename ( const std::string& filename ) const;
31 std::string GetActualSourceFilename ( const std::string& filename ) const;
32 std::string GetModuleArchiveFilename ( const Module& module ) const;
33 bool IsGeneratedFile ( const File& file ) const;
34 std::string GetImportLibraryDependency ( const Module& importedModule ) const;
35 std::string GetImportLibraryDependencies ( const Module& module ) const;
36 std::string GetModuleDependencies ( const Module& module ) const;
37 std::string GetAllDependencies ( const Module& module ) const;
38 std::string GetSourceFilenames ( const Module& module,
39 bool includeGeneratedFiles ) const;
40 std::string GetSourceFilenames ( const Module& module ) const;
41 std::string GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const;
42
43 std::string GetObjectFilenames ( const Module& module ) const;
44 void GenerateMacrosAndTargetsHost ( const Module& module ) const;
45 void GenerateMacrosAndTargetsTarget ( const Module& module ) const;
46 void GenerateMacrosAndTargetsTarget ( const Module& module,
47 const std::string* cflags,
48 const std::string* nasmflags ) const;
49 std::string GetInvocationDependencies ( const Module& module ) const;
50 void GenerateInvocations ( const Module& module ) const;
51
52 std::string GetPreconditionDependenciesName ( const Module& module ) const;
53 void GeneratePreconditionDependencies ( const Module& module ) const;
54 std::string GetCFlagsMacro ( const Module& module ) const;
55 std::string GetObjectsMacro ( const Module& module ) const;
56 std::string GetLinkerMacro ( const Module& module ) const;
57 void GenerateLinkerCommand ( const Module& module,
58 const std::string& linker,
59 const std::string& linkerParameters,
60 const std::string& objectFilenames ) const;
61 void GenerateImportLibraryTargetIfNeeded ( const Module& module ) const;
62 std::string GetDefinitionDependencies ( const Module& module ) const;
63 std::string GetLinkingDependencies ( const Module& module ) const;
64 bool IsCPlusPlusModule ( const Module& module ) const;
65 static FILE* fMakefile;
66 static std::set<std::string> directory_set;
67 private:
68 std::string ConcatenatePaths ( const std::string& path1,
69 const std::string& path2 ) const;
70 std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
71 std::string GenerateGccDefineParameters ( const Module& module ) const;
72 std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
73 std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;
74 std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
75 std::string GenerateLinkerParameters ( const Module& module ) const;
76 void GenerateMacro ( const char* assignmentOperation,
77 const std::string& macro,
78 const std::vector<Include*>& includes,
79 const std::vector<Define*>& defines,
80 const std::vector<CompilerFlag*>* compilerFlags ) const;
81 void GenerateMacros ( const char* op,
82 const std::vector<File*>& files,
83 const std::vector<Include*>& includes,
84 const std::vector<Define*>& defines,
85 const std::vector<CompilerFlag*>* compilerFlags,
86 const std::vector<LinkerFlag*>* linkerFlags,
87 const std::vector<If*>& ifs,
88 const std::string& cflags_macro,
89 const std::string& nasmflags_macro,
90 const std::string& windresflags_macro,
91 const std::string& linkerflags_macro,
92 const std::string& objs_macro) const;
93 void GenerateMacros ( const Module& module,
94 const std::string& cflags_macro,
95 const std::string& nasmflags_macro,
96 const std::string& windresflags_macro,
97 const std::string& linkerflags_macro,
98 const std::string& objs_macro) const;
99 std::string GenerateGccIncludeParameters ( const Module& module ) const;
100 std::string GenerateGccParameters ( const Module& module ) const;
101 std::string GenerateNasmParameters ( const Module& module ) const;
102 void GenerateGccCommand ( const Module& module,
103 const std::string& sourceFilename,
104 const std::string& cc,
105 const std::string& cflagsMacro ) const;
106 void GenerateGccAssemblerCommand ( const Module& module,
107 const std::string& sourceFilename,
108 const std::string& cc,
109 const std::string& cflagsMacro ) const;
110 void GenerateNasmCommand ( const Module& module,
111 const std::string& sourceFilename,
112 const std::string& nasmflagsMacro ) const;
113 void GenerateWindresCommand ( const Module& module,
114 const std::string& sourceFilename,
115 const std::string& windresflagsMacro ) const;
116 void GenerateWinebuildCommands ( const Module& module,
117 const std::string& sourceFilename ) const;
118 void GenerateCommands ( const Module& module,
119 const std::string& sourceFilename,
120 const std::string& cc,
121 const std::string& cppc,
122 const std::string& cflagsMacro,
123 const std::string& nasmflagsMacro,
124 const std::string& windresflagsMacro ) const;
125 void GenerateObjectFileTargets ( const Module& module,
126 const std::vector<File*>& files,
127 const std::vector<If*>& ifs,
128 const std::string& cc,
129 const std::string& cppc,
130 const std::string& cflagsMacro,
131 const std::string& nasmflagsMacro,
132 const std::string& windresflagsMacro ) const;
133 void GenerateObjectFileTargets ( const Module& module,
134 const std::string& cc,
135 const std::string& cppc,
136 const std::string& cflagsMacro,
137 const std::string& nasmflagsMacro,
138 const std::string& windresflagsMacro ) const;
139 void GetCleanTargets ( std::vector<std::string>& out,
140 const std::vector<File*>& files,
141 const std::vector<If*>& ifs ) const;
142 std::string GenerateArchiveTarget ( const Module& module,
143 const std::string& ar,
144 const std::string& objs_macro ) const;
145 void GenerateMacrosAndTargets ( const Module& module,
146 const std::string& cc,
147 const std::string& cppc,
148 const std::string& ar,
149 const std::string* clags,
150 const std::string* nasmflags ) const;
151 std::string GetSpecObjectDependencies ( const std::string& filename ) const;
152 std::string GetDefaultDependencies ( const Module& module ) const;
153 };
154
155
156 class MingwBuildToolModuleHandler : public MingwModuleHandler
157 {
158 public:
159 MingwBuildToolModuleHandler ();
160 virtual void Process ( const Module& module );
161 private:
162 void GenerateBuildToolModuleTarget ( const Module& module );
163 };
164
165
166 class MingwKernelModuleHandler : public MingwModuleHandler
167 {
168 public:
169 MingwKernelModuleHandler ();
170 virtual void Process ( const Module& module );
171 private:
172 void GenerateKernelModuleTarget ( const Module& module );
173 };
174
175
176 class MingwStaticLibraryModuleHandler : public MingwModuleHandler
177 {
178 public:
179 MingwStaticLibraryModuleHandler ();
180 virtual void Process ( const Module& module );
181 private:
182 void GenerateStaticLibraryModuleTarget ( const Module& module );
183 };
184
185
186 class MingwObjectLibraryModuleHandler : public MingwModuleHandler
187 {
188 public:
189 MingwObjectLibraryModuleHandler ();
190 virtual void Process ( const Module& module );
191 private:
192 void GenerateObjectLibraryModuleTarget ( const Module& module );
193 };
194
195
196 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
197 {
198 public:
199 MingwKernelModeDLLModuleHandler ();
200 virtual void Process ( const Module& module );
201 private:
202 void GenerateKernelModeDLLModuleTarget ( const Module& module );
203 };
204
205
206 class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
207 {
208 public:
209 MingwKernelModeDriverModuleHandler ();
210 virtual void Process ( const Module& module );
211 private:
212 void GenerateKernelModeDriverModuleTarget ( const Module& module );
213 };
214
215
216 class MingwNativeDLLModuleHandler : public MingwModuleHandler
217 {
218 public:
219 MingwNativeDLLModuleHandler ();
220 virtual void Process ( const Module& module );
221 private:
222 void GenerateNativeDLLModuleTarget ( const Module& module );
223 };
224
225
226 class MingwNativeCUIModuleHandler : public MingwModuleHandler
227 {
228 public:
229 MingwNativeCUIModuleHandler ();
230 virtual void Process ( const Module& module );
231 private:
232 void GenerateNativeCUIModuleTarget ( const Module& module );
233 };
234
235
236 class MingwWin32DLLModuleHandler : public MingwModuleHandler
237 {
238 public:
239 MingwWin32DLLModuleHandler ();
240 virtual void Process ( const Module& module );
241 private:
242 void GenerateExtractWineDLLResourcesTarget ( const Module& module );
243 void GenerateWin32DLLModuleTarget ( const Module& module );
244 };
245
246
247 class MingwWin32CUIModuleHandler : public MingwModuleHandler
248 {
249 public:
250 MingwWin32CUIModuleHandler ();
251 virtual void Process ( const Module& module );
252 private:
253 void GenerateWin32CUIModuleTarget ( const Module& module );
254 };
255
256
257 class MingwWin32GUIModuleHandler : public MingwModuleHandler
258 {
259 public:
260 MingwWin32GUIModuleHandler ();
261 virtual void Process ( const Module& module );
262 private:
263 void GenerateWin32GUIModuleTarget ( const Module& module );
264 };
265
266
267 class MingwBootLoaderModuleHandler : public MingwModuleHandler
268 {
269 public:
270 MingwBootLoaderModuleHandler ();
271 virtual void Process ( const Module& module );
272 private:
273 void GenerateBootLoaderModuleTarget ( const Module& module );
274 };
275
276
277 class MingwBootSectorModuleHandler : public MingwModuleHandler
278 {
279 public:
280 MingwBootSectorModuleHandler ();
281 virtual void Process ( const Module& module );
282 private:
283 void GenerateBootSectorModuleTarget ( const Module& module );
284 };
285
286
287 class MingwIsoModuleHandler : public MingwModuleHandler
288 {
289 public:
290 MingwIsoModuleHandler ();
291 virtual void Process ( const Module& module );
292 private:
293 void GenerateIsoModuleTarget ( const Module& module );
294 };
295
296 #endif /* MINGW_MODULEHANDLER_H */