host vs target refactoring, <module> has two new attributes 'host' and 'prefix' ...
[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 extern std::string
11 PrefixFilename (
12 const std::string& filename,
13 const std::string& prefix );
14
15 class MingwModuleHandler
16 {
17 public:
18 typedef std::vector<std::string> string_list;
19
20 static std::map<ModuleType,MingwModuleHandler*>* handler_map;
21 static int ref;
22
23 MingwModuleHandler ( ModuleType moduletype );
24 virtual ~MingwModuleHandler();
25
26 static void SetMakefile ( FILE* f );
27 static void SetUsePch ( bool use_pch );
28 static MingwModuleHandler* LookupHandler ( const std::string& location,
29 ModuleType moduletype_ );
30 virtual HostType DefaultHost() = 0;
31 virtual void Process ( const Module& module, string_list& clean_files ) = 0;
32 bool IncludeDirectoryTarget ( const std::string& directory ) const;
33 void GenerateDirectoryTargets () const;
34 void GenerateCleanTarget ( const Module& module,
35 const string_list& clean_files ) const;
36 protected:
37 const std::string &PassThruCacheDirectory ( const std::string &f ) const;
38 std::string GetWorkingDirectory () const;
39 std::string GetBasename ( const std::string& filename ) const;
40 std::string GetActualSourceFilename ( const std::string& filename ) const;
41 std::string GetModuleArchiveFilename ( const Module& module ) const;
42 bool IsGeneratedFile ( const File& file ) const;
43 std::string GetImportLibraryDependency ( const Module& importedModule ) const;
44 std::string GetModuleDependencies ( const Module& module ) const;
45 std::string GetAllDependencies ( const Module& module ) const;
46 std::string GetSourceFilenames ( const Module& module,
47 bool includeGeneratedFiles ) const;
48 std::string GetSourceFilenames ( const Module& module ) const;
49 std::string GetSourceFilenamesWithoutGeneratedFiles ( const Module& module ) const;
50
51 std::string GetObjectFilenames ( const Module& module ) const;
52 std::string GetInvocationDependencies ( const Module& module ) const;
53 void GenerateInvocations ( const Module& module ) const;
54
55 std::string GetPreconditionDependenciesName ( const Module& module ) const;
56 void GeneratePreconditionDependencies ( const Module& module ) const;
57 std::string GetCFlagsMacro ( const Module& module ) const;
58 std::string GetObjectsMacro ( const Module& module ) const;
59 std::string GetLinkingDependenciesMacro ( const Module& module ) const;
60 std::string GetLibsMacro ( const Module& module ) const;
61 std::string GetLinkerMacro ( const Module& module ) const;
62 void GenerateLinkerCommand ( const Module& module,
63 const std::string& linker,
64 const std::string& linkerParameters,
65 const std::string& objectsMacro,
66 const std::string& libsMacro,
67 string_list& clean_files ) const;
68 void GenerateMacrosAndTargets ( const Module& module,
69 const std::string* clags,
70 const std::string* nasmflags,
71 string_list& clean_files ) const;
72 void GenerateImportLibraryTargetIfNeeded ( const Module& module, string_list& clean_files ) const;
73 std::string GetDefinitionDependencies ( const Module& module ) const;
74 std::string GetLinkingDependencies ( const Module& module ) const;
75 bool IsCPlusPlusModule ( const Module& module ) const;
76 static FILE* fMakefile;
77 static bool use_pch;
78 static std::set<std::string> directory_set;
79 private:
80 std::string ConcatenatePaths ( const std::string& path1,
81 const std::string& path2 ) const;
82 std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
83 std::string GenerateGccDefineParameters ( const Module& module ) const;
84 std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
85 std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;
86 std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
87 std::string GenerateImportLibraryDependenciesFromVector ( const std::vector<Library*>& libraries ) const;
88 std::string GenerateLinkerParameters ( const Module& module ) const;
89 void GenerateMacro ( const char* assignmentOperation,
90 const std::string& macro,
91 const IfableData& data,
92 const std::vector<CompilerFlag*>* compilerFlags ) const;
93 void GenerateMacros (
94 const Module& module,
95 const char* op,
96 const IfableData& data,
97 const std::vector<CompilerFlag*>* compilerFlags,
98 const std::vector<LinkerFlag*>* linkerFlags,
99 const std::string& cflags_macro,
100 const std::string& nasmflags_macro,
101 const std::string& windresflags_macro,
102 const std::string& linkerflags_macro,
103 const std::string& objs_macro,
104 const std::string& libs_macro,
105 const std::string& linkdeps_macro ) const;
106 void GenerateMacros ( const Module& module,
107 const std::string& cflags_macro,
108 const std::string& nasmflags_macro,
109 const std::string& windresflags_macro,
110 const std::string& linkerflags_macro,
111 const std::string& objs_macro,
112 const std::string& libs_macro,
113 const std::string& linkDepsMacro ) const;
114 std::string GenerateGccIncludeParameters ( const Module& module ) const;
115 std::string GenerateGccParameters ( const Module& module ) const;
116 std::string GenerateNasmParameters ( const Module& module ) const;
117 void GenerateGccCommand ( const Module& module,
118 const std::string& sourceFilename,
119 const std::string& cc,
120 const std::string& cflagsMacro ) const;
121 void GenerateGccAssemblerCommand ( const Module& module,
122 const std::string& sourceFilename,
123 const std::string& cc,
124 const std::string& cflagsMacro ) const;
125 void GenerateNasmCommand ( const Module& module,
126 const std::string& sourceFilename,
127 const std::string& nasmflagsMacro ) const;
128 void GenerateWindresCommand ( const Module& module,
129 const std::string& sourceFilename,
130 const std::string& windresflagsMacro ) const;
131 void GenerateWinebuildCommands ( const Module& module,
132 const std::string& sourceFilename,
133 string_list& clean_files ) const;
134 void GenerateCommands ( const Module& module,
135 const std::string& sourceFilename,
136 const std::string& cc,
137 const std::string& cppc,
138 const std::string& cflagsMacro,
139 const std::string& nasmflagsMacro,
140 const std::string& windresflagsMacro,
141 string_list& clean_files ) const;
142 void GenerateObjectFileTargets ( const Module& module,
143 const IfableData& data,
144 const std::string& cc,
145 const std::string& cppc,
146 const std::string& cflagsMacro,
147 const std::string& nasmflagsMacro,
148 const std::string& windresflagsMacro,
149 string_list& clean_files ) const;
150 void GenerateObjectFileTargets ( const Module& module,
151 const std::string& cc,
152 const std::string& cppc,
153 const std::string& cflagsMacro,
154 const std::string& nasmflagsMacro,
155 const std::string& windresflagsMacro,
156 string_list& clean_files ) const;
157 std::string GenerateArchiveTarget ( const Module& module,
158 const std::string& ar,
159 const std::string& objs_macro ) const;
160 std::string GetSpecObjectDependencies ( const std::string& filename ) const;
161 std::string GetDefaultDependencies ( const Module& module ) const;
162 };
163
164
165 class MingwBuildToolModuleHandler : public MingwModuleHandler
166 {
167 public:
168 MingwBuildToolModuleHandler ();
169 virtual HostType DefaultHost() { return HostTrue; }
170 virtual void Process ( const Module& module, string_list& clean_files );
171 private:
172 void GenerateBuildToolModuleTarget ( const Module& module, string_list& clean_files );
173 };
174
175
176 class MingwKernelModuleHandler : public MingwModuleHandler
177 {
178 public:
179 MingwKernelModuleHandler ();
180 virtual HostType DefaultHost() { return HostFalse; }
181 virtual void Process ( const Module& module, string_list& clean_files );
182 private:
183 void GenerateKernelModuleTarget ( const Module& module, string_list& clean_files );
184 };
185
186
187 class MingwStaticLibraryModuleHandler : public MingwModuleHandler
188 {
189 public:
190 MingwStaticLibraryModuleHandler ();
191 virtual HostType DefaultHost() { return HostFalse; }
192 virtual void Process ( const Module& module, string_list& clean_files );
193 private:
194 void GenerateStaticLibraryModuleTarget ( const Module& module, string_list& clean_files );
195 };
196
197
198 class MingwObjectLibraryModuleHandler : public MingwModuleHandler
199 {
200 public:
201 MingwObjectLibraryModuleHandler ();
202 virtual HostType DefaultHost() { return HostFalse; }
203 virtual void Process ( const Module& module, string_list& clean_files );
204 private:
205 void GenerateObjectLibraryModuleTarget ( const Module& module, string_list& clean_files );
206 };
207
208
209 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
210 {
211 public:
212 MingwKernelModeDLLModuleHandler ();
213 virtual HostType DefaultHost() { return HostFalse; }
214 virtual void Process ( const Module& module, string_list& clean_files );
215 private:
216 void GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files );
217 };
218
219
220 class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
221 {
222 public:
223 MingwKernelModeDriverModuleHandler ();
224 virtual HostType DefaultHost() { return HostFalse; }
225 virtual void Process ( const Module& module, string_list& clean_files );
226 private:
227 void GenerateKernelModeDriverModuleTarget ( const Module& module, string_list& clean_files );
228 };
229
230
231 class MingwNativeDLLModuleHandler : public MingwModuleHandler
232 {
233 public:
234 MingwNativeDLLModuleHandler ();
235 virtual HostType DefaultHost() { return HostFalse; }
236 virtual void Process ( const Module& module, string_list& clean_files );
237 private:
238 void GenerateNativeDLLModuleTarget ( const Module& module, string_list& clean_files );
239 };
240
241
242 class MingwNativeCUIModuleHandler : public MingwModuleHandler
243 {
244 public:
245 MingwNativeCUIModuleHandler ();
246 virtual HostType DefaultHost() { return HostFalse; }
247 virtual void Process ( const Module& module, string_list& clean_files );
248 private:
249 void GenerateNativeCUIModuleTarget ( const Module& module, string_list& clean_files );
250 };
251
252
253 class MingwWin32DLLModuleHandler : public MingwModuleHandler
254 {
255 public:
256 MingwWin32DLLModuleHandler ();
257 virtual HostType DefaultHost() { return HostFalse; }
258 virtual void Process ( const Module& module, string_list& clean_files );
259 private:
260 void GenerateExtractWineDLLResourcesTarget ( const Module& module, string_list& clean_files );
261 void GenerateWin32DLLModuleTarget ( const Module& module, string_list& clean_files );
262 };
263
264
265 class MingwWin32CUIModuleHandler : public MingwModuleHandler
266 {
267 public:
268 MingwWin32CUIModuleHandler ();
269 virtual HostType DefaultHost() { return HostFalse; }
270 virtual void Process ( const Module& module, string_list& clean_files );
271 private:
272 void GenerateWin32CUIModuleTarget ( const Module& module, string_list& clean_files );
273 };
274
275
276 class MingwWin32GUIModuleHandler : public MingwModuleHandler
277 {
278 public:
279 MingwWin32GUIModuleHandler ();
280 virtual HostType DefaultHost() { return HostFalse; }
281 virtual void Process ( const Module& module, string_list& clean_files );
282 private:
283 void GenerateWin32GUIModuleTarget ( const Module& module, string_list& clean_files );
284 };
285
286
287 class MingwBootLoaderModuleHandler : public MingwModuleHandler
288 {
289 public:
290 MingwBootLoaderModuleHandler ();
291 virtual HostType DefaultHost() { return HostFalse; }
292 virtual void Process ( const Module& module, string_list& clean_files );
293 private:
294 void GenerateBootLoaderModuleTarget ( const Module& module, string_list& clean_files );
295 };
296
297
298 class MingwBootSectorModuleHandler : public MingwModuleHandler
299 {
300 public:
301 MingwBootSectorModuleHandler ();
302 virtual HostType DefaultHost() { return HostFalse; }
303 virtual void Process ( const Module& module, string_list& clean_files );
304 private:
305 void GenerateBootSectorModuleTarget ( const Module& module, string_list& clean_files );
306 };
307
308
309 class MingwIsoModuleHandler : public MingwModuleHandler
310 {
311 public:
312 MingwIsoModuleHandler ();
313 virtual HostType DefaultHost() { return HostFalse; }
314 virtual void Process ( const Module& module, string_list& clean_files );
315 private:
316 void GenerateIsoModuleTarget ( const Module& module, string_list& clean_files );
317 std::string GetBootstrapCdDirectories ( const std::string bootcdDirectory,
318 const Module& module ) const;
319 std::string GetNonModuleCdDirectories ( const std::string bootcdDirectory,
320 const Module& module ) const;
321 std::string GetCdDirectories ( const std::string bootcdDirectory,
322 const Module& module ) const;
323 std::string GetBootstrapCdFiles ( const std::string bootcdDirectory,
324 const Module& module ) const;
325 std::string GetNonModuleCdFiles ( const std::string bootcdDirectory,
326 const Module& module ) const;
327 std::string GetCdFiles ( const std::string bootcdDirectory,
328 const Module& module ) const;
329 void OutputBootstrapfileCopyCommands ( const std::string bootcdDirectory,
330 const Module& module ) const;
331 void OutputCdfileCopyCommands ( const std::string bootcdDirectory,
332 const Module& module ) const;
333 };
334
335 #endif /* MINGW_MODULEHANDLER_H */