From ca6850941c181236215c0f2bc6d94354bdf92afc Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Fri, 4 Dec 2009 16:15:08 +0000 Subject: [PATCH] Start implementing Visual Studio 2010 support. This is seriously boring, don't expect it anytime soon :( svn path=/trunk/; revision=44406 --- reactos/tools/rbuild/backend/msvc/msvc.cpp | 18 +- reactos/tools/rbuild/backend/msvc/msvc.h | 1 + .../tools/rbuild/backend/msvc/vcprojmaker.cpp | 2 +- .../rbuild/backend/msvc/vcxprojmaker.cpp | 197 +++++++++++++++++- reactos/tools/rbuild/rbuild.h | 2 +- 5 files changed, 211 insertions(+), 9 deletions(-) diff --git a/reactos/tools/rbuild/backend/msvc/msvc.cpp b/reactos/tools/rbuild/backend/msvc/msvc.cpp index 5beb7d05220..8ddf0cb7391 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.cpp +++ b/reactos/tools/rbuild/backend/msvc/msvc.cpp @@ -138,12 +138,16 @@ void MSVCBackend::ProcessModules() ProjMaker *projMaker; - string vcproj_file = VcprojFileName(module); - if (configuration.VSProjectVersion == "10.00") + { + string vcproj_file = VcprojFileName(module); projMaker = new VCXProjMaker( configuration, m_configurations, vcproj_file ); + } else - projMaker = new VCProjMaker( configuration, m_configurations, vcproj_file ); + { + string vcxproj_file = VcxprojFileName(module); + projMaker = new VCProjMaker( configuration, m_configurations, vcxproj_file ); + } projMaker->_generate_proj_file ( module ); delete projMaker; @@ -275,6 +279,14 @@ MSVCBackend::VcprojFileName ( const Module& module ) const ); } +std::string +MSVCBackend::VcxprojFileName ( const Module& module ) const +{ + return FixSeparatorForSystemCommand( + ReplaceExtension ( module.output->relative_path + "\\" + module.name, "_" + _get_vc_dir() + "_auto.vcxproj" ) + ); +} + std::string MSVCBackend::_get_vc_dir ( void ) const { if ( configuration.VSProjectVersion == "8.00" ) diff --git a/reactos/tools/rbuild/backend/msvc/msvc.h b/reactos/tools/rbuild/backend/msvc/msvc.h index 69050cbba03..fde4b81657e 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.h +++ b/reactos/tools/rbuild/backend/msvc/msvc.h @@ -103,6 +103,7 @@ class MSVCBackend : public Backend void OutputFileUnits(); std::string VcprojFileName ( const Module& module ) const; + std::string VcxprojFileName ( const Module& module ) const; std::string SlnFileName ( const Module& module ) const; std::string SuoFileName ( const Module& module ) const; std::string NcbFileName ( const Module& module ) const; diff --git a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp index f43f745ec40..36a37380265 100644 --- a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp @@ -107,7 +107,7 @@ VCProjMaker::_generate_proj_file ( const Module& module ) if ((computername != "") && (username != "")) vcproj_file_user = vcproj_file + "." + computername + "." + username + ".user"; - printf ( "Creating MSVC.NET project: '%s'\n", vcproj_file.c_str() ); + printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() ); string path_basedir = module.GetPathToBaseDir (); string intenv = Environment::GetIntermediatePath (); diff --git a/reactos/tools/rbuild/backend/msvc/vcxprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcxprojmaker.cpp index a5cc7181583..cc8cedf367c 100644 --- a/reactos/tools/rbuild/backend/msvc/vcxprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcxprojmaker.cpp @@ -75,8 +75,195 @@ VCXProjMaker::~VCXProjMaker() void VCXProjMaker::_generate_proj_file ( const Module& module ) { - // TODO: Implement me - ProjMaker::_generate_proj_file ( module ); + size_t i; + + string computername; + string username; + + // make sure the containers are empty + header_files.clear(); + includes.clear(); + includes_ros.clear(); + libraries.clear(); + common_defines.clear(); + + if (getenv ( "USERNAME" ) != NULL) + username = getenv ( "USERNAME" ); + if (getenv ( "COMPUTERNAME" ) != NULL) + computername = getenv ( "COMPUTERNAME" ); + else if (getenv ( "HOSTNAME" ) != NULL) + computername = getenv ( "HOSTNAME" ); + + string vcproj_file_user = ""; + + if ((computername != "") && (username != "")) + vcproj_file_user = vcproj_file + "." + computername + "." + username + ".user"; + + printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() ); + + string path_basedir = module.GetPathToBaseDir (); + string intenv = Environment::GetIntermediatePath (); + string outenv = Environment::GetOutputPath (); + string outdir; + string intdir; + string vcdir; + + if ( intenv == "obj-i386" ) + intdir = path_basedir + "obj-i386"; /* append relative dir from project dir */ + else + intdir = intenv; + + if ( outenv == "output-i386" ) + outdir = path_basedir + "output-i386"; + else + outdir = outenv; + + if ( configuration.UseVSVersionInPath ) + { + vcdir = DEF_SSEP + _get_vc_dir(); + } + + bool include_idl = false; + + vector source_files, resource_files; + vector ifs_list; + ifs_list.push_back ( &module.project.non_if_data ); + ifs_list.push_back ( &module.non_if_data ); + + while ( ifs_list.size() ) + { + const IfableData& data = *ifs_list.back(); + ifs_list.pop_back(); + const vector& files = data.files; + for ( i = 0; i < files.size(); i++ ) + { + if (files[i]->file.directory != SourceDirectory) + continue; + + // We want the full path here for directory support later on + string path = Path::RelativeFromDirectory ( + files[i]->file.relative_path, + module.output->relative_path ); + string file = path + std::string("\\") + files[i]->file.name; + + if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) + resource_files.push_back ( file ); + else if ( !stricmp ( Right(file,2).c_str(), ".h" ) ) + header_files.push_back ( file ); + else + source_files.push_back ( file ); + } + const vector& incs = data.includes; + for ( i = 0; i < incs.size(); i++ ) + { + string path = Path::RelativeFromDirectory ( + incs[i]->directory->relative_path, + module.output->relative_path ); + if ( module.type != RpcServer && module.type != RpcClient ) + { + if ( path.find ("/include/reactos/idl") != string::npos) + { + include_idl = true; + continue; + } + } + // switch between general headers and ros headers + if ( !strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 ) || + !strncmp(incs[i]->directory->relative_path.c_str(), "include\\ddk", 11 ) || + !strncmp(incs[i]->directory->relative_path.c_str(), "include\\GL", 10 ) || + !strncmp(incs[i]->directory->relative_path.c_str(), "include\\psdk", 12 ) || + !strncmp(incs[i]->directory->relative_path.c_str(), "include\\reactos\\wine", 20 ) ) + { + if (strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 )) + // not crt include + includes_ros.push_back ( path ); + } + else + { + includes.push_back ( path ); + } + } + const vector& libs = data.libraries; + for ( i = 0; i < libs.size(); i++ ) + { + string libpath = outdir + "\\" + libs[i]->importedModule->output->relative_path + "\\" + _get_vc_dir() + "\\---\\" + libs[i]->name + ".lib"; + libraries.push_back ( libpath ); + } + const vector& defs = data.defines; + for ( i = 0; i < defs.size(); i++ ) + { + if ( defs[i]->backend != "" && defs[i]->backend != "msvc" ) + continue; + + if ( defs[i]->value[0] ) + common_defines.insert( defs[i]->name + "=" + defs[i]->value ); + else + common_defines.insert( defs[i]->name ); + } + for ( std::map::const_iterator p = data.properties.begin(); p != data.properties.end(); ++ p ) + { + Property& prop = *p->second; + if ( strstr ( module.baseaddress.c_str(), prop.name.c_str() ) ) + baseaddr = prop.value; + } + } + /* include intermediate path for reactos.rc */ + string version = intdir + "\\include"; + includes.push_back (version); + version += "\\reactos"; + includes.push_back (version); + + // Set the binary type + string module_type = GetExtension(*module.output); + BinaryType binaryType; + if ((module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a")) + binaryType = Lib; + else if ((module_type == ".dll") || (module_type == ".cpl")) + binaryType = Dll; + else if ((module_type == ".exe") || (module_type == ".scr")) + binaryType = Exe; + else if (module_type == ".sys") + binaryType = Sys; + else + binaryType = BinUnknown; + + string include_string; + + fprintf ( OUT, "\r\n" ); + fprintf ( OUT, "\r\n" ); + + if (configuration.VSProjectVersion.empty()) + configuration.VSProjectVersion = "10.00"; + + // Write out the configurations + fprintf ( OUT, "\t\r\n" ); + for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) + { + const MSVCConfiguration& cfg = *m_configurations[icfg]; + + if ( cfg.optimization == RosBuild ) + { + _generate_makefile_configuration( module, cfg ); + } + else + { + _generate_standard_configuration( module, cfg, binaryType ); + } + } + fprintf ( OUT, "\t\r\n" ); + + // Write out the global info + fprintf ( OUT, "\t\r\n" ); + fprintf ( OUT, "\t\t{%s}\r\n", module.guid.c_str() ); + fprintf ( OUT, "\t\t%s\r\n", "Win32Proj" ); //FIXME: Win32Proj??? + fprintf ( OUT, "\t\t%s\r\n", module.name.c_str() ); //FIXME: shouldn't this be the soltion name? + fprintf ( OUT, "\t\r\n" ); + + + } void @@ -89,8 +276,10 @@ VCXProjMaker::_generate_user_configuration () void VCXProjMaker::_generate_standard_configuration( const Module& module, const MSVCConfiguration& cfg, BinaryType binaryType ) { - // TODO: Implement me - ProjMaker::_generate_standard_configuration ( module, cfg, binaryType ); + fprintf ( OUT, "\t\t\r\n", cfg.name.c_str() ); + fprintf ( OUT, "\t\t%s\r\n", cfg.name.c_str() ); + fprintf ( OUT, "\t\tWin32\r\n" ); + fprintf ( OUT, "\t\r\n" ); } void diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 8d158a41832..510203b068f 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -68,7 +68,7 @@ extern char cBadSep; #define DEF_SBAD_SEP "\\" #endif -#define MS_VS_DEF_VERSION "8.00" +#define MS_VS_DEF_VERSION "9.00" class XmlNode; class Directory;