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
);
42 class MingwModuleHandler
45 MingwModuleHandler ( const Module
& module_
);
46 virtual ~MingwModuleHandler();
48 static void SetBackend ( MingwBackend
* backend_
);
49 static void SetMakefile ( FILE* f
);
50 void EnablePreCompiledHeaderSupport ();
52 static const FileLocation
* PassThruCacheDirectory (const FileLocation
* fileLocation
);
54 static const FileLocation
* GetTargetFilename (
56 string_list
* pclean_files
);
58 static const FileLocation
* GetImportLibraryFilename (
60 string_list
* pclean_files
);
62 static std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
, std::set
<std::string
> &used_defs
);
63 static std::string
GenerateDefineParametersFromVector ( const std::vector
<Define
*>& defines
, CompilerType compiler
);
64 static std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
);
65 static std::string
GenerateIncludeParametersFromVector ( const std::vector
<Include
*>& includes
, CompilerType compiler
);
67 static void GenerateParameters ( const char* prefix
,
68 const char* assignmentOperation
,
69 const IfableData
& data
);
71 std::string
GetModuleTargets ( const Module
& module
);
72 void GetObjectsVector ( const IfableData
& data
,
73 std::vector
<FileLocation
>& objectFiles
) const;
74 void GenerateSourceMacro();
75 void GenerateObjectMacro();
76 void GenerateTargetMacro();
77 void GenerateOtherMacros();
79 static MingwModuleHandler
* InstanciateHandler ( const Module
& module_
,
80 MingwBackend
* backend_
);
81 void GeneratePreconditionDependencies ();
82 virtual void Process () { GenerateRules (); }
83 void GenerateInvocations () const;
84 void GenerateCleanTarget () const;
85 void GenerateInstallTarget () const;
86 void GenerateDependsTarget () const;
87 static bool ReferenceObjects ( const Module
& module
);
88 virtual void AddImplicitLibraries ( Module
& module
) { return; }
90 void OutputCopyCommand ( const FileLocation
& source
,
91 const FileLocation
& destination
);
93 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
94 std::string
GetWorkingDirectory () const;
95 std::string
GetBasename ( const std::string
& filename
) const;
96 std::string
GetCompilationUnitDependencies ( const CompilationUnit
& compilationUnit
) const;
97 const FileLocation
* GetModuleArchiveFilename () const;
98 std::string
GetImportLibraryDependency ( const Module
& importedModule
);
99 void GetTargets ( const Module
& dependencyModule
,
100 string_list
& targets
);
101 void GetModuleDependencies ( string_list
& dependencies
);
102 std::string
GetAllDependencies () const;
103 const FileLocation
* GetObjectFilename ( const FileLocation
* sourceFile
,
104 const Module
& module
) const;
106 std::string
GetPreconditionDependenciesName () const;
107 static std::string
GetObjectsMacro ( const Module
& );
108 std::string
GetLinkingDependenciesMacro () const;
109 std::string
GetLibsMacro () const;
110 std::string
GetLinkerMacro () const;
111 static std::string
GetDebugFormat ();
112 void GenerateCleanObjectsAsYouGoCode () const;
113 void GenerateRunRsymCode () const;
114 void GenerateRunStripCode () const;
115 void GenerateLinkerCommand ( const std::string
& dependencies
,
116 const std::string
& linkerParameters
,
117 const std::string
& pefixupParameters
);
118 void GeneratePhonyTarget() const;
119 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
120 void GenerateRules ();
121 void GenerateImportLibraryTargetIfNeeded ();
122 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
123 std::string
GetLinkingDependencies () const;
124 static MingwBackend
* backend
;
125 static FILE* fMakefile
;
128 std::string
ConcatenatePaths ( const std::string
& path1
,
129 const std::string
& path2
) const;
130 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
131 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
132 std::string
GenerateLinkerParameters () const;
133 void GenerateMacros ( const char* op
,
134 const IfableData
& data
,
135 const std::vector
<LinkerFlag
*>* linkerFlags
,
136 std::set
<const Define
*>& used_defs
);
137 void GenerateSourceMacros ( const IfableData
& data
);
138 void GenerateObjectMacros ( const IfableData
& data
);
139 const FileLocation
* GetPrecompiledHeaderFilename () const;
140 const FileLocation
* GetPrecompiledHeaderPath () const;
141 const FileLocation
* GetDlldataFilename () const;
142 void GenerateGccCommand ( const FileLocation
* sourceFile
,
144 const std::string
& extraDependencies
);
145 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
146 const std::string
& extraDependencies
);
147 void GenerateObjectFileTargets ( const IfableData
& data
);
148 void GenerateObjectFileTargets ();
149 const FileLocation
* GenerateArchiveTarget ();
150 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
151 const FileLocation
*file
) const;
152 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
153 const FileLocation
*file
) const;
154 void GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
155 const FileLocation
*file
) const;
156 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
157 const FileLocation
*file
) const;
158 void GetDefaultDependencies ( string_list
& dependencies
) const;
159 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
160 SpecFileType
IsSpecDefinitionFile () const;
161 const FileLocation
* GetDefinitionFilename () const;
162 void GenerateBuildNonSymbolStrippedCode ();
163 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
164 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
165 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
166 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
167 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
168 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
169 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
170 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
171 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
172 std::string
GetModuleCleanTarget ( const Module
& module
) const;
173 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
175 const Module
& module
;
176 string_list clean_files
;
177 std::string commonflagsMacro
;
178 std::string cflagsMacro
;
179 std::string cxxflagsMacro
;
180 std::string nasmflagsMacro
;
181 std::string windresflagsMacro
;
182 std::string widlflagsMacro
;
183 std::string linkerflagsMacro
;
184 std::string sourcesMacro
;
185 std::string objectsMacro
;
186 std::string libsMacro
;
187 std::string linkDepsMacro
;
191 class MingwBuildToolModuleHandler
: public MingwModuleHandler
194 MingwBuildToolModuleHandler ( const Module
& module
);
195 virtual void Process ();
197 void GenerateBuildToolModuleTarget ();
201 class MingwKernelModuleHandler
: public MingwModuleHandler
204 MingwKernelModuleHandler ( const Module
& module
);
205 virtual void Process ();
207 void GenerateKernelModuleTarget ();
211 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
214 MingwKernelModeDLLModuleHandler ( const Module
& module
);
215 virtual void Process ();
216 void AddImplicitLibraries ( Module
& module
);
218 void GenerateKernelModeDLLModuleTarget ();
222 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
225 MingwNativeDLLModuleHandler ( const Module
& module
);
226 virtual void Process ();
227 void AddImplicitLibraries ( Module
& module
);
229 void GenerateNativeDLLModuleTarget ();
233 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
236 MingwNativeCUIModuleHandler ( const Module
& module
);
237 virtual void Process ();
238 void AddImplicitLibraries ( Module
& module
);
240 void GenerateNativeCUIModuleTarget ();
244 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
247 MingwWin32DLLModuleHandler ( const Module
& module
);
248 virtual void Process ();
249 void AddImplicitLibraries ( Module
& module
);
251 void GenerateWin32DLLModuleTarget ();
255 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
258 MingwWin32OCXModuleHandler ( const Module
& module
);
259 virtual void Process ();
260 void AddImplicitLibraries ( Module
& module
);
262 void GenerateWin32OCXModuleTarget ();
266 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
269 MingwWin32CUIModuleHandler ( const Module
& module
);
270 virtual void Process ();
271 void AddImplicitLibraries ( Module
& module
);
273 void GenerateWin32CUIModuleTarget ();
277 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
280 MingwWin32GUIModuleHandler ( const Module
& module
);
281 virtual void Process ();
282 void AddImplicitLibraries ( Module
& module
);
284 void GenerateWin32GUIModuleTarget ();
288 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
291 MingwBootLoaderModuleHandler ( const Module
& module
);
292 virtual void Process ();
294 void GenerateBootLoaderModuleTarget ();
298 class MingwBootProgramModuleHandler
: public MingwModuleHandler
301 MingwBootProgramModuleHandler ( const Module
& module
);
302 virtual void Process ();
303 std::string
GetProgTextAddrMacro ();
305 void GenerateBootProgramModuleTarget ();
309 class MingwIsoModuleHandler
: public MingwModuleHandler
312 MingwIsoModuleHandler ( const Module
& module
);
313 virtual void Process ();
315 void GenerateIsoModuleTarget ();
316 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
317 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
318 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
319 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
320 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
321 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
322 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
323 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
327 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
330 MingwLiveIsoModuleHandler ( const Module
& module
);
331 virtual void Process ();
333 void GenerateLiveIsoModuleTarget ();
334 void CreateDirectory ( const std::string
& directory
);
335 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
336 std::string
& livecdReactos
);
337 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
338 std::string
& livecdReactos
);
339 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
340 void OutputLoaderCommands ( std::string
& livecdDirectory
);
341 void OutputRegistryCommands ( std::string
& livecdDirectory
);
345 class MingwTestModuleHandler
: public MingwModuleHandler
348 MingwTestModuleHandler ( const Module
& module
);
349 virtual void Process ();
351 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
353 void GenerateTestModuleTarget ();
356 class MingwAliasModuleHandler
: public MingwModuleHandler
359 MingwAliasModuleHandler ( const Module
& module
);
360 virtual void Process ();
363 class MingwCabinetModuleHandler
: public MingwModuleHandler
366 MingwCabinetModuleHandler ( const Module
& module
);
367 virtual void Process ();
370 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
373 MingwElfExecutableModuleHandler ( const Module
& module
);
374 virtual void Process ();
377 #endif /* MINGW_MODULEHANDLER_H */