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
,
63 static std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
, std::set
<std::string
> &used_defs
);
64 static std::string
GenerateDefineParametersFromVector ( const std::vector
<Define
*>& defines
, CompilerType compiler
);
65 static std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
);
66 static std::string
GenerateIncludeParametersFromVector ( const std::vector
<Include
*>& includes
, CompilerType compiler
);
68 static void GenerateParameters ( const char* prefix
,
69 const char* assignmentOperation
,
70 const IfableData
& data
);
72 std::string
GetModuleTargets ( const Module
& module
);
73 void GetObjectsVector ( const IfableData
& data
,
74 std::vector
<FileLocation
>& objectFiles
) const;
75 void GenerateSourceMacro();
76 void GenerateObjectMacro();
77 void GenerateTargetMacro();
78 void GenerateOtherMacros();
80 static MingwModuleHandler
* InstanciateHandler ( const Module
& module_
,
81 MingwBackend
* backend_
);
82 void GeneratePreconditionDependencies ();
83 virtual void Process () { GenerateRules (); }
84 void GenerateInvocations () const;
85 void GenerateCleanTarget () const;
86 void GenerateInstallTarget () const;
87 void GenerateDependsTarget () const;
88 static bool ReferenceObjects ( const Module
& module
);
89 virtual void AddImplicitLibraries ( Module
& module
) { return; }
91 void OutputCopyCommand ( const FileLocation
& source
,
92 const FileLocation
& destination
);
93 void OutputCopyCommandSingle ( const FileLocation
& source
,
94 const FileLocation
& destination
);
96 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
97 std::string
GetWorkingDirectory () const;
98 std::string
GetBasename ( const std::string
& filename
) const;
99 std::string
GetCompilationUnitDependencies ( const CompilationUnit
& compilationUnit
) const;
100 const FileLocation
* GetModuleArchiveFilename () const;
101 std::string
GetImportLibraryDependency ( const Module
& importedModule
, bool delayimp
);
102 void GetTargets ( const Module
& dependencyModule
,
103 string_list
& targets
);
104 void GetModuleDependencies ( string_list
& dependencies
);
105 std::string
GetAllDependencies () const;
106 const FileLocation
* GetObjectFilename ( const FileLocation
* sourceFile
,
107 const Module
& module
) const;
109 std::string
GetPreconditionDependenciesName () const;
110 static std::string
GetObjectsMacro ( const Module
& );
111 std::string
GetLinkingDependenciesMacro () const;
112 std::string
GetLibsMacro () const;
113 std::string
GetLinkerMacro () const;
114 static std::string
GetDebugFormat ();
115 void GenerateCleanObjectsAsYouGoCode () const;
116 void GenerateRunRsymCode () const;
117 void GenerateRunStripCode () const;
118 void GenerateLinkerCommand ( const std::string
& dependencies
,
119 const std::string
& linkerParameters
,
120 const std::string
& pefixupParameters
);
121 void GeneratePhonyTarget() const;
122 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
123 void GenerateRules ();
124 void GenerateImportLibraryTarget (const FileLocation
*defFilename
, const FileLocation
*library_target
, bool delayimp
);
125 void GenerateImportLibraryTargetIfNeeded ();
126 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
127 std::string
GetLinkingDependencies () const;
128 static MingwBackend
* backend
;
129 static FILE* fMakefile
;
132 std::string
ConcatenatePaths ( const std::string
& path1
,
133 const std::string
& path2
) const;
134 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
135 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
136 std::string
GenerateLinkerParameters () const;
137 void GenerateMacros ( const char* op
,
138 const IfableData
& data
,
139 const std::vector
<LinkerFlag
*>* linkerFlags
,
140 std::set
<const Define
*>& used_defs
);
141 void GenerateSourceMacros ( const IfableData
& data
);
142 void GenerateObjectMacros ( const IfableData
& data
);
143 const FileLocation
* GetPrecompiledHeaderFilename () const;
144 const FileLocation
* GetPrecompiledHeaderPath () const;
145 const FileLocation
* GetDlldataFilename () const;
146 void GenerateGccCommand ( const FileLocation
* sourceFile
,
148 const std::string
& extraDependencies
);
149 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
150 const std::string
& extraDependencies
);
151 void GenerateObjectFileTargets ( const IfableData
& data
);
152 void GenerateObjectFileTargets ();
153 const FileLocation
* GenerateArchiveTarget ();
154 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
155 const FileLocation
*file
) const;
156 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
157 const FileLocation
*file
) const;
158 void GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
159 const FileLocation
*file
) const;
160 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
161 const FileLocation
*file
) const;
162 void GetDefaultDependencies ( string_list
& dependencies
) const;
163 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
164 SpecFileType
IsSpecDefinitionFile () const;
165 const FileLocation
* GetDefinitionFilename () const;
166 void GenerateBuildNonSymbolStrippedCode ();
167 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
168 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
169 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
170 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
171 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
172 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
173 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
174 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
175 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
176 std::string
GetModuleCleanTarget ( const Module
& module
) const;
177 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
179 const Module
& module
;
180 string_list clean_files
;
181 std::string commonflagsMacro
;
182 std::string cflagsMacro
;
183 std::string cxxflagsMacro
;
184 std::string nasmflagsMacro
;
185 std::string windresflagsMacro
;
186 std::string widlflagsMacro
;
187 std::string linkerflagsMacro
;
188 std::string sourcesMacro
;
189 std::string objectsMacro
;
190 std::string libsMacro
;
191 std::string linkDepsMacro
;
195 class MingwBuildToolModuleHandler
: public MingwModuleHandler
198 MingwBuildToolModuleHandler ( const Module
& module
);
199 virtual void Process ();
201 void GenerateBuildToolModuleTarget ();
205 class MingwKernelModuleHandler
: public MingwModuleHandler
208 MingwKernelModuleHandler ( const Module
& module
);
209 virtual void Process ();
211 void GenerateKernelModuleTarget ();
215 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
218 MingwKernelModeDLLModuleHandler ( const Module
& module
);
219 virtual void Process ();
220 void AddImplicitLibraries ( Module
& module
);
222 void GenerateKernelModeDLLModuleTarget ();
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 std::vector
<FileLocation
>& destinations
);
342 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
343 std::string
& livecdReactos
,
344 std::vector
<FileLocation
>& destinations
);
345 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
,
346 std::vector
<FileLocation
>& destinations
);
347 void OutputLoaderCommands ( std::string
& livecdDirectory
,
348 std::vector
<FileLocation
>& destinations
);
349 void OutputRegistryCommands ( std::string
& livecdDirectory
);
353 class MingwTestModuleHandler
: public MingwModuleHandler
356 MingwTestModuleHandler ( const Module
& module
);
357 virtual void Process ();
359 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
361 void GenerateTestModuleTarget ();
364 class MingwAliasModuleHandler
: public MingwModuleHandler
367 MingwAliasModuleHandler ( const Module
& module
);
368 virtual void Process ();
371 class MingwCabinetModuleHandler
: public MingwModuleHandler
374 MingwCabinetModuleHandler ( const Module
& module
);
375 virtual void Process ();
378 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
381 MingwElfExecutableModuleHandler ( const Module
& module
);
382 virtual void Process ();
385 #endif /* MINGW_MODULEHANDLER_H */