1 #ifndef MINGW_MODULEHANDLER_H
2 #define MINGW_MODULEHANDLER_H
4 #include "../backend.h"
10 GetTargetMacro ( const Module
&, bool with_dollar
= true );
14 const std::string
& filename
,
15 const std::string
& prefix
);
17 class MingwModuleHandler
20 MingwModuleHandler ( const Module
& module_
);
21 virtual ~MingwModuleHandler();
23 static void SetBackend ( MingwBackend
* backend_
);
24 static void SetMakefile ( FILE* f
);
25 static void SetUsePch ( bool use_pch
);
27 static std::string
PassThruCacheDirectory (
29 Directory
* directoryTree
);
31 static Directory
* GetTargetDirectoryTree (
32 const Module
& module
);
34 static std::string
GetTargetFilename (
36 string_list
* pclean_files
);
39 GetImportLibraryFilename (
41 string_list
* pclean_files
);
43 static std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
);
44 static std::string
GenerateGccIncludeParametersFromVector ( const std::vector
<Include
*>& includes
);
46 std::string
GetModuleTargets ( const Module
& module
);
47 void GetObjectsVector ( const IfableData
& data
,
48 std::vector
<std::string
>& objectFiles
) const;
49 void GenerateObjectMacro();
50 void GenerateTargetMacro();
51 void GenerateOtherMacros();
53 static MingwModuleHandler
* InstanciateHandler ( const Module
& module_
,
54 MingwBackend
* backend_
);
55 virtual HostType
DefaultHost() = 0;
56 void GeneratePreconditionDependencies ();
57 virtual void Process () = 0;
58 virtual std::string
TypeSpecificCFlags() { return ""; }
59 virtual std::string
TypeSpecificNasmFlags() { return ""; }
60 virtual std::string
TypeSpecificLinkerFlags() { return ""; }
61 void GenerateInvocations () const;
62 void GenerateCleanTarget () const;
63 void GenerateInstallTarget () const;
64 static bool ReferenceObjects ( const Module
& module
);
66 virtual void GetModuleSpecificSourceFiles ( std::vector
<File
*>& sourceFiles
);
67 std::string
GetWorkingDirectory () const;
68 std::string
GetBasename ( const std::string
& filename
) const;
69 std::string
GetActualSourceFilename ( const std::string
& filename
) const;
70 std::string
GetModuleArchiveFilename () const;
71 bool IsGeneratedFile ( const File
& file
) const;
72 std::string
GetImportLibraryDependency ( const Module
& importedModule
);
73 void GetTargets ( const Module
& dependencyModule
,
74 string_list
& targets
);
75 void GetModuleDependencies ( string_list
& dependencies
);
76 std::string
GetAllDependencies () const;
77 void GetSourceFilenames ( string_list
& list
,
78 bool includeGeneratedFiles
) const;
79 void GetSourceFilenamesWithoutGeneratedFiles ( string_list
& list
) const;
80 std::string
GetObjectFilename ( const std::string
& sourceFilename
,
81 string_list
* pclean_files
) const;
83 std::string
GetObjectFilenames ();
85 std::string
GetPreconditionDependenciesName () const;
86 std::string
GetCFlagsMacro () const;
87 static std::string
GetObjectsMacro ( const Module
& );
88 std::string
GetLinkingDependenciesMacro () const;
89 std::string
GetLibsMacro () const;
90 std::string
GetLinkerMacro () const;
91 void GenerateCleanObjectsAsYouGoCode () const;
92 void GenerateRunRsymCode () const;
93 void GenerateLinkerCommand ( const std::string
& dependencies
,
94 const std::string
& linker
,
95 const std::string
& linkerParameters
,
96 const std::string
& objectsMacro
,
97 const std::string
& libsMacro
);
98 void GeneratePhonyTarget() const;
99 void GenerateRules ();
100 void GenerateImportLibraryTargetIfNeeded ();
101 void GetDefinitionDependencies ( string_list
& dependencies
) const;
102 std::string
GetLinkingDependencies () const;
103 static MingwBackend
* backend
;
104 static FILE* fMakefile
;
107 std::string
ConcatenatePaths ( const std::string
& path1
,
108 const std::string
& path2
) const;
109 std::string
GenerateGccDefineParameters () const;
110 std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
) const;
111 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
112 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
113 std::string
GenerateLinkerParameters () const;
114 void GenerateMacro ( const char* assignmentOperation
,
115 const std::string
& macro
,
116 const IfableData
& data
);
117 void GenerateMacros ( const char* op
,
118 const IfableData
& data
,
119 const std::vector
<LinkerFlag
*>* linkerFlags
);
120 void GenerateObjectMacros ( const char* assignmentOperation
,
121 const IfableData
& data
,
122 const std::vector
<LinkerFlag
*>* linkerFlags
);
123 std::string
GenerateGccIncludeParameters () const;
124 std::string
GenerateGccParameters () const;
125 std::string
GenerateNasmParameters () const;
126 void GenerateGccCommand ( const std::string
& sourceFilename
,
127 const std::string
& cc
,
128 const std::string
& cflagsMacro
);
129 void GenerateGccAssemblerCommand ( const std::string
& sourceFilename
,
130 const std::string
& cc
,
131 const std::string
& cflagsMacro
);
132 void GenerateNasmCommand ( const std::string
& sourceFilename
,
133 const std::string
& nasmflagsMacro
);
134 void GenerateWindresCommand ( const std::string
& sourceFilename
,
135 const std::string
& windresflagsMacro
);
136 void GenerateWinebuildCommands ( const std::string
& sourceFilename
);
137 std::string
GetWidlFlags ( const File
& file
);
138 void GenerateWidlCommandsServer (
140 const std::string
& widlflagsMacro
);
141 void GenerateWidlCommandsClient (
143 const std::string
& widlflagsMacro
);
144 void GenerateWidlCommands ( const File
& file
,
145 const std::string
& widlflagsMacro
);
146 void GenerateCommands ( const File
& file
,
147 const std::string
& cc
,
148 const std::string
& cppc
,
149 const std::string
& cflagsMacro
,
150 const std::string
& nasmflagsMacro
,
151 const std::string
& windresflagsMacro
,
152 const std::string
& widlflagsMacro
);
153 void GenerateObjectFileTargets ( const IfableData
& data
,
154 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 void GenerateObjectFileTargets ( const std::string
& cc
,
161 const std::string
& cppc
,
162 const std::string
& cflagsMacro
,
163 const std::string
& nasmflagsMacro
,
164 const std::string
& windresflagsMacro
,
165 const std::string
& widlflagsMacro
);
166 std::string
GenerateArchiveTarget ( const std::string
& ar
,
167 const std::string
& objs_macro
) const;
168 void GetSpecObjectDependencies ( string_list
& dependencies
,
169 const std::string
& filename
) const;
170 void GetWidlObjectDependencies ( string_list
& dependencies
,
171 const std::string
& filename
) const;
172 void GetDefaultDependencies ( string_list
& dependencies
) const;
173 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
174 bool IsWineModule () const;
175 std::string
GetDefinitionFilename () const;
176 static std::string
RemoveVariables ( std::string path
);
177 void GenerateBuildMapCode ();
178 void GenerateBuildNonSymbolStrippedCode ();
179 void CleanupFileVector ( std::vector
<File
*>& sourceFiles
);
180 void GetRpcHeaderDependencies ( string_list
& dependencies
) const;
181 std::string
GetRpcServerHeaderFilename ( std::string basename
) const;
182 std::string
GetRpcClientHeaderFilename ( std::string basename
) const;
184 const Module
& module
;
185 string_list clean_files
;
186 std::string cflagsMacro
;
187 std::string nasmflagsMacro
;
188 std::string windresflagsMacro
;
189 std::string widlflagsMacro
;
190 std::string linkerflagsMacro
;
191 std::string objectsMacro
;
192 std::string libsMacro
;
193 std::string linkDepsMacro
;
197 class MingwBuildToolModuleHandler
: public MingwModuleHandler
200 MingwBuildToolModuleHandler ( const Module
& module
);
201 virtual HostType
DefaultHost() { return HostTrue
; }
202 virtual void Process ();
204 void GenerateBuildToolModuleTarget ();
208 class MingwKernelModuleHandler
: public MingwModuleHandler
211 MingwKernelModuleHandler ( const Module
& module
);
212 virtual HostType
DefaultHost() { return HostFalse
; }
213 virtual void Process ();
214 std::string
TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }
216 void GenerateKernelModuleTarget ();
220 class MingwStaticLibraryModuleHandler
: public MingwModuleHandler
223 MingwStaticLibraryModuleHandler ( const Module
& module
);
224 virtual HostType
DefaultHost() { return HostFalse
; }
225 virtual void Process ();
227 void GenerateStaticLibraryModuleTarget ();
231 class MingwObjectLibraryModuleHandler
: public MingwModuleHandler
234 MingwObjectLibraryModuleHandler ( const Module
& module
);
235 virtual HostType
DefaultHost() { return HostFalse
; }
236 virtual void Process ();
238 void GenerateObjectLibraryModuleTarget ();
242 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
245 MingwKernelModeDLLModuleHandler ( const Module
& module
);
246 virtual HostType
DefaultHost() { return HostFalse
; }
247 virtual void Process ();
248 std::string
TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }
249 std::string
TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
251 void GenerateKernelModeDLLModuleTarget ();
255 class MingwKernelModeDriverModuleHandler
: public MingwModuleHandler
258 MingwKernelModeDriverModuleHandler ( const Module
& module
);
259 virtual HostType
DefaultHost() { return HostFalse
; }
260 virtual void Process ();
261 std::string
TypeSpecificCFlags() { return "-D__NTDRIVER__ -D_SEH_NO_NATIVE_NLG"; }
262 std::string
TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
264 void GenerateKernelModeDriverModuleTarget ();
268 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
271 MingwNativeDLLModuleHandler ( const Module
& module
);
272 virtual HostType
DefaultHost() { return HostFalse
; }
273 virtual void Process ();
274 std::string
TypeSpecificCFlags() { return "-D_SEH_NO_NATIVE_NLG"; }
275 std::string
TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
277 void GenerateNativeDLLModuleTarget ();
281 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
284 MingwNativeCUIModuleHandler ( const Module
& module
);
285 virtual HostType
DefaultHost() { return HostFalse
; }
286 virtual void Process ();
287 std::string
TypeSpecificCFlags() { return "-D__NTAPP__ -D_SEH_NO_NATIVE_NLG"; }
288 std::string
TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
290 void GenerateNativeCUIModuleTarget ();
294 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
297 MingwWin32DLLModuleHandler ( const Module
& module
);
298 virtual HostType
DefaultHost() { return HostFalse
; }
299 virtual void Process ();
301 void GenerateWin32DLLModuleTarget ();
305 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
308 MingwWin32CUIModuleHandler ( const Module
& module
);
309 virtual HostType
DefaultHost() { return HostFalse
; }
310 virtual void Process ();
312 void GenerateWin32CUIModuleTarget ();
316 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
319 MingwWin32GUIModuleHandler ( const Module
& module
);
320 virtual HostType
DefaultHost() { return HostFalse
; }
321 virtual void Process ();
323 void GenerateWin32GUIModuleTarget ();
327 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
330 MingwBootLoaderModuleHandler ( const Module
& module
);
331 virtual HostType
DefaultHost() { return HostFalse
; }
332 virtual void Process ();
333 std::string
TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
335 void GenerateBootLoaderModuleTarget ();
339 class MingwBootSectorModuleHandler
: public MingwModuleHandler
342 MingwBootSectorModuleHandler ( const Module
& module
);
343 virtual HostType
DefaultHost() { return HostFalse
; }
344 virtual void Process ();
345 std::string
TypeSpecificNasmFlags() { return "-f bin"; }
347 void GenerateBootSectorModuleTarget ();
351 class MingwIsoModuleHandler
: public MingwModuleHandler
354 MingwIsoModuleHandler ( const Module
& module
);
355 virtual HostType
DefaultHost() { return HostFalse
; }
356 virtual void Process ();
358 void GenerateIsoModuleTarget ();
359 std::string
GetBootstrapCdDirectories ( const std::string
& bootcdDirectory
);
360 std::string
GetNonModuleCdDirectories ( const std::string
& bootcdDirectory
);
361 std::string
GetCdDirectories ( const std::string
& bootcdDirectory
);
362 void GetBootstrapCdFiles ( std::vector
<std::string
>& out
) const;
363 void GetNonModuleCdFiles ( std::vector
<std::string
>& out
) const;
364 void GetCdFiles ( std::vector
<std::string
>& out
) const;
365 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
366 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
370 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
373 MingwLiveIsoModuleHandler ( const Module
& module
);
374 virtual HostType
DefaultHost() { return HostFalse
; }
375 virtual void Process ();
377 void GenerateLiveIsoModuleTarget ();
378 void CreateDirectory ( const std::string
& directory
);
379 void OutputCopyCommand ( const std::string
& sourceFilename
,
380 const std::string
& targetFilename
,
381 const std::string
& targetDirectory
);
382 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
383 std::string
& livecdReactos
);
384 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
385 std::string
& livecdReactos
);
386 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
387 void OutputLoaderCommands ( std::string
& livecdDirectory
);
388 void OutputRegistryCommands ( std::string
& livecdDirectory
);
392 class MingwTestModuleHandler
: public MingwModuleHandler
395 MingwTestModuleHandler ( const Module
& module
);
396 virtual HostType
DefaultHost() { return HostFalse
; }
397 virtual void Process ();
399 virtual void GetModuleSpecificSourceFiles ( std::vector
<File
*>& sourceFiles
);
401 void GenerateTestModuleTarget ();
405 class MingwRpcServerModuleHandler
: public MingwModuleHandler
408 MingwRpcServerModuleHandler ( const Module
& module
);
409 virtual HostType
DefaultHost() { return HostFalse
; }
410 virtual void Process ();
414 class MingwRpcClientModuleHandler
: public MingwModuleHandler
417 MingwRpcClientModuleHandler ( const Module
& module
);
418 virtual HostType
DefaultHost() { return HostFalse
; }
419 virtual void Process ();
422 #endif /* MINGW_MODULEHANDLER_H */