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
GenerateGccIncludeParametersFromVector ( const std::vector
<Include
*>& includes
);
65 std::string
GetModuleTargets ( const Module
& module
);
66 void GetObjectsVector ( const IfableData
& data
,
67 std::vector
<FileLocation
>& objectFiles
) const;
68 void GenerateSourceMacro();
69 void GenerateObjectMacro();
70 void GenerateTargetMacro();
71 void GenerateOtherMacros();
73 static MingwModuleHandler
* InstanciateHandler ( const Module
& module_
,
74 MingwBackend
* backend_
);
75 void GeneratePreconditionDependencies ();
76 virtual void Process () { GenerateRules (); }
77 void GenerateInvocations () const;
78 void GenerateCleanTarget () const;
79 void GenerateInstallTarget () const;
80 void GenerateDependsTarget () const;
81 static bool ReferenceObjects ( const Module
& module
);
82 virtual void AddImplicitLibraries ( Module
& module
) { return; }
84 void OutputCopyCommand ( const FileLocation
& source
,
85 const FileLocation
& destination
);
87 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
88 std::string
GetWorkingDirectory () const;
89 std::string
GetBasename ( const std::string
& filename
) const;
90 std::string
GetCompilationUnitDependencies ( const CompilationUnit
& compilationUnit
) const;
91 const FileLocation
* GetModuleArchiveFilename () const;
92 std::string
GetImportLibraryDependency ( const Module
& importedModule
);
93 void GetTargets ( const Module
& dependencyModule
,
94 string_list
& targets
);
95 void GetModuleDependencies ( string_list
& dependencies
);
96 std::string
GetAllDependencies () const;
97 const FileLocation
* GetObjectFilename ( const FileLocation
* sourceFile
,
98 const Module
& module
) const;
100 std::string
GetPreconditionDependenciesName () const;
101 static std::string
GetObjectsMacro ( const Module
& );
102 std::string
GetLinkingDependenciesMacro () const;
103 std::string
GetLibsMacro () const;
104 std::string
GetLinkerMacro () const;
105 void GenerateCleanObjectsAsYouGoCode () const;
106 void GenerateRunRsymCode () const;
107 void GenerateRunStripCode () const;
108 void GenerateLinkerCommand ( const std::string
& dependencies
,
109 const std::string
& linkerParameters
,
110 const std::string
& pefixupParameters
);
111 void GeneratePhonyTarget() const;
112 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
113 void GenerateRules ();
114 void GenerateImportLibraryTargetIfNeeded ();
115 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
116 std::string
GetLinkingDependencies () const;
117 static MingwBackend
* backend
;
118 static FILE* fMakefile
;
121 std::string
ConcatenatePaths ( const std::string
& path1
,
122 const std::string
& path2
) const;
123 std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const;
124 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
125 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
126 std::string
GenerateLinkerParameters () const;
127 void GenerateMacro ( const char* assignmentOperation
,
128 const std::string
& macro
,
129 const IfableData
& data
,
130 std::set
<const Define
*>* used_defs
,
131 bool generatingCompilerMacro
);
132 void GenerateMacros ( const char* op
,
133 const IfableData
& data
,
134 const std::vector
<LinkerFlag
*>* linkerFlags
,
135 std::set
<const Define
*>& used_defs
);
136 void GenerateSourceMacros ( const IfableData
& data
);
137 void GenerateObjectMacros ( const IfableData
& data
);
138 const FileLocation
* GetPrecompiledHeaderFilename () const;
139 const FileLocation
* GetDlldataFilename () const;
140 void GenerateGccCommand ( const FileLocation
* sourceFile
,
142 const std::string
& extraDependencies
);
143 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
144 const std::string
& extraDependencies
);
145 void GenerateObjectFileTargets ( const IfableData
& data
);
146 void GenerateObjectFileTargets ();
147 const FileLocation
* GenerateArchiveTarget ();
148 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
149 const FileLocation
*file
) const;
150 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
151 const FileLocation
*file
) const;
152 void GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
153 const FileLocation
*file
) const;
154 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
155 const FileLocation
*file
) const;
156 void GetDefaultDependencies ( string_list
& dependencies
) const;
157 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
158 SpecFileType
IsSpecDefinitionFile () const;
159 const FileLocation
* GetDefinitionFilename () const;
160 void GenerateBuildNonSymbolStrippedCode ();
161 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
162 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
163 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
164 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
165 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
166 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
167 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
168 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
169 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
170 std::string
GetModuleCleanTarget ( const Module
& module
) const;
171 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
173 const Module
& module
;
174 string_list clean_files
;
175 std::string commonflagsMacro
;
176 std::string cflagsMacro
;
177 std::string cxxflagsMacro
;
178 std::string nasmflagsMacro
;
179 std::string windresflagsMacro
;
180 std::string widlflagsMacro
;
181 std::string linkerflagsMacro
;
182 std::string sourcesMacro
;
183 std::string objectsMacro
;
184 std::string libsMacro
;
185 std::string linkDepsMacro
;
189 class MingwBuildToolModuleHandler
: public MingwModuleHandler
192 MingwBuildToolModuleHandler ( const Module
& module
);
193 virtual void Process ();
195 void GenerateBuildToolModuleTarget ();
199 class MingwKernelModuleHandler
: public MingwModuleHandler
202 MingwKernelModuleHandler ( const Module
& module
);
203 virtual void Process ();
205 void GenerateKernelModuleTarget ();
209 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
212 MingwKernelModeDLLModuleHandler ( const Module
& module
);
213 virtual void Process ();
214 void AddImplicitLibraries ( Module
& module
);
216 void GenerateKernelModeDLLModuleTarget ();
220 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
223 MingwNativeDLLModuleHandler ( const Module
& module
);
224 virtual void Process ();
225 void AddImplicitLibraries ( Module
& module
);
227 void GenerateNativeDLLModuleTarget ();
231 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
234 MingwNativeCUIModuleHandler ( const Module
& module
);
235 virtual void Process ();
236 void AddImplicitLibraries ( Module
& module
);
238 void GenerateNativeCUIModuleTarget ();
242 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
245 MingwWin32DLLModuleHandler ( const Module
& module
);
246 virtual void Process ();
247 void AddImplicitLibraries ( Module
& module
);
249 void GenerateWin32DLLModuleTarget ();
253 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
256 MingwWin32OCXModuleHandler ( const Module
& module
);
257 virtual void Process ();
258 void AddImplicitLibraries ( Module
& module
);
260 void GenerateWin32OCXModuleTarget ();
264 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
267 MingwWin32CUIModuleHandler ( const Module
& module
);
268 virtual void Process ();
269 void AddImplicitLibraries ( Module
& module
);
271 void GenerateWin32CUIModuleTarget ();
275 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
278 MingwWin32GUIModuleHandler ( const Module
& module
);
279 virtual void Process ();
280 void AddImplicitLibraries ( Module
& module
);
282 void GenerateWin32GUIModuleTarget ();
286 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
289 MingwBootLoaderModuleHandler ( const Module
& module
);
290 virtual void Process ();
292 void GenerateBootLoaderModuleTarget ();
296 class MingwBootProgramModuleHandler
: public MingwModuleHandler
299 MingwBootProgramModuleHandler ( const Module
& module
);
300 virtual void Process ();
301 std::string
GetProgTextAddrMacro ();
303 void GenerateBootProgramModuleTarget ();
307 class MingwIsoModuleHandler
: public MingwModuleHandler
310 MingwIsoModuleHandler ( const Module
& module
);
311 virtual void Process ();
313 void GenerateIsoModuleTarget ();
314 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
315 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
316 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
317 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
318 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
319 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
320 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
321 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
325 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
328 MingwLiveIsoModuleHandler ( const Module
& module
);
329 virtual void Process ();
331 void GenerateLiveIsoModuleTarget ();
332 void CreateDirectory ( const std::string
& directory
);
333 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
334 std::string
& livecdReactos
);
335 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
336 std::string
& livecdReactos
);
337 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
338 void OutputLoaderCommands ( std::string
& livecdDirectory
);
339 void OutputRegistryCommands ( std::string
& livecdDirectory
);
343 class MingwTestModuleHandler
: public MingwModuleHandler
346 MingwTestModuleHandler ( const Module
& module
);
347 virtual void Process ();
349 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
351 void GenerateTestModuleTarget ();
354 class MingwAliasModuleHandler
: public MingwModuleHandler
357 MingwAliasModuleHandler ( const Module
& module
);
358 virtual void Process ();
361 class MingwCabinetModuleHandler
: public MingwModuleHandler
364 MingwCabinetModuleHandler ( const Module
& module
);
365 virtual void Process ();
368 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
371 MingwElfExecutableModuleHandler ( const Module
& module
);
372 virtual void Process ();
375 #endif /* MINGW_MODULEHANDLER_H */