using std::string;\r
using std::vector;\r
\r
+#ifdef OUT\r
+#undef OUT\r
+#endif//OUT\r
+\r
void\r
MSVCBackend::_generate_vcproj ( const Module& module )\r
{\r
\r
std::vector<std::string> cfgs;\r
\r
- cfgs.push_back ( module.name + " - Win32" );\r
+ cfgs.push_back ( "Debug" );\r
+ cfgs.push_back ( "Release" );\r
\r
if (!no_cpp)\r
{\r
\r
fprintf ( OUT, "\tVersion=\"%s\"\r\n", configuration.VSProjectVersion.c_str() );\r
fprintf ( OUT, "\tName=\"%s\"\r\n", module.name.c_str() );\r
+ fprintf ( OUT, "\tProjectGUID=\"%s\"\r\n", module.guid.c_str() ); \r
fprintf ( OUT, "\tKeyword=\"Win32Proj\">\r\n" );\r
\r
fprintf ( OUT, "\t<Platforms>\r\n" );\r
{\r
if ( i > 0 )\r
fprintf ( OUT, ";" );\r
+\r
+ defines[i] = _replace_str(defines[i], "\"","""); \r
fprintf ( OUT, "%s", defines[i].c_str() );\r
}\r
fprintf ( OUT, "\"\r\n" );\r
{\r
fprintf ( OUT, "\t\t\t<Tool\r\n" );\r
fprintf ( OUT, "\t\t\t\tName=\"VCLibrarianTool\"\r\n" );\r
- fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s.%s\"/>\r\n", module.name.c_str(), module_type.c_str() );\r
+ fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"/>\r\n", module.name.c_str(), module_type.c_str() );\r
}\r
else\r
{\r
}\r
fprintf ( OUT, "\"\r\n" );\r
\r
- fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s.%s\"\r\n", module.name.c_str(), module_type.c_str() );\r
+ fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"\r\n", module.name.c_str(), module_type.c_str() );\r
fprintf ( OUT, "\t\t\t\tLinkIncremental=\"%d\"\r\n", debug ? 2 : 1 );\r
fprintf ( OUT, "\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n" );\r
\r
fclose(OUT);\r
}\r
\r
+std::string\r
+MSVCBackend::_replace_str(std::string string1, const std::string &find_str, const std::string &replace_str)\r
+{\r
+ std::string::size_type pos = string1.find(find_str, 0);\r
+ int intLen = find_str.length();\r
+\r
+ while(std::string::npos != pos)\r
+ {\r
+ string1.replace(pos, intLen, replace_str);\r
+ pos = string1.find(find_str, intLen + pos);\r
+ }\r
+\r
+ return string1;\r
+} \r
+\r
void\r
MSVCBackend::_generate_sln_header ( FILE* OUT )\r
{\r
string version;\r
\r
if (configuration.VSProjectVersion == "7.00")\r
- version = "7.00";\r
+ version = "7.00";\r
\r
if (configuration.VSProjectVersion == "7.10")\r
- version = "8.00";\r
+ version = "8.00";\r
\r
if (configuration.VSProjectVersion == "8.00")\r
- version = "9.00";\r
+ version = "9.00";\r
\r
fprintf ( OUT, "Microsoft Visual Studio Solution File, Format Version %s\r\n", version.c_str() );\r
fprintf ( OUT, "# Visual Studio 2005\r\n" );\r
std::string vcproj_guid,\r
const std::vector<Dependency*>& dependencies )\r
{\r
- \r
- vcproj_file = DosSeparator ( std::string(".\\") + vcproj_file );\r
+ vcproj_file = DosSeparator ( std::string(".\\") + vcproj_file );\r
\r
fprintf ( OUT, "Project(\"%s\") = \"%s\", \"%s\", \"%s\"\r\n", sln_guid.c_str() , module.name.c_str(), vcproj_file.c_str(), vcproj_guid.c_str() );\r
- fprintf ( OUT, " ProjectSection(ProjectDependencies) = postProject\r\n" );\r
- fprintf ( OUT, " EndProjectSection\r\n" );\r
+\r
+ //FIXME: only omit ProjectDependencies in VS 2005 when there are no dependencies\r
+ //NOTE: VS 2002 do not use ProjectSection; it uses GlobalSection instead\r
+ if (configuration.VSProjectVersion == "7.10") {\r
+ fprintf ( OUT, "\tProjectSection(ProjectDependencies) = postProject\r\n" );\r
+ fprintf ( OUT, "\tEndProjectSection\r\n" );\r
+ }\r
+\r
fprintf ( OUT, "EndProject\r\n" );\r
}\r
\r
void\r
MSVCBackend::_generate_sln_footer ( FILE* OUT )\r
{\r
- fprintf ( OUT, "Global\r\n" );\r
+ fprintf ( OUT, "Global\r\n" );\r
+ fprintf ( OUT, "\tGlobalSection(SolutionConfiguration) = preSolution\r\n" );\r
+ fprintf ( OUT, "\t\tDebug = Debug\r\n" );\r
+ fprintf ( OUT, "\t\tRelease = Release\r\n" );\r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
+ fprintf ( OUT, "\tGlobalSection(ProjectConfiguration) = postSolution\r\n" );\r
+ for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )\r
+ {\r
+ Module& module = *ProjectNode.modules[i];\r
+ std::string guid = module.guid;\r
+ _generate_sln_configurations ( OUT, guid.c_str() );\r
+ } \r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
+ fprintf ( OUT, "\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n" );\r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
+ fprintf ( OUT, "\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n" );\r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
\r
- fprintf ( OUT, " GlobalSection(SolutionConfiguration) = preSolution\r\n" );\r
- fprintf ( OUT, " Debug = Debug\r\n" );\r
- fprintf ( OUT, " Release = Release\r\n" );\r
- fprintf ( OUT, " EndGlobalSection\r\n" );\r
+ \r
+ if (configuration.VSProjectVersion == "7.00") {\r
+ fprintf ( OUT, "\tGlobalSection(ProjectDependencies) = postSolution\r\n" );\r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
+ }\r
+\r
+ if (configuration.VSProjectVersion == "8.00") {\r
+ fprintf ( OUT, "\tGlobalSection(SolutionProperties) = preSolution\r\n" );\r
+ fprintf ( OUT, "\t\tHideSolutionNode = FALSE\r\n" );\r
+ fprintf ( OUT, "\tEndGlobalSection\r\n" );\r
+ }\r
\r
- fprintf ( OUT, " GlobalSection(ExtensibilityGlobals) = postSolution\r\n" );\r
- fprintf ( OUT, " EndGlobalSection\r\n" );\r
- fprintf ( OUT, " GlobalSection(ExtensibilityAddIns) = postSolution\r\n" );\r
- fprintf ( OUT, " EndGlobalSection\r\n" );\r
fprintf ( OUT, "EndGlobal\r\n" );\r
+ fprintf ( OUT, "\r\n" );\r
+}\r
\r
\r
- fprintf ( OUT, "\r\n" );\r
+void\r
+MSVCBackend::_generate_sln_configurations ( FILE* OUT, std::string vcproj_guid )\r
+{\r
+ fprintf ( OUT, "\t\t%s.Debug.ActiveCfg = Debug|Win32\r\n", vcproj_guid.c_str() );\r
+ fprintf ( OUT, "\t\t%s.Debug.Build.0 = Debug|Win32\r\n", vcproj_guid.c_str() );\r
+ fprintf ( OUT, "\t\t%s.Debug.Release.ActiveCfg = Release|Win32\r\n", vcproj_guid.c_str() );\r
+ fprintf ( OUT, "\t\t%s.Debug.Release.Build.0 = Release|Win32\r\n", vcproj_guid.c_str() );\r
}\r
\r
-\r
void\r
MSVCBackend::_generate_sln ( FILE* OUT )\r
{\r
string sln_guid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";\r
+ vector<string> guids;\r
\r
_generate_sln_header(OUT);\r
// TODO FIXME - is it necessary to sort them?\r
for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )\r
{\r
Module& module = *ProjectNode.modules[i];\r
-\r
+ \r
std::string vcproj_file = VcprojFileName ( module );\r
- std::string vcproj_guid = _gen_guid();\r
- _generate_sln_project ( OUT, module, vcproj_file, sln_guid, vcproj_guid, module.dependencies );\r
- }\r
- _generate_sln_footer ( OUT );\r
+ _generate_sln_project ( OUT, module, vcproj_file, sln_guid, module.guid, module.dependencies );\r
+ }\r
+ _generate_sln_footer ( OUT );\r
}\r
\r