1 #ifndef MINGW_MODULEHANDLER_H
2 #define MINGW_MODULEHANDLER_H
4 #include "../backend.h"
7 ReplaceExtension ( const std::string
& filename
,
8 const std::string
& newExtension
);
12 const std::string
& filename
,
13 const std::string
& prefix
);
15 class MingwModuleHandler
18 typedef std::vector
<std::string
> string_list
;
20 static std::map
<ModuleType
,MingwModuleHandler
*>* handler_map
;
23 MingwModuleHandler ( ModuleType moduletype
);
24 virtual ~MingwModuleHandler();
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;
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;
51 std::string
GetObjectFilenames ( const Module
& module
) const;
52 std::string
GetInvocationDependencies ( const Module
& module
) const;
53 void GenerateInvocations ( const Module
& module
) const;
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
& target
,
64 const std::string
& dependencies
,
65 const std::string
& linker
,
66 const std::string
& linkerParameters
,
67 const std::string
& objectsMacro
,
68 const std::string
& libsMacro
,
69 string_list
& clean_files
) const;
70 void GenerateMacrosAndTargets ( const Module
& module
,
71 const std::string
* clags
,
72 const std::string
* nasmflags
,
73 string_list
& clean_files
) const;
74 void GenerateImportLibraryTargetIfNeeded ( const Module
& module
, string_list
& clean_files
) const;
75 std::string
GetDefinitionDependencies ( const Module
& module
) const;
76 std::string
GetLinkingDependencies ( const Module
& module
) const;
77 bool IsCPlusPlusModule ( const Module
& module
) const;
78 static FILE* fMakefile
;
80 static std::set
<std::string
> directory_set
;
82 std::string
ConcatenatePaths ( const std::string
& path1
,
83 const std::string
& path2
) const;
84 std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
) const;
85 std::string
GenerateGccDefineParameters ( const Module
& module
) const;
86 std::string
GenerateGccIncludeParametersFromVector ( const std::vector
<Include
*>& includes
) const;
87 std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
) const;
88 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
89 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
) const;
90 std::string
GenerateLinkerParameters ( const Module
& module
) const;
91 void GenerateMacro ( const char* assignmentOperation
,
92 const std::string
& macro
,
93 const IfableData
& data
,
94 const std::vector
<CompilerFlag
*>* compilerFlags
) const;
98 const IfableData
& data
,
99 const std::vector
<CompilerFlag
*>* compilerFlags
,
100 const std::vector
<LinkerFlag
*>* linkerFlags
,
101 const std::string
& cflags_macro
,
102 const std::string
& nasmflags_macro
,
103 const std::string
& windresflags_macro
,
104 const std::string
& linkerflags_macro
,
105 const std::string
& objs_macro
,
106 const std::string
& libs_macro
,
107 const std::string
& linkdeps_macro
) const;
108 void GenerateMacros ( const Module
& module
,
109 const std::string
& cflags_macro
,
110 const std::string
& nasmflags_macro
,
111 const std::string
& windresflags_macro
,
112 const std::string
& linkerflags_macro
,
113 const std::string
& objs_macro
,
114 const std::string
& libs_macro
,
115 const std::string
& linkDepsMacro
) const;
116 std::string
GenerateGccIncludeParameters ( const Module
& module
) const;
117 std::string
GenerateGccParameters ( const Module
& module
) const;
118 std::string
GenerateNasmParameters ( const Module
& module
) const;
119 void GenerateGccCommand ( const Module
& module
,
120 const std::string
& sourceFilename
,
121 const std::string
& cc
,
122 const std::string
& cflagsMacro
) const;
123 void GenerateGccAssemblerCommand ( const Module
& module
,
124 const std::string
& sourceFilename
,
125 const std::string
& cc
,
126 const std::string
& cflagsMacro
) const;
127 void GenerateNasmCommand ( const Module
& module
,
128 const std::string
& sourceFilename
,
129 const std::string
& nasmflagsMacro
) const;
130 void GenerateWindresCommand ( const Module
& module
,
131 const std::string
& sourceFilename
,
132 const std::string
& windresflagsMacro
) const;
133 void GenerateWinebuildCommands ( const Module
& module
,
134 const std::string
& sourceFilename
,
135 string_list
& clean_files
) const;
136 void GenerateCommands ( const Module
& module
,
137 const std::string
& sourceFilename
,
138 const std::string
& cc
,
139 const std::string
& cppc
,
140 const std::string
& cflagsMacro
,
141 const std::string
& nasmflagsMacro
,
142 const std::string
& windresflagsMacro
,
143 string_list
& clean_files
) const;
144 void GenerateObjectFileTargets ( const Module
& module
,
145 const IfableData
& data
,
146 const std::string
& cc
,
147 const std::string
& cppc
,
148 const std::string
& cflagsMacro
,
149 const std::string
& nasmflagsMacro
,
150 const std::string
& windresflagsMacro
,
151 string_list
& clean_files
) const;
152 void GenerateObjectFileTargets ( const Module
& module
,
153 const std::string
& cc
,
154 const std::string
& cppc
,
155 const std::string
& cflagsMacro
,
156 const std::string
& nasmflagsMacro
,
157 const std::string
& windresflagsMacro
,
158 string_list
& clean_files
) const;
159 std::string
GenerateArchiveTarget ( const Module
& module
,
160 const std::string
& ar
,
161 const std::string
& objs_macro
) const;
162 std::string
GetSpecObjectDependencies ( const std::string
& filename
) const;
163 std::string
GetDefaultDependencies ( const Module
& module
) const;
167 class MingwBuildToolModuleHandler
: public MingwModuleHandler
170 MingwBuildToolModuleHandler ();
171 virtual HostType
DefaultHost() { return HostTrue
; }
172 virtual void Process ( const Module
& module
, string_list
& clean_files
);
174 void GenerateBuildToolModuleTarget ( const Module
& module
, string_list
& clean_files
);
178 class MingwKernelModuleHandler
: public MingwModuleHandler
181 MingwKernelModuleHandler ();
182 virtual HostType
DefaultHost() { return HostFalse
; }
183 virtual void Process ( const Module
& module
, string_list
& clean_files
);
185 void GenerateKernelModuleTarget ( const Module
& module
, string_list
& clean_files
);
189 class MingwStaticLibraryModuleHandler
: public MingwModuleHandler
192 MingwStaticLibraryModuleHandler ();
193 virtual HostType
DefaultHost() { return HostFalse
; }
194 virtual void Process ( const Module
& module
, string_list
& clean_files
);
196 void GenerateStaticLibraryModuleTarget ( const Module
& module
, string_list
& clean_files
);
200 class MingwObjectLibraryModuleHandler
: public MingwModuleHandler
203 MingwObjectLibraryModuleHandler ();
204 virtual HostType
DefaultHost() { return HostFalse
; }
205 virtual void Process ( const Module
& module
, string_list
& clean_files
);
207 void GenerateObjectLibraryModuleTarget ( const Module
& module
, string_list
& clean_files
);
211 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
214 MingwKernelModeDLLModuleHandler ();
215 virtual HostType
DefaultHost() { return HostFalse
; }
216 virtual void Process ( const Module
& module
, string_list
& clean_files
);
218 void GenerateKernelModeDLLModuleTarget ( const Module
& module
, string_list
& clean_files
);
222 class MingwKernelModeDriverModuleHandler
: public MingwModuleHandler
225 MingwKernelModeDriverModuleHandler ();
226 virtual HostType
DefaultHost() { return HostFalse
; }
227 virtual void Process ( const Module
& module
, string_list
& clean_files
);
229 void GenerateKernelModeDriverModuleTarget ( const Module
& module
, string_list
& clean_files
);
233 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
236 MingwNativeDLLModuleHandler ();
237 virtual HostType
DefaultHost() { return HostFalse
; }
238 virtual void Process ( const Module
& module
, string_list
& clean_files
);
240 void GenerateNativeDLLModuleTarget ( const Module
& module
, string_list
& clean_files
);
244 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
247 MingwNativeCUIModuleHandler ();
248 virtual HostType
DefaultHost() { return HostFalse
; }
249 virtual void Process ( const Module
& module
, string_list
& clean_files
);
251 void GenerateNativeCUIModuleTarget ( const Module
& module
, string_list
& clean_files
);
255 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
258 MingwWin32DLLModuleHandler ();
259 virtual HostType
DefaultHost() { return HostFalse
; }
260 virtual void Process ( const Module
& module
, string_list
& clean_files
);
262 void GenerateExtractWineDLLResourcesTarget ( const Module
& module
, string_list
& clean_files
);
263 void GenerateWin32DLLModuleTarget ( const Module
& module
, string_list
& clean_files
);
267 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
270 MingwWin32CUIModuleHandler ();
271 virtual HostType
DefaultHost() { return HostFalse
; }
272 virtual void Process ( const Module
& module
, string_list
& clean_files
);
274 void GenerateWin32CUIModuleTarget ( const Module
& module
, string_list
& clean_files
);
278 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
281 MingwWin32GUIModuleHandler ();
282 virtual HostType
DefaultHost() { return HostFalse
; }
283 virtual void Process ( const Module
& module
, string_list
& clean_files
);
285 void GenerateWin32GUIModuleTarget ( const Module
& module
, string_list
& clean_files
);
289 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
292 MingwBootLoaderModuleHandler ();
293 virtual HostType
DefaultHost() { return HostFalse
; }
294 virtual void Process ( const Module
& module
, string_list
& clean_files
);
296 void GenerateBootLoaderModuleTarget ( const Module
& module
, string_list
& clean_files
);
300 class MingwBootSectorModuleHandler
: public MingwModuleHandler
303 MingwBootSectorModuleHandler ();
304 virtual HostType
DefaultHost() { return HostFalse
; }
305 virtual void Process ( const Module
& module
, string_list
& clean_files
);
307 void GenerateBootSectorModuleTarget ( const Module
& module
, string_list
& clean_files
);
311 class MingwIsoModuleHandler
: public MingwModuleHandler
314 MingwIsoModuleHandler ();
315 virtual HostType
DefaultHost() { return HostFalse
; }
316 virtual void Process ( const Module
& module
, string_list
& clean_files
);
318 void GenerateIsoModuleTarget ( const Module
& module
, string_list
& clean_files
);
319 std::string
GetBootstrapCdDirectories ( const std::string
& bootcdDirectory
,
320 const Module
& module
) const;
321 std::string
GetNonModuleCdDirectories ( const std::string
& bootcdDirectory
,
322 const Module
& module
) const;
323 std::string
GetCdDirectories ( const std::string
& bootcdDirectory
,
324 const Module
& module
) const;
325 void GetBootstrapCdFiles ( std::vector
<std::string
>& out
,
326 const Module
& module
) const;
327 void GetNonModuleCdFiles ( std::vector
<std::string
>& out
,
328 const Module
& module
) const;
329 void GetCdFiles ( std::vector
<std::string
>& out
,
330 const Module
& module
) const;
331 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
,
332 const Module
& module
) const;
333 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
,
334 const Module
& module
) const;
337 #endif /* MINGW_MODULEHANDLER_H */