added msvc_clean and msvc_clean_all (patch by Brezenbak)
authorChristoph von Wittich <christoph_vw@reactos.org>
Tue, 10 Jan 2006 19:41:07 +0000 (19:41 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Tue, 10 Jan 2006 19:41:07 +0000 (19:41 +0000)
svn path=/trunk/; revision=20765

reactos/Makefile
reactos/tools/rbuild/backend/msvc/msvc.cpp
reactos/tools/rbuild/backend/msvc/msvc.h
reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp

index ab25433..ce29342 100644 (file)
@@ -396,6 +396,39 @@ msvc8: $(RBUILD_TARGET)
        $(ECHO_RBUILD)
        $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 msvc
 
        $(ECHO_RBUILD)
        $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 msvc
 
+.PHONY: msvc6
+msvc6_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs6.00 msvc
+
+.PHONY: msvc7
+msvc7_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.00 msvc
+
+.PHONY: msvc71
+msvc71_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.10 msvc
+
+.PHONY: msvc8
+msvc8_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs8.00 msvc
+
+.PHONY: msvc_clean
+msvc_clean: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c msvc
+
+.PHONY: msvc_clean_all
+msvc_clean_all: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs6.00 msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.00 msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs7.10 msvc
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -c -vs8.10 msvc
+
 .PHONY: makefile_auto_clean
 makefile_auto_clean:
        -@$(rm) $(ROS_AUTOMAKE) $(PREAUTO) 2>$(NUL)
 .PHONY: makefile_auto_clean
 makefile_auto_clean:
        -@$(rm) $(ROS_AUTOMAKE) $(PREAUTO) 2>$(NUL)
@@ -406,4 +439,4 @@ clean: makefile_auto_clean
 .PHONY: depends
 depends:
        @-$(rm) makefile.auto
 .PHONY: depends
 depends:
        @-$(rm) makefile.auto
-       @$(MAKE) $(filter-out depends, $(MAKECMDGOALS))
+       @$(MAKE) $(filter-out depends, $(MAKECMDGOALS))
\ No newline at end of file
index e7581bf..25adae1 100644 (file)
 #include <iostream>\r
 #include <fstream>\r
 #include <string>\r
 #include <iostream>\r
 #include <fstream>\r
 #include <string>\r
+#include <vector>\r
 \r
 #include "msvc.h"\r
 #include "../mingw/mingw.h"\r
 \r
 \r
 #include "msvc.h"\r
 #include "../mingw/mingw.h"\r
 \r
-using namespace std;\r
+using std::string;\r
+using std::vector;\r
+using std::ifstream;\r
 \r
 static class MSVCFactory : public Backend::Factory\r
 {\r
 \r
 static class MSVCFactory : public Backend::Factory\r
 {\r
@@ -53,6 +56,11 @@ MSVCBackend::MSVCBackend(Project &project,
 \r
 void MSVCBackend::Process()\r
 {\r
 \r
 void MSVCBackend::Process()\r
 {\r
+       if ( configuration.CleanAsYouGo ) {\r
+               _clean_project_files();\r
+               return;\r
+       }\r
+\r
        string filename_sln ( ProjectNode.name );\r
        //string filename_rules = "gccasm.rules";\r
        \r
        string filename_sln ( ProjectNode.name );\r
        //string filename_rules = "gccasm.rules";\r
        \r
@@ -205,6 +213,46 @@ void MSVCBackend::OutputFolders()
 #endif\r
 }\r
 \r
 #endif\r
 }\r
 \r
+std::string\r
+MSVCBackend::OptFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), "_" + _get_vc_dir() + "_auto.opt" )\r
+               );\r
+}\r
+\r
+std::string\r
+MSVCBackend::SuoFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), "_" + _get_vc_dir() + "_auto.suo" )\r
+               );\r
+}\r
+\r
+std::string\r
+MSVCBackend::DswFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), "_auto.dsw" )\r
+               );\r
+}\r
+\r
+std::string\r
+MSVCBackend::SlnFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), "_" + _get_vc_dir() + "_auto.sln" )\r
+               );\r
+}\r
+\r
+std::string\r
+MSVCBackend::NcbFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), "_" + _get_vc_dir() + "_auto.ncb" )\r
+               );\r
+}\r
+\r
 std::string\r
 MSVCBackend::DspFileName ( const Module& module ) const\r
 {\r
 std::string\r
 MSVCBackend::DspFileName ( const Module& module ) const\r
 {\r
@@ -217,6 +265,112 @@ std::string
 MSVCBackend::VcprojFileName ( const Module& module ) const\r
 {\r
        return DosSeparator(\r
 MSVCBackend::VcprojFileName ( const Module& module ) const\r
 {\r
        return DosSeparator(\r
-               ReplaceExtension ( module.GetPath(), "_auto.vcproj" )\r
-               );\r
+                       ReplaceExtension ( module.GetPath(), "_" + _get_vc_dir() + "_auto.vcproj" )\r
+                       );\r
+}\r
+\r
+std::string MSVCBackend::_get_vc_dir ( void ) const\r
+{\r
+       if ( configuration.VSProjectVersion == "6.00" )\r
+               return "vc6";\r
+       else if ( configuration.VSProjectVersion == "7.00" )\r
+               return "vc70";\r
+       else if ( configuration.VSProjectVersion == "7.10" )\r
+               return "vc71";\r
+       else /* must be VS2005 */\r
+               return "vc8";\r
+\r
+\r
+}\r
+\r
+void \r
+MSVCBackend::_get_object_files ( const Module& module, vector<string>& out) const\r
+{\r
+       string basepath = module.GetBasePath ();\r
+       string vcdir = _get_vc_dir ();\r
+       size_t i;\r
+       string intenv = Environment::GetIntermediatePath () + "\\" + basepath + "\\" + vcdir + "\\";\r
+       string outenv = Environment::GetOutputPath () + "\\" + basepath + "\\" + vcdir + "\\";\r
+       string dbg = vcdir.substr ( 0, 3 );\r
+\r
+       vector<string> cfgs;\r
+       cfgs.push_back ( intenv + "Debug" );\r
+       cfgs.push_back ( intenv + "Release" );\r
+       cfgs.push_back ( intenv + "Speed" );\r
+       cfgs.push_back ( outenv + "Debug" );\r
+       cfgs.push_back ( outenv + "Release" );\r
+       cfgs.push_back ( outenv + "Speed" );\r
+\r
+\r
+       vector<const IfableData*> ifs_list;\r
+       ifs_list.push_back ( &module.project.non_if_data );\r
+       ifs_list.push_back ( &module.non_if_data );\r
+       while ( ifs_list.size () )\r
+       {\r
+               const IfableData& data = *ifs_list.back();\r
+               ifs_list.pop_back();\r
+               const vector<File*>& files = data.files;\r
+               for ( i = 0; i < files.size (); i++ )\r
+               {\r
+                       string file = files[i]->name;\r
+                       string::size_type pos = file.find_last_of ("\\");\r
+                       if ( pos != string::npos )\r
+                               file.erase ( 0, pos+1 );\r
+                       if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )\r
+                               file = ReplaceExtension ( file, ".res" );\r
+                       else\r
+                               file = ReplaceExtension ( file, ".obj" );\r
+                       for ( size_t j = 0; j < cfgs.size () / 2; j++ )\r
+                               out.push_back ( cfgs[j] + "\\" + file );\r
+               }\r
+\r
+       }\r
+       //common files in intermediate dir\r
+       for ( i = 0; i < cfgs.size () / 2; i++)\r
+       {\r
+               out.push_back ( cfgs[i] + "\\" + "BuildLog.htm" );\r
+               out.push_back ( cfgs[i] + "\\" + dbg + "0.pdb" );\r
+               out.push_back ( cfgs[i] + "\\" + dbg + "0.idb" );\r
+               out.push_back ( cfgs[i] + "\\" + module.name + ".pch" );\r
+       }\r
+       //files in the output dir\r
+       for ( i = cfgs.size () / 2; i < cfgs.size (); i++ )\r
+       {\r
+               out.push_back ( cfgs[i] + "\\" + module.GetTargetName () );\r
+               out.push_back ( cfgs[i] + "\\" + module.name + ".pdb" );\r
+               out.push_back ( cfgs[i] + "\\" + module.name + ".lib" );\r
+               out.push_back ( cfgs[i] + "\\" + module.name + ".exp" );\r
+               out.push_back ( cfgs[i] + "\\" + module.name + ".ilk" );\r
+               out.push_back ( cfgs[i] + "\\" + "(InputName).obj" ); //MSVC2003 build bug \r
+       }\r
 }\r
 }\r
+\r
+void\r
+MSVCBackend::_clean_project_files ( void )\r
+{\r
+       for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )\r
+       {\r
+               Module& module = *ProjectNode.modules[i];\r
+               vector<string> out;\r
+               printf("Cleaning project %s %s %s\n", module.name.c_str (), module.GetBasePath ().c_str (), NcbFileName ( module ).c_str () );\r
+               \r
+               string basepath = module.GetBasePath ();\r
+               remove ( NcbFileName ( module ).c_str () );\r
+               remove ( DspFileName ( module ).c_str () );\r
+               remove ( DswFileName ( module ).c_str () );\r
+               remove ( OptFileName ( module ).c_str () );\r
+               remove ( SlnFileName ( module ).c_str () );\r
+               remove ( SuoFileName ( module ).c_str () );\r
+               remove ( VcprojFileName ( module ).c_str () );  \r
+\r
+               _get_object_files ( module, out );\r
+               for ( size_t j = 0; j < out.size (); j++)\r
+                       remove ( out[j].c_str () );\r
+       }\r
+       string filename_sln = ProjectNode.name + ".sln";\r
+       string filename_dsw = ProjectNode.name + ".dsw";\r
+\r
+       remove ( filename_sln.c_str () );\r
+       remove ( filename_dsw.c_str () );\r
+}\r
+\r
index 6d19353..459fcee 100644 (file)
@@ -55,7 +55,14 @@ class MSVCBackend : public Backend
 \r
                std::string DspFileName ( const Module& module ) const;\r
                std::string VcprojFileName ( const Module& module ) const;\r
 \r
                std::string DspFileName ( const Module& module ) const;\r
                std::string VcprojFileName ( const Module& module ) const;\r
-               \r
+               std::string DswFileName ( const Module& module ) const;\r
+               std::string SlnFileName ( const Module& module ) const;\r
+               std::string OptFileName ( const Module& module ) const;\r
+               std::string SuoFileName ( const Module& module ) const;\r
+               std::string NcbFileName ( const Module& module ) const;\r
+\r
+\r
+\r
                std::vector<FileUnit> m_fileUnits;\r
                std::vector<std::string> m_folders;\r
 \r
                std::vector<FileUnit> m_fileUnits;\r
                std::vector<std::string> m_folders;\r
 \r
@@ -87,6 +94,8 @@ class MSVCBackend : public Backend
                        const std::string &find_str,\r
                        const std::string &replace_str);\r
 \r
                        const std::string &find_str,\r
                        const std::string &replace_str);\r
 \r
+               std::string _get_vc_dir ( void ) const;\r
+\r
                void _generate_vcproj ( const Module& module );\r
 \r
                void _generate_sln_header ( FILE* OUT );\r
                void _generate_vcproj ( const Module& module );\r
 \r
                void _generate_sln_header ( FILE* OUT );\r
@@ -103,7 +112,8 @@ class MSVCBackend : public Backend
                void _generate_sln_configurations (\r
                        FILE* OUT,\r
                        std::string vcproj_guid );\r
                void _generate_sln_configurations (\r
                        FILE* OUT,\r
                        std::string vcproj_guid );\r
-\r
+               void _clean_project_files ( void );\r
+               void _get_object_files ( const Module& module, std::vector<std::string>& out ) const;\r
 };\r
 \r
 #endif // __MSVC_H__\r
 };\r
 \r
 #endif // __MSVC_H__\r
index 0abb5a4..f0b32fa 100644 (file)
@@ -252,8 +252,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
 \r
                fprintf ( OUT, "\t\t<Configuration\r\n" );\r
                fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.c_str() );\r
 \r
                fprintf ( OUT, "\t\t<Configuration\r\n" );\r
                fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.c_str() );\r
-               fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\\%s\\%s\"\r\n", outdir.c_str (), module.GetBasePath ().c_str (), cfg.c_str() );\r
-               fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\\%s\\%s\"\r\n", intdir.c_str (), module.GetBasePath ().c_str (), cfg.c_str() );\r
+               fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\\%s\\%s\\%s\"\r\n", outdir.c_str (), module.GetBasePath ().c_str (), _get_vc_dir().c_str (), cfg.c_str() );\r
+               fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\\%s\\%s\\%s\"\r\n", intdir.c_str (), module.GetBasePath ().c_str (), _get_vc_dir().c_str (), cfg.c_str() );\r
                fprintf ( OUT, "\t\t\tConfigurationType=\"%d\"\r\n", exe ? 1 : dll ? 2 : lib ? 4 : -1 );\r
                fprintf ( OUT, "\t\t\tCharacterSet=\"2\">\r\n" );\r
 \r
                fprintf ( OUT, "\t\t\tConfigurationType=\"%d\"\r\n", exe ? 1 : dll ? 2 : lib ? 4 : -1 );\r
                fprintf ( OUT, "\t\t\tCharacterSet=\"2\">\r\n" );\r
 \r