2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #ifndef MINGW_MODULEHANDLER_H
19 #define MINGW_MODULEHANDLER_H
21 #include "../backend.h"
28 GetTargetMacro ( const Module
&, bool with_dollar
= true );
32 const std::string
& filename
,
33 const std::string
& prefix
);
35 class MingwModuleHandler
38 MingwModuleHandler ( const Module
& module_
);
39 virtual ~MingwModuleHandler();
41 static void SetBackend ( MingwBackend
* backend_
);
42 static void SetMakefile ( FILE* f
);
43 void EnablePreCompiledHeaderSupport ();
45 static const FileLocation
* PassThruCacheDirectory (const FileLocation
* fileLocation
);
47 static const FileLocation
* GetTargetFilename (
49 string_list
* pclean_files
);
51 static const FileLocation
* GetImportLibraryFilename (
53 string_list
* pclean_files
);
55 static std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
, std::set
<std::string
> &used_defs
);
56 static std::string
GenerateGccIncludeParametersFromVector ( const std::vector
<Include
*>& includes
);
58 std::string
GetModuleTargets ( const Module
& module
);
59 void GetObjectsVector ( const IfableData
& data
,
60 std::vector
<FileLocation
>& objectFiles
) const;
61 void GenerateSourceMacro();
62 void GenerateObjectMacro();
63 void GenerateTargetMacro();
64 void GenerateOtherMacros();
66 static MingwModuleHandler
* InstanciateHandler ( const Module
& module_
,
67 MingwBackend
* backend_
);
68 void GeneratePreconditionDependencies ();
69 virtual void Process () { GenerateRules (); }
70 void GenerateInvocations () const;
71 void GenerateCleanTarget () const;
72 void GenerateInstallTarget () const;
73 void GenerateDependsTarget () const;
74 static bool ReferenceObjects ( const Module
& module
);
75 virtual void AddImplicitLibraries ( Module
& module
) { return; }
77 void OutputCopyCommand ( const FileLocation
& source
,
78 const FileLocation
& destination
);
80 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
81 std::string
GetWorkingDirectory () const;
82 std::string
GetBasename ( const std::string
& filename
) const;
83 std::string
GetCompilationUnitDependencies ( const CompilationUnit
& compilationUnit
) const;
84 const FileLocation
* GetModuleArchiveFilename () const;
85 std::string
GetImportLibraryDependency ( const Module
& importedModule
);
86 void GetTargets ( const Module
& dependencyModule
,
87 string_list
& targets
);
88 void GetModuleDependencies ( string_list
& dependencies
);
89 std::string
GetAllDependencies () const;
90 const FileLocation
* GetObjectFilename ( const FileLocation
* sourceFile
,
91 const Module
& module
) const;
93 std::string
GetObjectFilenames ();
95 std::string
GetPreconditionDependenciesName () const;
96 std::string
GetCFlagsMacro () const;
97 static std::string
GetObjectsMacro ( const Module
& );
98 std::string
GetLinkingDependenciesMacro () const;
99 std::string
GetLibsMacro () const;
100 std::string
GetLinkerMacro () const;
101 void GenerateCleanObjectsAsYouGoCode () const;
102 void GenerateRunRsymCode () const;
103 void GenerateRunStripCode () const;
104 void GenerateLinkerCommand ( const std::string
& dependencies
,
105 const std::string
& linkerParameters
,
106 const std::string
& pefixupParameters
);
107 void GeneratePhonyTarget() const;
108 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
109 void GenerateRules ();
110 void GenerateImportLibraryTargetIfNeeded ();
111 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
112 std::string
GetLinkingDependencies () const;
113 static MingwBackend
* backend
;
114 static FILE* fMakefile
;
117 std::string
ConcatenatePaths ( const std::string
& path1
,
118 const std::string
& path2
) const;
119 std::string
GenerateGccDefineParameters () const;
120 std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const;
121 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
122 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
123 std::string
GenerateLinkerParameters () const;
124 void GenerateMacro ( const char* assignmentOperation
,
125 const std::string
& macro
,
126 const IfableData
& data
,
127 std::set
<const Define
*>* used_defs
,
128 bool generatingCompilerMacro
);
129 void GenerateMacros ( const char* op
,
130 const IfableData
& data
,
131 const std::vector
<LinkerFlag
*>* linkerFlags
,
132 std::set
<const Define
*>& used_defs
);
133 void GenerateSourceMacros ( const IfableData
& data
);
134 void GenerateObjectMacros ( const IfableData
& data
);
135 std::string
GenerateGccIncludeParameters () const;
136 std::string
GenerateGccParameters () const;
137 std::string
GenerateNasmParameters () const;
138 const FileLocation
* GetPrecompiledHeaderFilename () const;
139 void GenerateGccCommand ( const FileLocation
* sourceFile
,
141 const std::string
& extraDependencies
);
142 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
143 const std::string
& extraDependencies
);
144 void GenerateObjectFileTargets ( const IfableData
& data
);
145 void GenerateObjectFileTargets ();
146 const FileLocation
* GenerateArchiveTarget ();
147 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
148 const FileLocation
*file
) const;
149 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
150 const FileLocation
*file
) const;
151 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
152 const FileLocation
*file
) const;
153 void GetDefaultDependencies ( string_list
& dependencies
) const;
154 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
155 bool IsWineModule () const;
156 const FileLocation
* GetDefinitionFilename () const;
157 void GenerateBuildNonSymbolStrippedCode ();
158 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
159 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
160 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
161 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
162 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
163 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
164 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
165 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
166 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
167 std::string
GetModuleCleanTarget ( const Module
& module
) const;
168 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
170 const Module
& module
;
171 string_list clean_files
;
172 std::string cflagsMacro
;
173 std::string nasmflagsMacro
;
174 std::string windresflagsMacro
;
175 std::string widlflagsMacro
;
176 std::string linkerflagsMacro
;
177 std::string sourcesMacro
;
178 std::string objectsMacro
;
179 std::string libsMacro
;
180 std::string linkDepsMacro
;
184 class MingwBuildToolModuleHandler
: public MingwModuleHandler
187 MingwBuildToolModuleHandler ( const Module
& module
);
188 virtual void Process ();
190 void GenerateBuildToolModuleTarget ();
194 class MingwKernelModuleHandler
: public MingwModuleHandler
197 MingwKernelModuleHandler ( const Module
& module
);
198 virtual void Process ();
200 void GenerateKernelModuleTarget ();
204 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
207 MingwKernelModeDLLModuleHandler ( const Module
& module
);
208 virtual void Process ();
209 void AddImplicitLibraries ( Module
& module
);
211 void GenerateKernelModeDLLModuleTarget ();
215 class MingwKernelModeDriverModuleHandler
: public MingwModuleHandler
218 MingwKernelModeDriverModuleHandler ( const Module
& module
);
219 virtual void Process ();
220 void AddImplicitLibraries ( Module
& module
);
222 void GenerateKernelModeDriverModuleTarget ();
226 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
229 MingwNativeDLLModuleHandler ( const Module
& module
);
230 virtual void Process ();
231 void AddImplicitLibraries ( Module
& module
);
233 void GenerateNativeDLLModuleTarget ();
237 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
240 MingwNativeCUIModuleHandler ( const Module
& module
);
241 virtual void Process ();
242 void AddImplicitLibraries ( Module
& module
);
244 void GenerateNativeCUIModuleTarget ();
248 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
251 MingwWin32DLLModuleHandler ( const Module
& module
);
252 virtual void Process ();
253 void AddImplicitLibraries ( Module
& module
);
255 void GenerateWin32DLLModuleTarget ();
259 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
262 MingwWin32OCXModuleHandler ( const Module
& module
);
263 virtual void Process ();
264 void AddImplicitLibraries ( Module
& module
);
266 void GenerateWin32OCXModuleTarget ();
270 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
273 MingwWin32CUIModuleHandler ( const Module
& module
);
274 virtual void Process ();
275 void AddImplicitLibraries ( Module
& module
);
277 void GenerateWin32CUIModuleTarget ();
281 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
284 MingwWin32GUIModuleHandler ( const Module
& module
);
285 virtual void Process ();
286 void AddImplicitLibraries ( Module
& module
);
288 void GenerateWin32GUIModuleTarget ();
292 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
295 MingwBootLoaderModuleHandler ( const Module
& module
);
296 virtual void Process ();
298 void GenerateBootLoaderModuleTarget ();
302 class MingwBootProgramModuleHandler
: public MingwModuleHandler
305 MingwBootProgramModuleHandler ( const Module
& module
);
306 virtual void Process ();
307 std::string
GetProgTextAddrMacro ();
309 void GenerateBootProgramModuleTarget ();
313 class MingwIsoModuleHandler
: public MingwModuleHandler
316 MingwIsoModuleHandler ( const Module
& module
);
317 virtual void Process ();
319 void GenerateIsoModuleTarget ();
320 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
321 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
322 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
323 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
324 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
325 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
326 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
327 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
331 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
334 MingwLiveIsoModuleHandler ( const Module
& module
);
335 virtual void Process ();
337 void GenerateLiveIsoModuleTarget ();
338 void CreateDirectory ( const std::string
& directory
);
339 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
340 std::string
& livecdReactos
);
341 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
342 std::string
& livecdReactos
);
343 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
344 void OutputLoaderCommands ( std::string
& livecdDirectory
);
345 void OutputRegistryCommands ( std::string
& livecdDirectory
);
349 class MingwTestModuleHandler
: public MingwModuleHandler
352 MingwTestModuleHandler ( const Module
& module
);
353 virtual void Process ();
355 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
357 void GenerateTestModuleTarget ();
360 class MingwAliasModuleHandler
: public MingwModuleHandler
363 MingwAliasModuleHandler ( const Module
& module
);
364 virtual void Process ();
367 class MingwCabinetModuleHandler
: public MingwModuleHandler
370 MingwCabinetModuleHandler ( const Module
& module
);
371 virtual void Process ();
374 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
377 MingwElfExecutableModuleHandler ( const Module
& module
);
378 virtual void Process ();
381 #endif /* MINGW_MODULEHANDLER_H */