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
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "../backend.h"
26 #define NUL "/dev/null"
30 class MingwModuleHandler
;
33 v2s ( const string_list
& v
, int wrap_at
);
35 typedef std::map
<std::string
,Directory
*> directory_map
;
42 directory_map subdirs
;
43 Directory ( const std::string
& name
);
44 void Add ( const char* subdir
);
45 void GenerateTree ( const std::string
& parent
,
47 std::string
EscapeSpaces ( std::string path
);
48 void CreateRule ( FILE* f
,
49 const std::string
& parent
);
51 bool mkdir_p ( const char* path
);
52 std::string
ReplaceVariable ( std::string name
,
55 std::string
GetEnvironmentVariable ( const std::string
& name
);
56 void ResolveVariablesInPath ( char* buf
,
58 bool CreateDirectory ( std::string path
);
62 class MingwBackend
: public Backend
65 MingwBackend ( Project
& project
,
66 Configuration
& configuration
);
68 virtual void Process ();
69 std::string
AddDirectoryTarget ( const std::string
& directory
,
70 Directory
* directoryTree
);
71 const Module
& GetAliasedModuleOrModule ( const Module
& module
) const;
72 std::string compilerPrefix
;
73 std::string compilerCommand
;
74 std::string nasmCommand
;
76 Directory
* intermediateDirectory
;
77 Directory
* outputDirectory
;
78 Directory
* installDirectory
;
80 void CreateMakefile ();
81 void CloseMakefile () const;
82 void GenerateHeader () const;
83 std::string
GenerateIncludesAndDefines ( IfableData
& data
) const;
84 void GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
85 IfableData
& data
) const;
86 void GenerateGlobalCFlagsAndProperties ( const char* op
,
87 IfableData
& data
) const;
88 void GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
89 IfableData
& data
) const;
90 void GenerateProjectGccOptions ( const char* assignmentOperation
,
91 IfableData
& data
) const;
92 std::string
GenerateProjectLFLAGS () const;
93 void GenerateDirectories ();
94 void GenerateGlobalVariables () const;
95 bool IncludeInAllTarget ( const Module
& module
) const;
96 void GenerateAllTarget ( const std::vector
<MingwModuleHandler
*>& handlers
) const;
97 std::string
GetBuildToolDependencies () const;
98 void GenerateInitTarget () const;
99 void GenerateRegTestsRunTarget () const;
100 void GenerateXmlBuildFilesMacro() const;
101 std::string
GetBin2ResExecutable ();
102 void UnpackWineResources ();
103 void GenerateTestSupportCode ();
104 std::string
GetProxyMakefileTree () const;
105 void GenerateProxyMakefiles ();
106 void CheckAutomaticDependencies ();
107 bool IncludeDirectoryTarget ( const std::string
& directory
) const;
108 bool TryToDetectThisCompiler ( const std::string
& compiler
);
109 void DetectCompiler ();
110 bool TryToDetectThisNetwideAssembler ( const std::string
& assembler
);
111 void DetectNetwideAssembler ();
112 void DetectPipeSupport ();
113 void DetectPCHSupport ();
114 void ProcessModules ();
115 void CheckAutomaticDependenciesForModuleOnly ();
116 void ProcessNormal ();
117 std::string
GetNonModuleInstallDirectories ( const std::string
& installDirectory
);
118 std::string
GetInstallDirectories ( const std::string
& installDirectory
);
119 void GetNonModuleInstallFiles ( std::vector
<std::string
>& out
) const;
120 void GetInstallFiles ( std::vector
<std::string
>& out
) const;
121 void GetNonModuleInstallTargetFiles ( std::vector
<std::string
>& out
) const;
122 void GetModuleInstallTargetFiles ( std::vector
<std::string
>& out
) const;
123 void GetInstallTargetFiles ( std::vector
<std::string
>& out
) const;
124 void OutputInstallTarget ( const std::string
& sourceFilename
,
125 const std::string
& targetFilename
,
126 const std::string
& targetDirectory
);
127 void OutputNonModuleInstallTargets ();
128 void OutputModuleInstallTargets ();
129 std::string
GetRegistrySourceFiles ();
130 std::string
GetRegistryTargetFiles ();
131 void OutputRegistryInstallTarget ();
132 void GenerateInstallTarget ();
133 void GetModuleTestTargets ( std::vector
<std::string
>& out
) const;
134 void GenerateTestTarget ();
135 void GenerateDirectoryTargets ();
144 ProxyMakefile ( const Project
& project
);
146 void GenerateProxyMakefiles ( bool verbose
,
147 std::string outputTree
);
149 std::string
GeneratePathToParentDirectory ( int numberOfParentDirectories
);
150 std::string
GetPathToTopDirectory ( Module
& module
);
151 bool GenerateProxyMakefile ( Module
& module
);
152 void GenerateProxyMakefileForModule ( Module
& module
,
154 std::string outputTree
);
155 const Project
& project
;