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