Remove GetExtraDependencies() function.
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.h
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
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.
8 *
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.
13 *
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.
17 */
18 #ifndef MINGW_MODULEHANDLER_H
19 #define MINGW_MODULEHANDLER_H
20
21 #include "../backend.h"
22 #include "mingw.h"
23
24 class MingwBackend;
25 class Rule;
26
27 extern std::string
28 GetTargetMacro ( const Module&, bool with_dollar = true );
29
30 extern std::string
31 PrefixFilename (
32 const std::string& filename,
33 const std::string& prefix );
34
35 class MingwModuleHandler
36 {
37 public:
38 MingwModuleHandler ( const Module& module_ );
39 virtual ~MingwModuleHandler();
40
41 static void SetBackend ( MingwBackend* backend_ );
42 static void SetMakefile ( FILE* f );
43 void EnablePreCompiledHeaderSupport ();
44
45 static const FileLocation* PassThruCacheDirectory (const FileLocation* fileLocation );
46
47 static const FileLocation* GetTargetFilename (
48 const Module& module,
49 string_list* pclean_files );
50
51 static const FileLocation* GetImportLibraryFilename (
52 const Module& module,
53 string_list* pclean_files );
54
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 );
57
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();
65
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; }
76
77 void OutputCopyCommand ( const FileLocation& source,
78 const FileLocation& destination );
79 protected:
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;
92
93 std::string GetObjectFilenames ();
94
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;
115 bool use_pch;
116 private:
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,
140 const Rule *rule,
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 GetWidlObjectDependencies ( std::vector<FileLocation>& dependencies,
152 const FileLocation *file ) const;
153 void GetDefaultDependencies ( string_list& dependencies ) const;
154 void GetInvocationDependencies ( const Module& module, string_list& dependencies );
155 bool IsWineModule () const;
156 const FileLocation* GetDefinitionFilename () const;
157 void GenerateBuildNonSymbolStrippedCode ();
158 void CleanupCompilationUnitVector ( std::vector<CompilationUnit*>& compilationUnits );
159 void GetRpcHeaderDependencies ( std::vector<FileLocation>& dependencies ) const;
160 void GetMcHeaderDependencies ( std::vector<FileLocation>& dependencies ) const;
161 static std::string GetPropertyValue ( const Module& module, const std::string& name );
162 const FileLocation* GetRpcServerHeaderFilename ( const FileLocation *base ) const;
163 const FileLocation* GetRpcClientHeaderFilename ( const FileLocation *base ) const;
164 const FileLocation* GetRpcProxyHeaderFilename ( const FileLocation *base ) const;
165 const FileLocation* GetIdlHeaderFilename ( const FileLocation *base ) const;
166 const FileLocation* GetMcHeaderFilename ( const FileLocation *base ) const;
167 std::string GetModuleCleanTarget ( const Module& module ) const;
168 void GetReferencedObjectLibraryModuleCleanTargets ( std::vector<std::string>& moduleNames ) const;
169 public:
170 const Module& module;
171 string_list clean_files;
172 std::string cflagsMacro;
173 std::string nasmflagsMacro;
174 std::string windresflagsMacro;
175 std::string widlflagsMacro;
176 std::string linkerflagsMacro;
177 std::string sourcesMacro;
178 std::string objectsMacro;
179 std::string libsMacro;
180 std::string linkDepsMacro;
181 };
182
183
184 class MingwBuildToolModuleHandler : public MingwModuleHandler
185 {
186 public:
187 MingwBuildToolModuleHandler ( const Module& module );
188 virtual void Process ();
189 private:
190 void GenerateBuildToolModuleTarget ();
191 };
192
193
194 class MingwKernelModuleHandler : public MingwModuleHandler
195 {
196 public:
197 MingwKernelModuleHandler ( const Module& module );
198 virtual void Process ();
199 private:
200 void GenerateKernelModuleTarget ();
201 };
202
203
204 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
205 {
206 public:
207 MingwKernelModeDLLModuleHandler ( const Module& module );
208 virtual void Process ();
209 void AddImplicitLibraries ( Module& module );
210 private:
211 void GenerateKernelModeDLLModuleTarget ();
212 };
213
214
215 class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
216 {
217 public:
218 MingwKernelModeDriverModuleHandler ( const Module& module );
219 virtual void Process ();
220 void AddImplicitLibraries ( Module& module );
221 private:
222 void GenerateKernelModeDriverModuleTarget ();
223 };
224
225
226 class MingwNativeDLLModuleHandler : public MingwModuleHandler
227 {
228 public:
229 MingwNativeDLLModuleHandler ( const Module& module );
230 virtual void Process ();
231 void AddImplicitLibraries ( Module& module );
232 private:
233 void GenerateNativeDLLModuleTarget ();
234 };
235
236
237 class MingwNativeCUIModuleHandler : public MingwModuleHandler
238 {
239 public:
240 MingwNativeCUIModuleHandler ( const Module& module );
241 virtual void Process ();
242 void AddImplicitLibraries ( Module& module );
243 private:
244 void GenerateNativeCUIModuleTarget ();
245 };
246
247
248 class MingwWin32DLLModuleHandler : public MingwModuleHandler
249 {
250 public:
251 MingwWin32DLLModuleHandler ( const Module& module );
252 virtual void Process ();
253 void AddImplicitLibraries ( Module& module );
254 private:
255 void GenerateWin32DLLModuleTarget ();
256 };
257
258
259 class MingwWin32OCXModuleHandler : public MingwModuleHandler
260 {
261 public:
262 MingwWin32OCXModuleHandler ( const Module& module );
263 virtual void Process ();
264 void AddImplicitLibraries ( Module& module );
265 private:
266 void GenerateWin32OCXModuleTarget ();
267 };
268
269
270 class MingwWin32CUIModuleHandler : public MingwModuleHandler
271 {
272 public:
273 MingwWin32CUIModuleHandler ( const Module& module );
274 virtual void Process ();
275 void AddImplicitLibraries ( Module& module );
276 private:
277 void GenerateWin32CUIModuleTarget ();
278 };
279
280
281 class MingwWin32GUIModuleHandler : public MingwModuleHandler
282 {
283 public:
284 MingwWin32GUIModuleHandler ( const Module& module );
285 virtual void Process ();
286 void AddImplicitLibraries ( Module& module );
287 private:
288 void GenerateWin32GUIModuleTarget ();
289 };
290
291
292 class MingwBootLoaderModuleHandler : public MingwModuleHandler
293 {
294 public:
295 MingwBootLoaderModuleHandler ( const Module& module );
296 virtual void Process ();
297 private:
298 void GenerateBootLoaderModuleTarget ();
299 };
300
301
302 class MingwBootProgramModuleHandler : public MingwModuleHandler
303 {
304 public:
305 MingwBootProgramModuleHandler ( const Module& module );
306 virtual void Process ();
307 std::string GetProgTextAddrMacro ();
308 private:
309 void GenerateBootProgramModuleTarget ();
310 };
311
312
313 class MingwIsoModuleHandler : public MingwModuleHandler
314 {
315 public:
316 MingwIsoModuleHandler ( const Module& module );
317 virtual void Process ();
318 private:
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 );
328 };
329
330
331 class MingwLiveIsoModuleHandler : public MingwModuleHandler
332 {
333 public:
334 MingwLiveIsoModuleHandler ( const Module& module );
335 virtual void Process ();
336 private:
337 void GenerateLiveIsoModuleTarget ();
338 void CreateDirectory ( const std::string& directory );
339 void OutputModuleCopyCommands ( std::string& livecdDirectory,
340 std::string& livecdReactos );
341 void OutputNonModuleCopyCommands ( std::string& livecdDirectory,
342 std::string& livecdReactos );
343 void OutputProfilesDirectoryCommands ( std::string& livecdDirectory );
344 void OutputLoaderCommands ( std::string& livecdDirectory );
345 void OutputRegistryCommands ( std::string& livecdDirectory );
346 };
347
348
349 class MingwTestModuleHandler : public MingwModuleHandler
350 {
351 public:
352 MingwTestModuleHandler ( const Module& module );
353 virtual void Process ();
354 protected:
355 virtual void GetModuleSpecificCompilationUnits ( std::vector<CompilationUnit*>& compilationUnits );
356 private:
357 void GenerateTestModuleTarget ();
358 };
359
360 class MingwAliasModuleHandler : public MingwModuleHandler
361 {
362 public:
363 MingwAliasModuleHandler ( const Module& module );
364 virtual void Process ();
365 };
366
367 class MingwCabinetModuleHandler : public MingwModuleHandler
368 {
369 public:
370 MingwCabinetModuleHandler ( const Module& module );
371 virtual void Process ();
372 };
373
374 class MingwElfExecutableModuleHandler : public MingwModuleHandler
375 {
376 public:
377 MingwElfExecutableModuleHandler ( const Module& module );
378 virtual void Process ();
379 };
380
381 #endif /* MINGW_MODULEHANDLER_H */