* Bring back rbuild build to be used until bug 6372 is fixed.
[reactos.git] / 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 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.
17 */
18
19 #pragma once
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 bool compilerNeedsHelper;
49 std::string compilerPrefix;
50 std::string compilerCommand;
51 std::string nasmCommand;
52 std::string binutilsPrefix;
53 bool binutilsNeedsHelper;
54 std::string binutilsCommand;
55 bool usePipe, manualBinutilsSetting;
56 Directory* intermediateDirectory;
57 Directory* outputDirectory;
58 Directory* installDirectory;
59
60 std::string GetFullName ( const FileLocation& file ) const;
61 std::string GetFullPath ( const FileLocation& file ) const;
62
63 private:
64 void CreateMakefile ();
65 void CloseMakefile () const;
66 void GenerateHeader () const;
67 void GenerateGlobalProperties ( const char* assignmentOperation,
68 const IfableData& data ) const;
69 std::string GenerateProjectLDFLAGS () const;
70 void GenerateDirectories ();
71 void GenerateGlobalVariables () const;
72 bool IncludeInAllTarget ( const Module& module ) const;
73 void GenerateAllTarget ( const std::vector<MingwModuleHandler*>& handlers ) const;
74 void GenerateRegTestsRunTarget () const;
75 void GenerateXmlBuildFilesMacro() const;
76 void GenerateTestSupportCode ();
77 void GenerateCompilationUnitSupportCode ();
78 void GenerateSysSetup ();
79 std::string GetProxyMakefileTree () const;
80 void GenerateProxyMakefiles ();
81 void CheckAutomaticDependencies ();
82 bool TryToDetectThisCompiler ( const std::string& compiler );
83 void DetectCompiler ();
84 std::string GetCompilerVersion ( const std::string& compilerCommand );
85 bool IsSupportedCompilerVersion ( const std::string& compilerVersion );
86 bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
87 bool TryToDetectThisBinutils ( const std::string& binutils );
88 std::string GetBinutilsVersion ( const std::string& binutilsCommand );
89 std::string GetBinutilsVersionDate ( const std::string& binutilsCommand );
90 bool IsSupportedBinutilsVersion ( const std::string& binutilsVersion );
91 std::string GetVersionString ( const std::string& versionCommand );
92 std::string GetNetwideAssemblerVersion ( const std::string& nasmCommand );
93 void DetectBinutils ();
94 void DetectNetwideAssembler ();
95 void DetectPipeSupport ();
96 void DetectPCHSupport ();
97 bool CanEnablePreCompiledHeaderSupportForModule ( const Module& module );
98 void ProcessModules ();
99 void CheckAutomaticDependenciesForModuleOnly ();
100 void ProcessNormal ();
101 std::string GetNonModuleInstallDirectories ( const std::string& installDirectory );
102 std::string GetInstallDirectories ( const std::string& installDirectory );
103 void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const;
104 void GetInstallFiles ( std::vector<std::string>& out ) const;
105 void GetNonModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
106 void GetModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
107 void GetInstallTargetFiles ( std::vector<FileLocation>& out ) const;
108 void OutputInstallTarget ( const FileLocation& source, const FileLocation& target );
109 void OutputNonModuleInstallTargets ();
110 void OutputModuleInstallTargets ();
111 std::string GetRegistrySourceFiles ();
112 std::string GetRegistryTargetFiles ();
113 void OutputRegistryInstallTarget ();
114 void GenerateInstallTarget ();
115 void GetModuleTestTargets ( std::vector<std::string>& out ) const;
116 void GenerateTestTarget ();
117 void GenerateDirectoryTargets ();
118 FILE* fMakefile;
119 bool use_pch;
120 bool DetectMicrosoftCompiler ( std::string& version, std::string& path );
121 bool DetectMicrosoftLinker ( std::string& version, std::string& path );
122 };
123
124
125 class ProxyMakefile
126 {
127 public:
128 ProxyMakefile ( const Project& project );
129 ~ProxyMakefile ();
130 void GenerateProxyMakefiles ( bool verbose,
131 std::string outputTree );
132 static bool GenerateProxyMakefile ( const Module& module );
133
134 private:
135 std::string GeneratePathToParentDirectory ( int numberOfParentDirectories );
136 std::string GetPathToTopDirectory ( Module& module );
137 void GenerateProxyMakefileForModule ( Module& module,
138 bool verbose,
139 std::string outputTree );
140 const Project& project;
141 };
142
143 struct ModuleHandlerInformations
144 {
145 HostType DefaultHost;
146 const char* cflags;
147 const char* nasmflags;
148 const char* linkerflags;
149 };
150
151 extern const struct ModuleHandlerInformations ModuleHandlerInformations[];