make_msvcX_install_[config] patch by Brezenbak
[reactos.git] / reactos / tools / rbuild / backend / msvc / msvc.cpp
index 25adae1..dfadc5e 100644 (file)
@@ -60,7 +60,10 @@ void MSVCBackend::Process()
                _clean_project_files();\r
                return;\r
        }\r
-\r
+       if ( configuration.InstallFiles ) {\r
+               _install_files( _get_vc_dir(),  configuration.VSConfigurationType );\r
+               return;\r
+       }\r
        string filename_sln ( ProjectNode.name );\r
        //string filename_rules = "gccasm.rules";\r
        \r
@@ -374,3 +377,42 @@ MSVCBackend::_clean_project_files ( void )
        remove ( filename_dsw.c_str () );\r
 }\r
 \r
+bool\r
+MSVCBackend::_copy_file ( const std::string& inputname, const std::string& targetname ) const\r
+{\r
+  FILE * input = fopen ( inputname.c_str (), "rb" );\r
+       if ( !input )\r
+               return false;\r
+\r
+  FILE * output = fopen ( targetname.c_str (), "wb+" );\r
+  if ( !output )\r
+  {\r
+       fclose ( input );\r
+       return false;\r
+  }\r
+\r
+  char buffer[256];\r
+  int num_read;\r
+  while ( (num_read = fread( buffer, sizeof(char), 256, input) ) || !feof( input ) )\r
+               fwrite( buffer, sizeof(char), num_read, output );\r
+\r
+  fclose ( input );\r
+  fclose ( output );\r
+  return true;\r
+}\r
+\r
+void\r
+MSVCBackend::_install_files (const std::string& vcdir, const::string& config)\r
+{\r
+       for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )\r
+       {\r
+               Module& module = *ProjectNode.modules[i];\r
+               if ( module.installBase == "" || module.installName == "" )\r
+                       continue;\r
+\r
+               string inputname = Environment::GetOutputPath () + "\\" + module.GetBasePath () + "\\" + vcdir + "\\" + config + "\\" + module.GetTargetName ();\r
+               string installdir = Environment::GetInstallPath () + "\\" + module.installBase + "\\" + module.installName;\r
+               if ( _copy_file( inputname, installdir ) )\r
+                       printf ("Installed File :'%s'\n",installdir.c_str () );\r
+       }\r
+}\r