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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
,
56 static std::string
GenerateGccDefineParametersFromVector ( const std::vector
<Define
*>& defines
, std::set
<std::string
> &used_defs
);
57 static std::string
GenerateDefineParametersFromVector ( const std::vector
<Define
*>& defines
, CompilerType compiler
);
58 static std::string
GenerateCompilerParametersFromVector ( const std::vector
<CompilerFlag
*>& compilerFlags
, const CompilerType type
);
59 static std::string
GenerateIncludeParametersFromVector ( const std::vector
<Include
*>& includes
, CompilerType compiler
);
61 static void GenerateParameters ( const char* prefix
,
62 const char* assignmentOperation
,
63 const IfableData
& data
);
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
);
86 void OutputCopyCommandSingle ( const FileLocation
& source
,
87 const FileLocation
& destination
);
89 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
90 std::string
GetWorkingDirectory () const;
91 std::string
GetBasename ( const std::string
& filename
) const;
92 std::string
GetCompilationUnitDependencies ( const CompilationUnit
& compilationUnit
) const;
93 const FileLocation
* GetModuleArchiveFilename () const;
94 std::string
GetImportLibraryDependency ( const Module
& importedModule
, bool delayimp
);
95 void GetTargets ( const Module
& dependencyModule
,
96 string_list
& targets
);
97 void GetModuleDependencies ( string_list
& dependencies
);
98 std::string
GetAllDependencies () const;
99 const FileLocation
* GetObjectFilename ( const FileLocation
* sourceFile
,
100 const Module
& module
) const;
102 std::string
GetPreconditionDependenciesName () const;
103 static std::string
GetObjectsMacro ( const Module
& );
104 std::string
GetLinkingDependenciesMacro () const;
105 std::string
GetLibsMacro () const;
106 std::string
GetLinkerMacro () const;
107 static std::string
GetDebugFormat ();
108 void GenerateCleanObjectsAsYouGoCode () const;
109 void GenerateLinkerCommand () const;
110 void GenerateBuildMapCode ( const FileLocation
*mapTarget
= NULL
);
111 void GenerateRules ();
112 void GenerateImportLibraryTargetIfNeeded ();
113 void GetDefinitionDependencies ( std::vector
<FileLocation
>& dependencies
) const;
114 std::string
GetLinkingDependencies () const;
115 static MingwBackend
* backend
;
116 static FILE* fMakefile
;
119 std::string
ConcatenatePaths ( const std::string
& path1
,
120 const std::string
& path2
) 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 GenerateMacros ( const char* op
,
125 const IfableData
& data
,
126 const std::vector
<LinkerFlag
*>* linkerFlags
,
127 std::set
<const Define
*>& used_defs
);
128 void GenerateSourceMacros ( const IfableData
& data
);
129 void GenerateObjectMacros ( const IfableData
& data
);
130 const FileLocation
* GetPrecompiledHeaderFilename () const;
131 const FileLocation
* GetPrecompiledHeaderPath () const;
132 const FileLocation
* GetDlldataFilename () const;
133 void GenerateGccCommand ( const FileLocation
* sourceFile
,
135 const std::string
& extraDependencies
);
136 void GenerateCommands ( const CompilationUnit
& compilationUnit
,
137 const std::string
& extraDependencies
);
138 void GenerateObjectFileTargets ( const IfableData
& data
);
139 void GenerateObjectFileTargets ();
140 const FileLocation
* GenerateArchiveTarget ();
141 void GetMcObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
142 const FileLocation
*file
) const;
143 void GetSpecObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
144 const FileLocation
*file
) const;
145 void GetSpecImplibDependencies ( std::vector
<FileLocation
>& dependencies
,
146 const FileLocation
*file
) const;
147 void GetWidlObjectDependencies ( std::vector
<FileLocation
>& dependencies
,
148 const FileLocation
*file
) const;
149 void GetDefaultDependencies ( string_list
& dependencies
) const;
150 void GetInvocationDependencies ( const Module
& module
, string_list
& dependencies
);
151 SpecFileType
IsSpecDefinitionFile () const;
152 const FileLocation
* GetDefinitionFilename () const;
153 void GenerateBuildNonSymbolStrippedCode ();
154 void CleanupCompilationUnitVector ( std::vector
<CompilationUnit
*>& compilationUnits
);
155 void GetRpcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
156 void GetMcHeaderDependencies ( std::vector
<FileLocation
>& dependencies
) const;
157 static std::string
GetPropertyValue ( const Module
& module
, const std::string
& name
);
158 const FileLocation
* GetRpcServerHeaderFilename ( const FileLocation
*base
) const;
159 const FileLocation
* GetRpcClientHeaderFilename ( const FileLocation
*base
) const;
160 const FileLocation
* GetRpcProxyHeaderFilename ( const FileLocation
*base
) const;
161 const FileLocation
* GetIdlHeaderFilename ( const FileLocation
*base
) const;
162 const FileLocation
* GetMcHeaderFilename ( const FileLocation
*base
) const;
163 std::string
GetModuleCleanTarget ( const Module
& module
) const;
164 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector
<std::string
>& moduleNames
) const;
166 const Module
& module
;
167 string_list clean_files
;
168 std::string commonflagsMacro
;
169 std::string cflagsMacro
;
170 std::string cxxflagsMacro
;
171 std::string nasmflagsMacro
;
172 std::string windresflagsMacro
;
173 std::string widlflagsMacro
;
174 std::string linkerflagsMacro
;
175 std::string sourcesMacro
;
176 std::string objectsMacro
;
177 std::string libsMacro
;
178 std::string linkDepsMacro
;
182 class MingwBuildToolModuleHandler
: public MingwModuleHandler
185 MingwBuildToolModuleHandler ( const Module
& module
);
186 virtual void Process ();
188 void GenerateBuildToolModuleTarget ();
192 class MingwKernelModuleHandler
: public MingwModuleHandler
195 MingwKernelModuleHandler ( const Module
& module
);
196 virtual void Process ();
198 void GenerateKernelModuleTarget ();
202 class MingwKernelModeDLLModuleHandler
: public MingwModuleHandler
205 MingwKernelModeDLLModuleHandler ( const Module
& module
);
206 virtual void Process ();
207 void AddImplicitLibraries ( Module
& module
);
209 void GenerateKernelModeDLLModuleTarget ();
213 class MingwNativeDLLModuleHandler
: public MingwModuleHandler
216 MingwNativeDLLModuleHandler ( const Module
& module
);
217 virtual void Process ();
218 void AddImplicitLibraries ( Module
& module
);
220 void GenerateNativeDLLModuleTarget ();
224 class MingwNativeCUIModuleHandler
: public MingwModuleHandler
227 MingwNativeCUIModuleHandler ( const Module
& module
);
228 virtual void Process ();
229 void AddImplicitLibraries ( Module
& module
);
231 void GenerateNativeCUIModuleTarget ();
235 class MingwWin32DLLModuleHandler
: public MingwModuleHandler
238 MingwWin32DLLModuleHandler ( const Module
& module
);
239 virtual void Process ();
240 void AddImplicitLibraries ( Module
& module
);
242 void GenerateWin32DLLModuleTarget ();
246 class MingwWin32OCXModuleHandler
: public MingwModuleHandler
249 MingwWin32OCXModuleHandler ( const Module
& module
);
250 virtual void Process ();
251 void AddImplicitLibraries ( Module
& module
);
253 void GenerateWin32OCXModuleTarget ();
257 class MingwWin32CUIModuleHandler
: public MingwModuleHandler
260 MingwWin32CUIModuleHandler ( const Module
& module
);
261 virtual void Process ();
262 void AddImplicitLibraries ( Module
& module
);
264 void GenerateWin32CUIModuleTarget ();
268 class MingwWin32GUIModuleHandler
: public MingwModuleHandler
271 MingwWin32GUIModuleHandler ( const Module
& module
);
272 virtual void Process ();
273 void AddImplicitLibraries ( Module
& module
);
275 void GenerateWin32GUIModuleTarget ();
279 class MingwBootLoaderModuleHandler
: public MingwModuleHandler
282 MingwBootLoaderModuleHandler ( const Module
& module
);
283 virtual void Process ();
285 void GenerateBootLoaderModuleTarget ();
289 class MingwBootProgramModuleHandler
: public MingwModuleHandler
292 MingwBootProgramModuleHandler ( const Module
& module
);
293 virtual void Process ();
294 std::string
GetProgTextAddrMacro ();
296 void GenerateBootProgramModuleTarget ();
300 class MingwIsoModuleHandler
: public MingwModuleHandler
303 MingwIsoModuleHandler ( const Module
& module
);
304 virtual void Process ();
306 void GenerateIsoModuleTarget ();
307 void GetBootstrapCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
308 void GetNonModuleCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
309 void GetCdDirectories ( std::vector
<FileLocation
>& out
, const std::string
& bootcdDirectory
);
310 void GetBootstrapCdFiles ( std::vector
<FileLocation
>& out
) const;
311 void GetNonModuleCdFiles ( std::vector
<FileLocation
>& out
) const;
312 void GetCdFiles ( std::vector
<FileLocation
>& out
) const;
313 void OutputBootstrapfileCopyCommands ( const std::string
& bootcdDirectory
,
314 std::vector
<FileLocation
>& destinations
);
315 void OutputCdfileCopyCommands ( const std::string
& bootcdDirectory
,
316 std::vector
<FileLocation
>& destinations
);
320 class MingwLiveIsoModuleHandler
: public MingwModuleHandler
323 MingwLiveIsoModuleHandler ( const Module
& module
);
324 virtual void Process ();
326 void GenerateLiveIsoModuleTarget ();
327 void CreateDirectory ( const std::string
& directory
);
328 void OutputModuleCopyCommands ( std::string
& livecdDirectory
,
329 std::string
& livecdReactos
,
330 std::vector
<FileLocation
>& destinations
);
331 void OutputNonModuleCopyCommands ( std::string
& livecdDirectory
,
332 std::string
& livecdReactos
,
333 std::vector
<FileLocation
>& destinations
);
334 void OutputProfilesDirectoryCommands ( std::string
& livecdDirectory
,
335 std::vector
<FileLocation
>& destinations
);
336 void OutputLoaderCommands ( std::string
& livecdDirectory
,
337 std::vector
<FileLocation
>& destinations
);
338 void OutputMakeLinkCommand ( const std::string name
,
339 const std::string application
,
340 const std::string
&path
,
341 std::vector
<FileLocation
>& destinations
);
342 void OutputShortcutCommands ( std::string
& livecdDirectory
,
343 std::vector
<FileLocation
>& destinations
);
344 void OutputRegistryCommands ( std::string
& livecdDirectory
);
348 class MingwTestModuleHandler
: public MingwModuleHandler
351 MingwTestModuleHandler ( const Module
& module
);
352 virtual void Process ();
354 virtual void GetModuleSpecificCompilationUnits ( std::vector
<CompilationUnit
*>& compilationUnits
);
356 void GenerateTestModuleTarget ();
359 class MingwAliasModuleHandler
: public MingwModuleHandler
362 MingwAliasModuleHandler ( const Module
& module
);
363 virtual void Process ();
366 class MingwCabinetModuleHandler
: public MingwModuleHandler
369 MingwCabinetModuleHandler ( const Module
& module
);
370 virtual void Process ();
373 class MingwElfExecutableModuleHandler
: public MingwModuleHandler
376 MingwElfExecutableModuleHandler ( const Module
& module
);
377 virtual void Process ();