adding gccasm.rules to vcproj files
[reactos.git] / reactos / tools / rbuild / backend / msvc / msvc.cpp
index 7b0a5fe..4df39ab 100644 (file)
@@ -2,6 +2,7 @@
  * 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
@@ -56,59 +53,40 @@ MSVCBackend::MSVCBackend(Project &project,
 \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 + ".dsw";\r
+       string filename_sln ( ProjectNode.name );\r
+       string filename_rules = "gccasm.rules";\r
        \r
-       printf ( "Creating MSVC workspace: %s\n", filename.c_str() );\r
+       if ( configuration.VSProjectVersion == "6.00" )\r
+               filename_sln += ".dsw";\r
+       else {\r
+               filename_sln += ".sln";\r
 \r
-       ProcessModules();\r
+               m_rulesFile = fopen ( filename_rules.c_str(), "wb" );\r
+               if ( m_rulesFile )\r
+               {\r
+                       _generate_rules_file ( m_rulesFile );\r
+               }\r
+               fclose ( m_rulesFile );\r
+       }\r
 \r
-       m_dswFile = fopen ( filename.c_str(), "wb" );\r
+       printf ( "Creating MSVC workspace: %s\n", filename_sln.c_str() );\r
+       \r
+       ProcessModules();\r
+       m_slnFile = fopen ( filename_sln.c_str(), "wb" );\r
 \r
-       if ( !m_dswFile )\r
+       if ( !m_slnFile )\r
        {\r
-               printf ( "Could not create file '%s'.\n", filename.c_str() );\r
+               printf ( "Could not create file '%s'.\n", filename_sln.c_str() );\r
                return;\r
        }\r
-       _generate_wine_dsw ( m_dswFile );\r
-#if 0\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
-#endif\r
-       fclose ( m_dswFile );\r
 \r
-       // The MSVC build still needs the mingw backend.\r
-       //ProcessModules();\r
+       if ( configuration.VSProjectVersion == "6.00" )\r
+               _generate_wine_dsw ( m_slnFile );\r
+       else\r
+               _generate_sln ( m_slnFile );\r
 \r
+       fclose ( m_slnFile );\r
        printf ( "Done.\n" );\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
 }\r
 \r
 void MSVCBackend::ProcessModules()\r
@@ -117,8 +95,13 @@ void MSVCBackend::ProcessModules()
        {\r
                Module &module = *ProjectNode.modules[i];\r
 \r
-               this->_generate_dsp ( module );\r
-               gen_guid();\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
@@ -222,39 +205,18 @@ void MSVCBackend::OutputFolders()
 #endif\r
 }\r
 \r
-\r
-char get_key(char *valid,char *prompt)\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
-}\r
-\r
-bool spawn_new( const string& cmd )\r
+std::string\r
+MSVCBackend::DspFileName ( 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(), ".dsp" )\r
+               );\r
 }\r
 \r
 std::string\r
-MSVCBackend::DspFileName ( const Module& module ) const\r
+MSVCBackend::VcprojFileName ( const Module& module ) const\r
 {\r
        return DosSeparator(\r
-               ReplaceExtension ( module.GetPath(), ".dsp" )\r
+               ReplaceExtension ( module.GetPath(), ".vcproj" )\r
                );\r
 }\r