* Copyright (C) 2005 Trevor McCort\r
* Copyright (C) 2005 Casper S. Hornstrup\r
* Copyright (C) 2005 Steven Edwards\r
+ * Copyright (C) 2005 Royce Mitchell\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
\r
using namespace std;\r
\r
-char get_key(char *valid,char *prompt); //FIXME\r
-bool spawn_new(const string& cmd); //FIXME\r
-void gen_guid();\r
-\r
static class MSVCFactory : public Backend::Factory\r
{\r
public:\r
\r
void MSVCBackend::Process()\r
{\r
- bool exec = false;\r
- const char rbuild_mingw[] = "output-i386\\tools\\rbuild\\rbuild.exe mingw"; \r
\r
- string filename = ProjectNode.name + ".sln";\r
+ string filename_sln = ProjectNode.name + ".sln";\r
+ printf ( "Creating MSVC workspace: %s\n", filename_sln.c_str() );\r
\r
- cout << "Creating MSVC project: " << filename << endl;\r
-\r
ProcessModules();\r
+ m_slnFile = fopen ( filename_sln.c_str(), "wb" );\r
\r
- m_devFile.open(filename.c_str());\r
-\r
- if(!m_devFile.is_open())\r
+ if ( !m_slnFile )\r
{\r
- cout << "Could not open file." << endl;\r
+ printf ( "Could not create file '%s'.\n", filename_sln.c_str() );\r
return;\r
}\r
- m_devFile << "Microsoft Visual Studio Solution File, Format Version 9.00" << endl;\r
- m_devFile << "# Visual C++ Express 2005" << endl;\r
-\r
- m_devFile << "# FIXME Project listings here" << endl;\r
- m_devFile << "EndProject" << endl;\r
- m_devFile << "Global" << endl;\r
- m_devFile << " GlobalSection(SolutionConfigurationPlatforms) = preSolution" << endl;\r
- m_devFile << " Debug|Win32 = Debug|Win32" << endl;\r
- m_devFile << " Release|Win32 = Release|Win32" << endl;\r
- m_devFile << " EndGlobalSection" << endl;\r
- m_devFile << " GlobalSection(ProjectConfigurationPlatforms) = postSolution" << endl;\r
- m_devFile << " #FIXME Project Listings Here" << endl;\r
- m_devFile << " EndGlobalSection" << endl;\r
- m_devFile << " GlobalSection(SolutionProperties) = preSolution" << endl;\r
- m_devFile << " HideSolutionNode = FALSE" << endl;\r
- m_devFile << " EndGlobalSection" << endl;\r
- m_devFile << "EndGlobal" << endl;\r
-\r
- m_devFile << endl << endl;\r
-\r
- m_devFile.close();\r
-\r
- gen_guid();\r
-\r
- // The MSVC build still needs the mingw backend.\r
- ProcessModules();\r
\r
- cout << "Done." << endl << endl;\r
-\r
- cout << "Don't expect the MSVC backend to work yet. "<< endl << endl;\r
-\r
- if(get_key("yn","Would you like to configure for a Mingw build as well? (y/n)") == 'y')\r
- {\r
- exec = spawn_new(rbuild_mingw);\r
- if (!exec)\r
- printf("\nError invoking rbuild\n");\r
- }\r
+ _generate_sln ( m_slnFile );\r
+ fclose ( m_slnFile );\r
+ printf ( "Done.\n" );\r
}\r
\r
void MSVCBackend::ProcessModules()\r
{\r
Module &module = *ProjectNode.modules[i];\r
\r
- for(size_t k = 0; k < module.non_if_data.files.size(); k++)\r
+ module.guid = _gen_guid();\r
+\r
+ if (configuration.VSProjectVersion == "6.00")\r
+ this->_generate_dsp ( module );\r
+ else\r
+ this->_generate_vcproj ( module );\r
+\r
+\r
+ /*for(size_t k = 0; k < module.non_if_data.files.size(); k++)\r
{\r
File &file = *module.non_if_data.files[k];\r
\r
ProcessFile(file.name);\r
- }\r
+ }*/\r
}\r
}\r
\r
void MSVCBackend::ProcessFile(string &filepath)\r
{\r
// Remove the .\ at the start of the filenames\r
- filepath.erase(0, 2);\r
+ if ( filepath[0] == '.' && strchr ( "/\\", filepath[1] ) )\r
+ filepath.erase(0, 2);\r
\r
if(!FileExists(filepath))\r
return;\r
\r
void MSVCBackend::OutputFolders()\r
{\r
+#if 0\r
m_devFile << "Folders=";\r
\r
for(size_t i = 0; i < m_folders.size(); i++)\r
\r
m_devFile << m_folders[i];\r
}\r
+#endif\r
}\r
\r
-\r
-char get_key(char *valid,char *prompt)\r
+std::string\r
+MSVCBackend::DspFileName ( const Module& module ) const\r
{\r
- int ch,okay;\r
-\r
- while (1) {\r
- if (prompt) printf("%s ",prompt);\r
- fflush(stdout);\r
- while (ch = getchar(), ch == ' ' || ch == '\t');\r
- if (ch == EOF) exit(1);\r
- if (!strchr(valid,okay = ch)) okay = 0;\r
- while (ch = getchar(), ch != '\n' && ch != EOF);\r
- if (ch == EOF) exit(1);\r
- if (okay) return okay;\r
- printf("Invalid input.\n");\r
- }\r
+ return DosSeparator(\r
+ ReplaceExtension ( module.GetPath(), ".dsp" )\r
+ );\r
}\r
\r
-bool spawn_new( const string& cmd )\r
+std::string\r
+MSVCBackend::VcprojFileName ( const Module& module ) const\r
{\r
- string command = ssprintf (\r
- "%s",\r
- cmd.c_str (),\r
- NUL,\r
- NUL );\r
- int exitcode = system ( command.c_str () );\r
- return (exitcode == 0);\r
+ return DosSeparator(\r
+ ReplaceExtension ( module.GetPath(), ".vcproj" )\r
+ );\r
}\r