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"
26 #define NUL "/dev/null"
30 class MingwModuleHandler
;
33 v2s ( const Backend
* backend
, const std::vector
<FileLocation
>& files
, int wrap_at
);
35 v2s ( const string_list
& v
, int wrap_at
);
38 class MingwBackend
: public Backend
41 MingwBackend ( Project
& project
,
42 Configuration
& configuration
);
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
;
60 std::string
GetFullName ( const FileLocation
& file
) const;
61 std::string
GetFullPath ( const FileLocation
& file
) const;
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 ();
120 bool DetectMicrosoftCompiler ( std::string
& version
, std::string
& path
);
121 bool DetectMicrosoftLinker ( std::string
& version
, std::string
& path
);
128 ProxyMakefile ( const Project
& project
);
130 void GenerateProxyMakefiles ( bool verbose
,
131 std::string outputTree
);
132 static bool GenerateProxyMakefile ( const Module
& module
);
135 std::string
GeneratePathToParentDirectory ( int numberOfParentDirectories
);
136 std::string
GetPathToTopDirectory ( Module
& module
);
137 void GenerateProxyMakefileForModule ( Module
& module
,
139 std::string outputTree
);
140 const Project
& project
;
143 struct ModuleHandlerInformations
145 HostType DefaultHost
;
147 const char* nasmflags
;
148 const char* linkerflags
;
151 extern const struct ModuleHandlerInformations ModuleHandlerInformations
[];