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 GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
152 const FileLocation
*file
) const;
153 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
154 const FileLocation
*file
) const;
155 void GetDefaultDependencies ( string_list
& dependencies
) const;
156 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
157 bool IsWineModule () const;
158 const FileLocation
* GetDefinitionFilename () const;
159 void GenerateBuildNonSymbolStrippedCode ();
160 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
161 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
162 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
163 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
164 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
165 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
166 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
167 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
168 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
169 std::string
GetModuleCleanTarget ( const Module
& module
) const;
170 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
172 const Module
& module
;
173 string_list clean_files
;
174 std::string cflagsMacro
;
175 std::string nasmflagsMacro
;
176 std::string windresflagsMacro
;
177 std::string widlflagsMacro
;
178 std::string linkerflagsMacro
;
179 std::string sourcesMacro
;
180 std::string objectsMacro
;
181 std::string libsMacro
;
182 std::string linkDepsMacro
;
186 class MingwBuildToolModuleHandler
: public MingwModuleHandler
189 MingwBuildToolModuleHandler ( const Module
& module
);
190 virtual void Process ();
192 void GenerateBuildToolModuleTarget ();
196 class MingwKernelModuleHandler
: public MingwModuleHandler
199 MingwKernelModuleHandler ( const Module
& module
);
200 virtual void Process ();
202 void GenerateKernelModuleTarget ();
206 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
209 MingwKernelModeDLLModuleHandler ( const Module
& module
);
210 virtual void Process ();
211 void AddImplicitLibraries ( Module
& module
);
213 void GenerateKernelModeDLLModuleTarget ();
217 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
220 MingwNativeDLLModuleHandler ( const Module
& module
);
221 virtual void Process ();
222 void AddImplicitLibraries ( Module
& module
);
224 void GenerateNativeDLLModuleTarget ();
228 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
231 MingwNativeCUIModuleHandler ( const Module
& module
);
232 virtual void Process ();
233 void AddImplicitLibraries ( Module
& module
);
235 void GenerateNativeCUIModuleTarget ();
239 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
242 MingwWin32DLLModuleHandler ( const Module
& module
);
243 virtual void Process ();
244 void AddImplicitLibraries ( Module
& module
);
246 void GenerateWin32DLLModuleTarget ();
250 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
253 MingwWin32OCXModuleHandler ( const Module
& module
);
254 virtual void Process ();
255 void AddImplicitLibraries ( Module
& module
);
257 void GenerateWin32OCXModuleTarget ();
261 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
264 MingwWin32CUIModuleHandler ( const Module
& module
);
265 virtual void Process ();
266 void AddImplicitLibraries ( Module
& module
);
268 void GenerateWin32CUIModuleTarget ();
272 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
275 MingwWin32GUIModuleHandler ( const Module
& module
);
276 virtual void Process ();
277 void AddImplicitLibraries ( Module
& module
);
279 void GenerateWin32GUIModuleTarget ();
283 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
286 MingwBootLoaderModuleHandler ( const Module
& module
);
287 virtual void Process ();
289 void GenerateBootLoaderModuleTarget ();
293 class MingwBootProgramModuleHandler
: public MingwModuleHandler
296 MingwBootProgramModuleHandler ( const Module
& module
);
297 virtual void Process ();
298 std::string
GetProgTextAddrMacro ();
300 void GenerateBootProgramModuleTarget ();
304 class MingwIsoModuleHandler
: public MingwModuleHandler
307 MingwIsoModuleHandler ( const Module
& module
);
308 virtual void Process ();
310 void GenerateIsoModuleTarget ();
311 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
312 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
313 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
314 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
315 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
316 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
317 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
318 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
322 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
325 MingwLiveIsoModuleHandler ( const Module
& module
);
326 virtual void Process ();
328 void GenerateLiveIsoModuleTarget ();
329 void CreateDirectory ( const std::string
& directory
);
330 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
331 std::string
& livecdReactos
);
332 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
333 std::string
& livecdReactos
);
334 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
335 void OutputLoaderCommands ( std::string
& livecdDirectory
);
336 void OutputRegistryCommands ( std::string
& livecdDirectory
);
340 class MingwTestModuleHandler
: public MingwModuleHandler
343 MingwTestModuleHandler ( const Module
& module
);
344 virtual void Process ();
346 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
348 void GenerateTestModuleTarget ();
351 class MingwAliasModuleHandler
: public MingwModuleHandler
354 MingwAliasModuleHandler ( const Module
& module
);
355 virtual void Process ();
358 class MingwCabinetModuleHandler
: public MingwModuleHandler
361 MingwCabinetModuleHandler ( const Module
& module
);
362 virtual void Process ();
365 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
368 MingwElfExecutableModuleHandler ( const Module
& module
);
369 virtual void Process ();
372 #endif /* MINGW_MODULEHANDLER_H */