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 std::string
GetDebugFormat () const;
106 void GenerateCleanObjectsAsYouGoCode () const;
107 void GenerateRunRsymCode () const;
108 void GenerateRunStripCode () const;
109 void GenerateLinkerCommand ( const std::string
& dependencies
,
110 const std::string
& linkerParameters
,
111 const std::string
& pefixupParameters
);
112 void GeneratePhonyTarget() const;
113 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
114 void GenerateRules ();
115 void GenerateImportLibraryTargetIfNeeded ();
116 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
117 std::string
GetLinkingDependencies () const;
118 static MingwBackend
* backend
;
119 static FILE* fMakefile
;
122 std::string
ConcatenatePaths ( const std::string
& path1
,
123 const std::string
& path2
) const;
124 std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
) const;
125 std::string
GenerateLinkerParametersFromVector ( const std::vector
<LinkerFlag
*>& linkerFlags
) const;
126 std::string
GenerateImportLibraryDependenciesFromVector ( const std::vector
<Library
*>& libraries
);
127 std::string
GenerateLinkerParameters () const;
128 void GenerateMacro ( const char* assignmentOperation
,
129 const std::string
& macro
,
130 const IfableData
& data
,
131 std::set
<const Define
*>* used_defs
,
132 bool generatingCompilerMacro
);
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
* GetDlldataFilename () const;
141 void GenerateGccCommand ( const FileLocation
* sourceFile
,
143 const std::string
& extraDependencies
);
144 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
145 const std::string
& extraDependencies
);
146 void GenerateObjectFileTargets ( const IfableData
& data
);
147 void GenerateObjectFileTargets ();
148 const FileLocation
* GenerateArchiveTarget ();
149 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
150 const FileLocation
*file
) const;
151 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
152 const FileLocation
*file
) const;
153 void GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
154 const FileLocation
*file
) const;
155 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
156 const FileLocation
*file
) const;
157 void GetDefaultDependencies ( string_list
& dependencies
) const;
158 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
159 SpecFileType
IsSpecDefinitionFile () const;
160 const FileLocation
* GetDefinitionFilename () const;
161 void GenerateBuildNonSymbolStrippedCode ();
162 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
163 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
164 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
165 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
166 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
167 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
168 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
169 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
170 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
171 std::string
GetModuleCleanTarget ( const Module
& module
) const;
172 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
174 const Module
& module
;
175 string_list clean_files
;
176 std::string commonflagsMacro
;
177 std::string cflagsMacro
;
178 std::string cxxflagsMacro
;
179 std::string nasmflagsMacro
;
180 std::string windresflagsMacro
;
181 std::string widlflagsMacro
;
182 std::string linkerflagsMacro
;
183 std::string sourcesMacro
;
184 std::string objectsMacro
;
185 std::string libsMacro
;
186 std::string linkDepsMacro
;
190 class MingwBuildToolModuleHandler
: public MingwModuleHandler
193 MingwBuildToolModuleHandler ( const Module
& module
);
194 virtual void Process ();
196 void GenerateBuildToolModuleTarget ();
200 class MingwKernelModuleHandler
: public MingwModuleHandler
203 MingwKernelModuleHandler ( const Module
& module
);
204 virtual void Process ();
206 void GenerateKernelModuleTarget ();
210 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
213 MingwKernelModeDLLModuleHandler ( const Module
& module
);
214 virtual void Process ();
215 void AddImplicitLibraries ( Module
& module
);
217 void GenerateKernelModeDLLModuleTarget ();
221 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
224 MingwNativeDLLModuleHandler ( const Module
& module
);
225 virtual void Process ();
226 void AddImplicitLibraries ( Module
& module
);
228 void GenerateNativeDLLModuleTarget ();
232 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
235 MingwNativeCUIModuleHandler ( const Module
& module
);
236 virtual void Process ();
237 void AddImplicitLibraries ( Module
& module
);
239 void GenerateNativeCUIModuleTarget ();
243 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
246 MingwWin32DLLModuleHandler ( const Module
& module
);
247 virtual void Process ();
248 void AddImplicitLibraries ( Module
& module
);
250 void GenerateWin32DLLModuleTarget ();
254 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
257 MingwWin32OCXModuleHandler ( const Module
& module
);
258 virtual void Process ();
259 void AddImplicitLibraries ( Module
& module
);
261 void GenerateWin32OCXModuleTarget ();
265 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
268 MingwWin32CUIModuleHandler ( const Module
& module
);
269 virtual void Process ();
270 void AddImplicitLibraries ( Module
& module
);
272 void GenerateWin32CUIModuleTarget ();
276 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
279 MingwWin32GUIModuleHandler ( const Module
& module
);
280 virtual void Process ();
281 void AddImplicitLibraries ( Module
& module
);
283 void GenerateWin32GUIModuleTarget ();
287 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
290 MingwBootLoaderModuleHandler ( const Module
& module
);
291 virtual void Process ();
293 void GenerateBootLoaderModuleTarget ();
297 class MingwBootProgramModuleHandler
: public MingwModuleHandler
300 MingwBootProgramModuleHandler ( const Module
& module
);
301 virtual void Process ();
302 std::string
GetProgTextAddrMacro ();
304 void GenerateBootProgramModuleTarget ();
308 class MingwIsoModuleHandler
: public MingwModuleHandler
311 MingwIsoModuleHandler ( const Module
& module
);
312 virtual void Process ();
314 void GenerateIsoModuleTarget ();
315 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
316 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
317 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
318 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
319 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
320 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
321 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
);
322 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
);
326 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
329 MingwLiveIsoModuleHandler ( const Module
& module
);
330 virtual void Process ();
332 void GenerateLiveIsoModuleTarget ();
333 void CreateDirectory ( const std::string
& directory
);
334 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
335 std::string
& livecdReactos
);
336 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
337 std::string
& livecdReactos
);
338 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
);
339 void OutputLoaderCommands ( std::string
& livecdDirectory
);
340 void OutputRegistryCommands ( std::string
& livecdDirectory
);
344 class MingwTestModuleHandler
: public MingwModuleHandler
347 MingwTestModuleHandler ( const Module
& module
);
348 virtual void Process ();
350 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
352 void GenerateTestModuleTarget ();
355 class MingwAliasModuleHandler
: public MingwModuleHandler
358 MingwAliasModuleHandler ( const Module
& module
);
359 virtual void Process ();
362 class MingwCabinetModuleHandler
: public MingwModuleHandler
365 MingwCabinetModuleHandler ( const Module
& module
);
366 virtual void Process ();
369 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
372 MingwElfExecutableModuleHandler ( const Module
& module
);
373 virtual void Process ();
376 #endif /* MINGW_MODULEHANDLER_H */