Merge from amd64-branch:
[reactos.git] / reactos / tools / rbuild / backend / mingw / mingw.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_H
19 #define MINGW_H
20
21 #include "../backend.h"
22
23 #ifdef WIN32
24 #define NUL "NUL"
25 #else
26 #define NUL "/dev/null"
27 #endif
28
29 class Directory;
30 class MingwModuleHandler;
31
32 extern std::string
33 v2s ( const Backend* backend, const std::vector<FileLocation>& files, int wrap_at );
34 extern std::string
35 v2s ( const string_list& v, int wrap_at );
36
37
38 class MingwBackend : public Backend
39 {
40 public:
41 MingwBackend ( Project& project,
42 Configuration& configuration );
43 ~MingwBackend ();
44 virtual void Process ();
45 std::string AddDirectoryTarget ( const std::string& directory,
46 Directory* directoryTree );
47 const Module& GetAliasedModuleOrModule ( const Module& module ) const;
48 std::string compilerPrefix;
49 std::string compilerCommand;
50 std::string nasmCommand;
51 std::string binutilsPrefix;
52 std::string binutilsCommand;
53 bool usePipe, manualBinutilsSetting;
54 Directory* intermediateDirectory;
55 Directory* outputDirectory;
56 Directory* installDirectory;
57
58 std::string GetFullName ( const FileLocation& file ) const;
59 std::string GetFullPath ( const FileLocation& file ) const;
60
61 private:
62 void CreateMakefile ();
63 void CloseMakefile () const;
64 void GenerateHeader () const;
65 void GenerateGlobalProperties ( const char* assignmentOperation,
66 const IfableData& data ) const;
67 std::string GenerateProjectLFLAGS () const;
68 void GenerateDirectories ();
69 void GenerateGlobalVariables () const;
70 bool IncludeInAllTarget ( const Module& module ) const;
71 void GenerateAllTarget ( const std::vector<MingwModuleHandler*>& handlers ) const;
72 void GenerateRegTestsRunTarget () const;
73 void GenerateXmlBuildFilesMacro() const;
74 void GenerateTestSupportCode ();
75 void GenerateCompilationUnitSupportCode ();
76 void GenerateSysSetup ();
77 std::string GetProxyMakefileTree () const;
78 void GenerateProxyMakefiles ();
79 void CheckAutomaticDependencies ();
80 bool TryToDetectThisCompiler ( const std::string& compiler );
81 void DetectCompiler ();
82 std::string GetCompilerVersion ( const std::string& compilerCommand );
83 bool IsSupportedCompilerVersion ( const std::string& compilerVersion );
84 bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
85 bool TryToDetectThisBinutils ( const std::string& binutils );
86 std::string GetBinutilsVersion ( const std::string& binutilsCommand );
87 std::string GetBinutilsVersionDate ( const std::string& binutilsCommand );
88 bool IsSupportedBinutilsVersion ( const std::string& binutilsVersion );
89 std::string GetVersionString ( const std::string& versionCommand );
90 std::string GetNetwideAssemblerVersion ( const std::string& nasmCommand );
91 void DetectBinutils ();
92 void DetectNetwideAssembler ();
93 void DetectPipeSupport ();
94 void DetectPCHSupport ();
95 bool CanEnablePreCompiledHeaderSupportForModule ( const Module& module );
96 void ProcessModules ();
97 void CheckAutomaticDependenciesForModuleOnly ();
98 void ProcessNormal ();
99 std::string GetNonModuleInstallDirectories ( const std::string& installDirectory );
100 std::string GetInstallDirectories ( const std::string& installDirectory );
101 void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const;
102 void GetInstallFiles ( std::vector<std::string>& out ) const;
103 void GetNonModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
104 void GetModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
105 void GetInstallTargetFiles ( std::vector<FileLocation>& out ) const;
106 void OutputInstallTarget ( const FileLocation& source, const FileLocation& target );
107 void OutputNonModuleInstallTargets ();
108 void OutputModuleInstallTargets ();
109 std::string GetRegistrySourceFiles ();
110 std::string GetRegistryTargetFiles ();
111 void OutputRegistryInstallTarget ();
112 void GenerateInstallTarget ();
113 void GetModuleTestTargets ( std::vector<std::string>& out ) const;
114 void GenerateTestTarget ();
115 void GenerateDirectoryTargets ();
116 FILE* fMakefile;
117 bool use_pch;
118 };
119
120
121 class ProxyMakefile
122 {
123 public:
124 ProxyMakefile ( const Project& project );
125 ~ProxyMakefile ();
126 void GenerateProxyMakefiles ( bool verbose,
127 std::string outputTree );
128 static bool GenerateProxyMakefile ( const Module& module );
129
130 private:
131 std::string GeneratePathToParentDirectory ( int numberOfParentDirectories );
132 std::string GetPathToTopDirectory ( Module& module );
133 void GenerateProxyMakefileForModule ( Module& module,
134 bool verbose,
135 std::string outputTree );
136 const Project& project;
137 };
138
139 struct ModuleHandlerInformations
140 {
141 HostType DefaultHost;
142 const char* cflags;
143 const char* nasmflags;
144 const char* linkerflags;
145 };
146
147 extern const struct ModuleHandlerInformations ModuleHandlerInformations[];
148
149 #endif /* MINGW_H */