2 * Copyright (C) 2005 Trevor McCort
3 * Copyright (C) 2005 Casper S. Hornstrup
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "../backend.h"
48 enum ConfigurationType
72 class MSVCConfiguration
75 MSVCConfiguration(const OptimizationType optimization
,
76 const HeadersType headers
= MSVCHeaders
,
77 const std::string
&name
= "");
78 virtual ~MSVCConfiguration() {}
80 OptimizationType optimization
;
84 class MSVCBackend
: public Backend
88 MSVCBackend(Project
&project
,
89 Configuration
& configuration
);
90 virtual ~MSVCBackend() {}
92 virtual void Process();
96 void ProcessModules();
97 void ProcessFile(std::string
&filename
);
99 bool CheckFolderAdded(std::string
&folder
);
100 void AddFolders(std::string
&folder
);
102 void OutputFolders();
103 void OutputFileUnits();
105 std::string
VcprojFileName ( const Module
& module
) const;
106 std::string
SlnFileName ( const Module
& module
) const;
107 std::string
SuoFileName ( const Module
& module
) const;
108 std::string
NcbFileName ( const Module
& module
) const;
110 std::vector
<MSVCConfiguration
*> m_configurations
;
112 std::vector
<FileUnit
> m_fileUnits
;
113 std::vector
<std::string
> m_folders
;
117 std::string
_gen_guid();
119 std::string
_get_solution_version ( void );
120 std::string
_get_studio_version ( void );
121 std::string
_get_vc_dir ( void ) const;
123 void _clean_project_files ( void );
124 void _get_object_files ( const Module
& module
, std::vector
<std::string
>& out
) const;
125 void _get_def_files ( const Module
& module
, std::vector
<std::string
>& out
) const;
126 void _install_files ( const std::string
& vcdir
, const std::string
& config
);
127 bool _copy_file ( const std::string
& inputname
, const std::string
& targetname
) const;
128 const Property
* _lookup_property ( const Module
& module
, const std::string
& name
) const;
137 ProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
138 virtual ~ProjMaker() {}
140 virtual void _generate_proj_file ( const Module
& module
) = 0;
141 virtual void _generate_user_configuration ();
144 Configuration configuration
;
145 std::vector
<MSVCConfiguration
*> m_configurations
;
146 std::string vcproj_file
;
149 std::vector
<std::string
> header_files
;
150 std::vector
<std::string
> includes
;
151 std::vector
<std::string
> includes_ros
;
152 std::vector
<std::string
> libraries
;
153 std::set
<std::string
> common_defines
;
154 std::string baseaddr
;
156 std::string
VcprojFileName ( const Module
& module
) const;
157 std::string
_get_vc_dir ( void ) const;
159 std::string
_strip_gcc_deffile(std::string Filename
, std::string sourcedir
, std::string objdir
);
160 std::string
_get_solution_version ( void );
161 std::string
_get_studio_version ( void );
162 std::string
_replace_str( std::string string1
, const std::string
&find_str
, const std::string
&replace_str
);
164 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
165 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
168 class VCProjMaker
: public ProjMaker
172 VCProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
173 virtual ~VCProjMaker ();
175 void _generate_proj_file ( const Module
& module
);
176 void _generate_user_configuration ();
179 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
180 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
183 class VCXProjMaker
: public ProjMaker
187 VCXProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
188 virtual ~VCXProjMaker ();
190 void _generate_proj_file ( const Module
& module
);
191 void _generate_user_configuration ();
194 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
195 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
201 SlnMaker ( Configuration
& buildConfig
, Project
& ProjectNode
, const std::vector
<MSVCConfiguration
*>& configurations
, std::string filename_sln
);
204 void _generate_sln ( std::string solution_version
, std::string studio_version
);
207 Configuration m_configuration
;
208 Project
* m_ProjectNode
;
209 std::vector
<MSVCConfiguration
*> m_configurations
;
212 void _generate_sln_header ( std::string solution_version
, std::string studio_version
);
213 void _generate_sln_footer ( );
214 //void _generate_rules_file ( FILE* OUT );
215 void _generate_sln_project (
216 const Module
& module
,
217 std::string vcproj_file
,
218 std::string sln_guid
,
219 std::string vcproj_guid
,
220 const std::vector
<Library
*>& libraries
);
221 void _generate_sln_configurations ( std::string vcproj_guid
);