Support 'make livecd'
[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 #include "mingw.h"
6
7 class MingwBackend;
8
9 extern std::string
10 GetTargetMacro ( const Module&, bool with_dollar = true );
11
12 extern std::string
13 PrefixFilename (
14 const std::string& filename,
15 const std::string& prefix );
16
17 class MingwModuleHandler
18 {
19 public:
20 MingwModuleHandler ( const Module& module_ );
21 virtual ~MingwModuleHandler();
22
23 static void SetBackend ( MingwBackend* backend_ );
24 static void SetMakefile ( FILE* f );
25 static void SetUsePch ( bool use_pch );
26
27 static std::string PassThruCacheDirectory (
28 const std::string &f,
29 Directory* directoryTree );
30
31 static std::string GetTargetFilename (
32 const Module& module,
33 string_list* pclean_files );
34
35 static std::string
36 GetImportLibraryFilename (
37 const Module& module,
38 string_list* pclean_files );
39
40 std::string GetModuleTargets ( const Module& module );
41 void GenerateObjectMacro();
42 void GenerateTargetMacro();
43 void GenerateOtherMacros();
44
45 static MingwModuleHandler* InstanciateHandler ( const Module& module_,
46 MingwBackend* backend_ );
47 virtual HostType DefaultHost() = 0;
48 void GeneratePreconditionDependencies ();
49 virtual void Process () = 0;
50 virtual std::string TypeSpecificCFlags() { return ""; }
51 virtual std::string TypeSpecificNasmFlags() { return ""; }
52 void GenerateInvocations () const;
53 void GenerateCleanTarget () const;
54 static bool ReferenceObjects ( const Module& module );
55 protected:
56 std::string GetWorkingDirectory () const;
57 std::string GetBasename ( const std::string& filename ) const;
58 std::string GetActualSourceFilename ( const std::string& filename ) const;
59 std::string GetModuleArchiveFilename () const;
60 bool IsGeneratedFile ( const File& file ) const;
61 std::string GetImportLibraryDependency ( const Module& importedModule );
62 void GetTargets ( const Module& dependencyModule,
63 string_list& targets );
64 void GetModuleDependencies ( string_list& dependencies );
65 std::string GetAllDependencies () const;
66 void GetSourceFilenames ( string_list& list, bool includeGeneratedFiles = true ) const;
67 void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list ) const;
68 std::string GetObjectFilename ( const std::string& sourceFilename,
69 string_list* pclean_files ) const;
70
71 std::string GetObjectFilenames ();
72
73 std::string GetPreconditionDependenciesName () const;
74 std::string GetCFlagsMacro () const;
75 static std::string GetObjectsMacro ( const Module& );
76 std::string GetLinkingDependenciesMacro () const;
77 std::string GetLibsMacro () const;
78 std::string GetLinkerMacro () const;
79 void GenerateLinkerCommand ( const std::string& dependencies,
80 const std::string& linker,
81 const std::string& linkerParameters,
82 const std::string& objectsMacro,
83 const std::string& libsMacro );
84 void GeneratePhonyTarget() const;
85 void GenerateRules ();
86 void GenerateImportLibraryTargetIfNeeded ();
87 void GetDefinitionDependencies ( string_list& dependencies ) const;
88 std::string GetLinkingDependencies () const;
89 static MingwBackend* backend;
90 static FILE* fMakefile;
91 static bool use_pch;
92 private:
93 std::string ConcatenatePaths ( const std::string& path1,
94 const std::string& path2 ) const;
95 std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
96 std::string GenerateGccDefineParameters () const;
97 std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
98 std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;
99 std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
100 std::string GenerateImportLibraryDependenciesFromVector ( const std::vector<Library*>& libraries );
101 std::string GenerateLinkerParameters () const;
102 void GenerateMacro ( const char* assignmentOperation,
103 const std::string& macro,
104 const IfableData& data,
105 const std::vector<CompilerFlag*>* compilerFlags );
106 void GenerateMacros ( const char* op,
107 const IfableData& data,
108 const std::vector<CompilerFlag*>* compilerFlags,
109 const std::vector<LinkerFlag*>* linkerFlags );
110 void GenerateObjectMacros ( const char* assignmentOperation,
111 const IfableData& data,
112 const std::vector<CompilerFlag*>* compilerFlags,
113 const std::vector<LinkerFlag*>* linkerFlags );
114 std::string GenerateGccIncludeParameters () const;
115 std::string GenerateGccParameters () const;
116 std::string GenerateNasmParameters () const;
117 void GenerateGccCommand ( const std::string& sourceFilename,
118 const std::string& cc,
119 const std::string& cflagsMacro );
120 void GenerateGccAssemblerCommand ( const std::string& sourceFilename,
121 const std::string& cc,
122 const std::string& cflagsMacro );
123 void GenerateNasmCommand ( const std::string& sourceFilename,
124 const std::string& nasmflagsMacro );
125 void GenerateWindresCommand ( const std::string& sourceFilename,
126 const std::string& windresflagsMacro );
127 void GenerateWinebuildCommands ( const std::string& sourceFilename );
128 void GenerateWidlCommandsServer (
129 const std::string& sourceFilename,
130 const std::string& widlflagsMacro );
131 void GenerateWidlCommandsClient (
132 const std::string& sourceFilename,
133 const std::string& widlflagsMacro );
134 void GenerateWidlCommands ( const std::string& sourceFilename,
135 const std::string& widlflagsMacro );
136 void GenerateCommands ( const std::string& sourceFilename,
137 const std::string& cc,
138 const std::string& cppc,
139 const std::string& cflagsMacro,
140 const std::string& nasmflagsMacro,
141 const std::string& windresflagsMacro,
142 const std::string& widlflagsMacro );
143 void GenerateObjectFileTargets ( 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 const std::string& widlflagsMacro );
150 void GenerateObjectFileTargets ( const std::string& cc,
151 const std::string& cppc,
152 const std::string& cflagsMacro,
153 const std::string& nasmflagsMacro,
154 const std::string& windresflagsMacro,
155 const std::string& widlflagsMacro );
156 std::string GenerateArchiveTarget ( const std::string& ar,
157 const std::string& objs_macro ) const;
158 void GetSpecObjectDependencies ( string_list& dependencies,
159 const std::string& filename ) const;
160 void GetWidlObjectDependencies ( string_list& dependencies,
161 const std::string& filename ) const;
162 void GetDefaultDependencies ( string_list& dependencies ) const;
163 void GetInvocationDependencies ( const Module& module, string_list& dependencies );
164 bool IsWineModule () const;
165 std::string GetDefinitionFilename () const;
166 static std::string RemoveVariables ( std::string path);
167 void GenerateBuildMapCode ();
168 public:
169 const Module& module;
170 string_list clean_files;
171 std::string cflagsMacro;
172 std::string nasmflagsMacro;
173 std::string windresflagsMacro;
174 std::string widlflagsMacro;
175 std::string linkerflagsMacro;
176 std::string objectsMacro;
177 std::string libsMacro;
178 std::string linkDepsMacro;
179 };
180
181
182 class MingwBuildToolModuleHandler : public MingwModuleHandler
183 {
184 public:
185 MingwBuildToolModuleHandler ( const Module& module );
186 virtual HostType DefaultHost() { return HostTrue; }
187 virtual void Process ();
188 private:
189 void GenerateBuildToolModuleTarget ();
190 };
191
192
193 class MingwKernelModuleHandler : public MingwModuleHandler
194 {
195 public:
196 MingwKernelModuleHandler ( const Module& module );
197 virtual HostType DefaultHost() { return HostFalse; }
198 virtual void Process ();
199 private:
200 void GenerateKernelModuleTarget ();
201 };
202
203
204 class MingwStaticLibraryModuleHandler : public MingwModuleHandler
205 {
206 public:
207 MingwStaticLibraryModuleHandler ( const Module& module );
208 virtual HostType DefaultHost() { return HostFalse; }
209 virtual void Process ();
210 private:
211 void GenerateStaticLibraryModuleTarget ();
212 };
213
214
215 class MingwObjectLibraryModuleHandler : public MingwModuleHandler
216 {
217 public:
218 MingwObjectLibraryModuleHandler ( const Module& module );
219 virtual HostType DefaultHost() { return HostFalse; }
220 virtual void Process ();
221 private:
222 void GenerateObjectLibraryModuleTarget ();
223 };
224
225
226 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
227 {
228 public:
229 MingwKernelModeDLLModuleHandler ( const Module& module );
230 virtual HostType DefaultHost() { return HostFalse; }
231 virtual void Process ();
232 private:
233 void GenerateKernelModeDLLModuleTarget ();
234 };
235
236
237 class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
238 {
239 public:
240 MingwKernelModeDriverModuleHandler ( const Module& module );
241 virtual HostType DefaultHost() { return HostFalse; }
242 virtual void Process ();
243 std::string TypeSpecificCFlags() { return "-D__NTDRIVER__"; }
244 private:
245 void GenerateKernelModeDriverModuleTarget ();
246 };
247
248
249 class MingwNativeDLLModuleHandler : public MingwModuleHandler
250 {
251 public:
252 MingwNativeDLLModuleHandler ( const Module& module );
253 virtual HostType DefaultHost() { return HostFalse; }
254 virtual void Process ();
255 private:
256 void GenerateNativeDLLModuleTarget ();
257 };
258
259
260 class MingwNativeCUIModuleHandler : public MingwModuleHandler
261 {
262 public:
263 MingwNativeCUIModuleHandler ( const Module& module );
264 virtual HostType DefaultHost() { return HostFalse; }
265 virtual void Process ();
266 std::string TypeSpecificCFlags() { return "-D__NTAPP__"; }
267 private:
268 void GenerateNativeCUIModuleTarget ();
269 };
270
271
272 class MingwWin32DLLModuleHandler : public MingwModuleHandler
273 {
274 public:
275 MingwWin32DLLModuleHandler ( const Module& module );
276 virtual HostType DefaultHost() { return HostFalse; }
277 virtual void Process ();
278 private:
279 void GenerateExtractWineDLLResourcesTarget ();
280 void GenerateWin32DLLModuleTarget ();
281 };
282
283
284 class MingwWin32CUIModuleHandler : public MingwModuleHandler
285 {
286 public:
287 MingwWin32CUIModuleHandler ( const Module& module );
288 virtual HostType DefaultHost() { return HostFalse; }
289 virtual void Process ();
290 private:
291 void GenerateWin32CUIModuleTarget ();
292 };
293
294
295 class MingwWin32GUIModuleHandler : public MingwModuleHandler
296 {
297 public:
298 MingwWin32GUIModuleHandler ( const Module& module );
299 virtual HostType DefaultHost() { return HostFalse; }
300 virtual void Process ();
301 private:
302 void GenerateWin32GUIModuleTarget ();
303 };
304
305
306 class MingwBootLoaderModuleHandler : public MingwModuleHandler
307 {
308 public:
309 MingwBootLoaderModuleHandler ( const Module& module );
310 virtual HostType DefaultHost() { return HostFalse; }
311 virtual void Process ();
312 private:
313 void GenerateBootLoaderModuleTarget ();
314 };
315
316
317 class MingwBootSectorModuleHandler : public MingwModuleHandler
318 {
319 public:
320 MingwBootSectorModuleHandler ( const Module& module );
321 virtual HostType DefaultHost() { return HostFalse; }
322 virtual void Process ();
323 std::string TypeSpecificNasmFlags() { return "-f bin"; }
324 private:
325 void GenerateBootSectorModuleTarget ();
326 };
327
328
329 class MingwIsoModuleHandler : public MingwModuleHandler
330 {
331 public:
332 MingwIsoModuleHandler ( const Module& module );
333 virtual HostType DefaultHost() { return HostFalse; }
334 virtual void Process ();
335 private:
336 void GenerateIsoModuleTarget ();
337 std::string GetBootstrapCdDirectories ( const std::string& bootcdDirectory );
338 std::string GetNonModuleCdDirectories ( const std::string& bootcdDirectory );
339 std::string GetCdDirectories ( const std::string& bootcdDirectory );
340 void GetBootstrapCdFiles ( std::vector<std::string>& out ) const;
341 void GetNonModuleCdFiles ( std::vector<std::string>& out ) const;
342 void GetCdFiles ( std::vector<std::string>& out ) const;
343 void OutputBootstrapfileCopyCommands ( const std::string& bootcdDirectory );
344 void OutputCdfileCopyCommands ( const std::string& bootcdDirectory );
345 };
346
347
348 class MingwLiveIsoModuleHandler : public MingwModuleHandler
349 {
350 public:
351 MingwLiveIsoModuleHandler ( const Module& module );
352 virtual HostType DefaultHost() { return HostFalse; }
353 virtual void Process ();
354 private:
355 void GenerateLiveIsoModuleTarget ();
356 void CreateDirectory ( const std::string& directory );
357 void OutputCopyCommand ( const std::string& sourceFilename,
358 const std::string& targetFilename,
359 const std::string& targetDirectory );
360 void OutputModuleCopyCommands ( std::string& livecdDirectory,
361 std::string& livecdReactos );
362 void OutputNonModuleCopyCommands ( std::string& livecdDirectory,
363 std::string& livecdReactos );
364 void OutputProfilesDirectoryCommands ( std::string& livecdDirectory );
365 void OutputLoaderCommands ( std::string& livecdDirectory );
366 void OutputRegistryCommands ( std::string& livecdDirectory );
367 };
368
369
370 class MingwTestModuleHandler : public MingwModuleHandler
371 {
372 public:
373 MingwTestModuleHandler ( const Module& module );
374 virtual HostType DefaultHost() { return HostFalse; }
375 virtual void Process ();
376 private:
377 void GenerateTestModuleTarget ();
378 };
379
380
381 class MingwRpcServerModuleHandler : public MingwModuleHandler
382 {
383 public:
384 MingwRpcServerModuleHandler ( const Module& module );
385 virtual HostType DefaultHost() { return HostFalse; }
386 virtual void Process ();
387 };
388
389
390 class MingwRpcClientModuleHandler : public MingwModuleHandler
391 {
392 public:
393 MingwRpcClientModuleHandler ( const Module& module );
394 virtual HostType DefaultHost() { return HostFalse; }
395 virtual void Process ();
396 };
397
398 #endif /* MINGW_MODULEHANDLER_H */