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
VcxprojFileName ( const Module
& module
) const;
107 std::string
SlnFileName ( const Module
& module
) const;
108 std::string
SuoFileName ( const Module
& module
) const;
109 std::string
NcbFileName ( const Module
& module
) const;
111 std::vector
<MSVCConfiguration
*> m_configurations
;
113 std::vector
<FileUnit
> m_fileUnits
;
114 std::vector
<std::string
> m_folders
;
118 std::string
_gen_guid();
120 std::string
_get_solution_version ( void );
121 std::string
_get_studio_version ( void );
122 std::string
_get_vc_dir ( void ) const;
124 void _clean_project_files ( void );
125 void _get_object_files ( const Module
& module
, std::vector
<std::string
>& out
) const;
126 void _get_def_files ( const Module
& module
, std::vector
<std::string
>& out
) const;
127 void _install_files ( const std::string
& vcdir
, const std::string
& config
);
128 bool _copy_file ( const std::string
& inputname
, const std::string
& targetname
) const;
129 const Property
* _lookup_property ( const Module
& module
, const std::string
& name
) const;
138 ProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
139 virtual ~ProjMaker() {}
141 virtual void _generate_proj_file ( const Module
& module
) = 0;
142 virtual void _generate_user_configuration ();
145 Configuration configuration
;
146 std::vector
<MSVCConfiguration
*> m_configurations
;
147 std::string vcproj_file
;
150 std::vector
<std::string
> header_files
;
151 std::vector
<std::string
> includes
;
152 std::vector
<std::string
> includes_ros
;
153 std::vector
<std::string
> libraries
;
154 std::set
<std::string
> common_defines
;
155 std::string baseaddr
;
157 std::string
VcprojFileName ( const Module
& module
) const;
158 std::string
_get_vc_dir ( void ) const;
160 std::string
_strip_gcc_deffile(std::string Filename
, std::string sourcedir
, std::string objdir
);
161 std::string
_get_solution_version ( void );
162 std::string
_get_studio_version ( void );
163 std::string
_replace_str( std::string string1
, const std::string
&find_str
, const std::string
&replace_str
);
165 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
166 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
169 class VCProjMaker
: public ProjMaker
173 VCProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
174 virtual ~VCProjMaker ();
176 void _generate_proj_file ( const Module
& module
);
177 void _generate_user_configuration ();
180 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
181 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
182 std::string
_get_file_path( FileLocation
* file
, std::string relative_path
);
185 class VCXProjMaker
: public ProjMaker
189 VCXProjMaker ( Configuration
& buildConfig
, const std::vector
<MSVCConfiguration
*>& msvc_configs
, std::string filename
);
190 virtual ~VCXProjMaker ();
192 void _generate_proj_file ( const Module
& module
);
193 void _generate_user_configuration ();
196 void _generate_standard_configuration( const Module
& module
, const MSVCConfiguration
& cfg
, BinaryType binaryType
);
197 void _generate_makefile_configuration( const Module
& module
, const MSVCConfiguration
& cfg
);
203 SlnMaker ( Configuration
& buildConfig
, Project
& ProjectNode
, const std::vector
<MSVCConfiguration
*>& configurations
, std::string filename_sln
);
206 void _generate_sln ( std::string solution_version
, std::string studio_version
);
209 Configuration m_configuration
;
210 Project
* m_ProjectNode
;
211 std::vector
<MSVCConfiguration
*> m_configurations
;
214 void _generate_sln_header ( std::string solution_version
, std::string studio_version
);
215 void _generate_sln_footer ( );
216 //void _generate_rules_file ( FILE* OUT );
217 void _generate_sln_project (
218 const Module
& module
,
219 std::string vcproj_file
,
220 std::string sln_guid
,
221 std::string vcproj_guid
,
222 const std::vector
<Library
*>& libraries
);
223 void _generate_sln_configurations ( std::string vcproj_guid
);
229 PropsMaker ( Configuration
& buildConfig
,
230 Project
* ProjectNode
,
231 std::string filename_props
,
232 MSVCConfiguration
* msvc_configs
);
236 void _generate_props ( std::string solution_version
, std::string studio_version
);
239 Configuration m_configuration
;
240 Project
* m_ProjectNode
;
242 MSVCConfiguration
* m_msvc_config
;
246 bool use_ros_headers
;
248 void _generate_header();
249 void _generate_tools_defaults();
250 void _generate_macro(std::string Name
, std::string Value
, bool EvairomentVariable
);
251 void _generate_global_includes();
252 void _generate_global_definitions();
253 void _generate_footer();