d2715c77958b8765911bc9714d59b3970e40c20c
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.h
1 #ifndef MINGW_MODULEHANDLER_H
2 #define MINGW_MODULEHANDLER_H
3
4 #include "../backend.h"
5
6 class MingwModuleHandler
7 {
8 public:
9 static std::map<ModuleType,MingwModuleHandler*>* handler_map;
10 static int ref;
11
12 MingwModuleHandler ( ModuleType moduletype );
13 virtual ~MingwModuleHandler();
14
15 static void SetMakefile ( FILE* f );
16 static MingwModuleHandler* LookupHandler ( const std::string& location,
17 ModuleType moduletype_ );
18 virtual void Process ( const Module& module ) = 0;
19
20 protected:
21 std::string GetWorkingDirectory () const;
22 std::string GetExtension ( const std::string& filename ) const;
23 std::string ReplaceExtension ( const std::string& filename,
24 const std::string& newExtension ) const;
25 std::string GetModuleArchiveFilename ( const Module& module ) const;
26 std::string GetImportLibraryDependencies ( const Module& module ) const;
27 std::string GetModuleDependencies ( const Module& module ) const;
28 std::string GetAllDependencies ( const Module& module ) const;
29 std::string GetSourceFilenames ( const Module& module ) const;
30
31 std::string GetObjectFilename ( const std::string& sourceFilename ) const;
32 std::string GetObjectFilenames ( const Module& module ) const;
33 void GenerateMacrosAndTargetsHost ( const Module& module ) const;
34 void GenerateMacrosAndTargetsTarget ( const Module& module ) const;
35 std::string GetInvocationDependencies ( const Module& module ) const;
36 std::string GetInvocationParameters ( const Invoke& invoke ) const;
37 void GenerateInvocations ( const Module& module ) const;
38 void GeneratePreconditionDependencies ( const Module& module ) const;
39 std::string GenerateMacros ( const Module& module,
40 const std::string& cflags_macro,
41 const std::string& objs_macro ) const;
42 static FILE* fMakefile;
43 private:
44 std::string ConcatenatePaths ( const std::string& path1,
45 const std::string& path2 ) const;
46 std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
47 std::string GenerateGccDefineParameters ( const Module& module ) const;
48 std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
49 void GenerateMacros ( const Module& module,
50 const char* op,
51 const std::vector<File*>& files,
52 const std::vector<Include*>* includes,
53 const std::vector<Define*>& defines,
54 const std::string& cflags_macro,
55 const std::string& nasmflags_macro,
56 const std::string& objs_macro) const;
57 void GenerateMacros ( const Module& module,
58 const std::string& cflags_macro,
59 const std::string& nasmflags_macro,
60 const std::string& objs_macro) const;
61 void GenerateGccModuleIncludeVariable ( const Module& module ) const;
62 std::string GenerateGccIncludeParameters ( const Module& module ) const;
63 std::string GenerateGccParameters ( const Module& module ) const;
64 std::string GenerateNasmParameters ( const Module& module ) const;
65 std::string GenerateGccCommand ( const Module& module,
66 const std::string& sourceFilename,
67 const std::string& cc,
68 const std::string& cflagsMacro ) const;
69 std::string GenerateGccAssemblerCommand ( const Module& module,
70 const std::string& sourceFilename,
71 const std::string& cc,
72 const std::string& cflagsMacro ) const;
73 std::string GenerateNasmCommand ( const Module& module,
74 const std::string& sourceFilename,
75 const std::string& nasmflagsMacro ) const;
76 std::string GenerateCommand ( const Module& module,
77 const std::string& sourceFilename,
78 const std::string& cc,
79 const std::string& cflagsMacro,
80 const std::string& nasmflagsMacro ) const;
81 void GenerateObjectFileTargets ( const Module& module,
82 const std::vector<File*>& files,
83 const std::string& cc,
84 const std::string& cflagsMacro,
85 const std::string& nasmflagsMacro ) const;
86 void GenerateObjectFileTargets ( const Module& module,
87 const std::string& cc,
88 const std::string& cflagsMacro,
89 const std::string& nasmflagsMacro ) const;
90 void GenerateArchiveTarget ( const Module& module,
91 const std::string& ar,
92 const std::string& objs_macro ) const;
93 void GenerateMacrosAndTargets ( const Module& module,
94 const std::string& cc,
95 const std::string& ar ) const;
96 std::string GetPreconditionDependenciesName ( const Module& module ) const;
97 };
98
99
100 class MingwBuildToolModuleHandler : public MingwModuleHandler
101 {
102 public:
103 MingwBuildToolModuleHandler ();
104 virtual void Process ( const Module& module );
105 private:
106 void GenerateBuildToolModuleTarget ( const Module& module );
107 };
108
109
110 class MingwKernelModuleHandler : public MingwModuleHandler
111 {
112 public:
113 MingwKernelModuleHandler ();
114 virtual void Process ( const Module& module );
115 private:
116 void GenerateKernelModuleTarget ( const Module& module );
117 };
118
119
120 class MingwStaticLibraryModuleHandler : public MingwModuleHandler
121 {
122 public:
123 MingwStaticLibraryModuleHandler ();
124 virtual void Process ( const Module& module );
125 private:
126 void GenerateStaticLibraryModuleTarget ( const Module& module );
127 };
128
129
130 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
131 {
132 public:
133 MingwKernelModeDLLModuleHandler ();
134 virtual void Process ( const Module& module );
135 private:
136 void GenerateKernelModeDLLModuleTarget ( const Module& module );
137 };
138
139
140 class MingwNativeDLLModuleHandler : public MingwModuleHandler
141 {
142 public:
143 MingwNativeDLLModuleHandler ();
144 virtual void Process ( const Module& module );
145 private:
146 void GenerateNativeDLLModuleTarget ( const Module& module );
147 };
148
149 #endif /* MINGW_MODULEHANDLER_H */