From d3f58e5415fd473e15b6499328c246da67e5e6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Tue, 13 Jun 2006 21:23:25 +0000 Subject: [PATCH] - Add a MSVCConfiguration class, to keep trace of parameters instead of parsing each time the configuration name - When building with MSVC headers, win32api and Wine directories are omitted and some defines are added svn path=/trunk/; revision=22343 --- reactos/tools/rbuild/backend/msvc/msvc.h | 25 +++ .../tools/rbuild/backend/msvc/vcprojmaker.cpp | 159 ++++++++++-------- 2 files changed, 117 insertions(+), 67 deletions(-) diff --git a/reactos/tools/rbuild/backend/msvc/msvc.h b/reactos/tools/rbuild/backend/msvc/msvc.h index af2b47626ed..bf906298748 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.h +++ b/reactos/tools/rbuild/backend/msvc/msvc.h @@ -32,6 +32,31 @@ class FileUnit std::string folder; }; +enum OptimizationType +{ + Debug, + Release, + Speed +}; + +enum HeadersType +{ + MSVCHeaders, + WineHeaders +}; + +class MSVCConfiguration +{ + public: + MSVCConfiguration(const OptimizationType optimization, + const HeadersType headers = MSVCHeaders, + const std::string &name = ""); + virtual ~MSVCConfiguration() {} + std::string name; + OptimizationType optimization; + HeadersType headers; +}; + class MSVCBackend : public Backend { public: diff --git a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp index 1b332a173a8..504c4920d86 100644 --- a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2002 Patrik Stridvall * Copyright (C) 2005 Royce Mitchell III + * Copyright (C) 2006 Hervé Poussineau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,12 +40,34 @@ typedef set StringSet; #undef OUT #endif//OUT +MSVCConfiguration::MSVCConfiguration ( const OptimizationType optimization, const HeadersType headers, const std::string &name ) +{ + this->optimization = optimization; + this->headers = headers; + if ( name != "" ) + this->name = name; + else + { + std::string headers_name; + if ( headers == MSVCHeaders ) + headers_name = ""; + else + headers_name = " - Wine headers"; + if ( optimization == Debug ) + this->name = "Debug" + headers_name; + else if ( optimization == Release ) + this->name = "Release" + headers_name; + else if ( optimization == Speed ) + this->name = "Speed" + headers_name; + else + this->name = "Unknown" + headers_name; + } +} + void MSVCBackend::_generate_vcproj ( const Module& module ) { size_t i; - // TODO FIXME wine hack? - //const bool wine = false; string vcproj_file = VcprojFileName(module); printf ( "Creating MSVC.NET project: '%s'\n", vcproj_file.c_str() ); @@ -95,18 +118,12 @@ MSVCBackend::_generate_vcproj ( const Module& module ) //$output->progress("$dsp_file (file $progress_current of $progress_max)"); string vcproj_path = module.GetBasePath(); - vector source_files, resource_files, includes, libraries; + vector source_files, resource_files, includes, includes_wine, libraries; StringSet common_defines; vector ifs_list; ifs_list.push_back ( &module.project.non_if_data ); ifs_list.push_back ( &module.non_if_data ); - // MinGW doesn't have a safe-string library yet - common_defines.insert ( "_CRT_SECURE_NO_DEPRECATE" ); - common_defines.insert ( "_CRT_NON_CONFORMING_SWPRINTFS" ); - // this is a define in MinGW w32api, but not Microsoft's headers - common_defines.insert ( "STDCALL=__stdcall" ); - string baseaddr; while ( ifs_list.size() ) @@ -136,24 +153,22 @@ MSVCBackend::_generate_vcproj ( const Module& module ) const vector& incs = data.includes; for ( i = 0; i < incs.size(); i++ ) { - // explicitly omit win32api directories - if ( !strncmp(incs[i]->directory.c_str(), "include\\ddk", 11 ) ) - continue; - - if ( !strncmp(incs[i]->directory.c_str(), "include\\crt", 11 ) ) - continue; - - if ( !strncmp(incs[i]->directory.c_str(), "include\\GL", 10 ) ) - continue; - - // explicitly omit include/wine directories - if ( !strncmp(incs[i]->directory.c_str(), "include\\reactos\\wine", 20 ) ) - continue; - string path = Path::RelativeFromDirectory ( incs[i]->directory, module.GetBasePath() ); - includes.push_back ( path ); + + // add to another list win32api and include/wine directories + if ( !strncmp(incs[i]->directory.c_str(), "include\\ddk", 11 ) || + !strncmp(incs[i]->directory.c_str(), "include\\crt", 11 ) || + !strncmp(incs[i]->directory.c_str(), "include\\GL", 10 ) || + !strncmp(incs[i]->directory.c_str(), "include\\reactos\\wine", 20 ) ) + { + includes_wine.push_back ( path ); + } + else + { + includes.push_back ( path ); + } } const vector& libs = data.libraries; for ( i = 0; i < libs.size(); i++ ) @@ -179,40 +194,22 @@ MSVCBackend::_generate_vcproj ( const Module& module ) vector header_files; - bool no_cpp = true; + // TODO FIXME wine hack? bool no_msvc_headers = true; - std::vector cfgs; + std::vector cfgs; - cfgs.push_back ( "Debug" ); - cfgs.push_back ( "Release" ); - cfgs.push_back ( "Speed" ); - - if (!no_cpp) - { - std::vector _cfgs; - for ( i = 0; i < cfgs.size(); i++ ) - { - _cfgs.push_back ( cfgs[i] + " C" ); - _cfgs.push_back ( cfgs[i] + " C++" ); - } - cfgs.resize(0); - cfgs = _cfgs; - } + cfgs.push_back ( new MSVCConfiguration( Debug )); + cfgs.push_back ( new MSVCConfiguration( Release )); + cfgs.push_back ( new MSVCConfiguration( Speed )); if (!no_msvc_headers) { - std::vector _cfgs; - for ( i = 0; i < cfgs.size(); i++ ) - { - _cfgs.push_back ( cfgs[i] + " MSVC Headers" ); - _cfgs.push_back ( cfgs[i] + " Wine Headers" ); - } - cfgs.resize(0); - cfgs = _cfgs; + cfgs.push_back ( new MSVCConfiguration( Debug, WineHeaders )); + cfgs.push_back ( new MSVCConfiguration( Release, WineHeaders )); + cfgs.push_back ( new MSVCConfiguration( Speed, WineHeaders )); } - string default_cfg = cfgs.back(); string include_string; fprintf ( OUT, "\r\n" ); @@ -248,18 +245,16 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, "\t\r\n" ); for ( size_t icfg = 0; icfg < cfgs.size(); icfg++ ) { - std::string& cfg = cfgs[icfg]; + const MSVCConfiguration& cfg = *cfgs[icfg]; - bool debug = strstr ( cfg.c_str(), "Debug" ) != NULL; - bool speed = strstr ( cfg.c_str(), "Speed" ) != NULL; - bool release = (!debug && !speed ); - - //bool msvc_headers = ( 0 != strstr ( cfg.c_str(), "MSVC Headers" ) ); + bool debug = ( cfg.optimization == Debug ); + bool release = ( cfg.optimization == Release ); + bool speed = ( cfg.optimization == Speed ); fprintf ( OUT, "\t\t\r\n" ); @@ -272,7 +267,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, "./;" ); for ( i = 0; i < includes.size(); i++ ) { - const string& include = includes[i]; + const std::string& include = includes[i]; if ( strcmp ( include.c_str(), "." ) ) { if ( multiple_includes ) @@ -283,6 +278,18 @@ MSVCBackend::_generate_vcproj ( const Module& module ) multiple_includes = true; } } + if ( cfg.headers == WineHeaders ) + { + for ( i = 0; i < includes_wine.size(); i++ ) + { + const std::string& include = includes_wine[i]; + if ( multiple_includes ) + fprintf ( OUT, ";" ); + fprintf ( OUT, "%s", include.c_str() ); + //include_string += " /I " + include; + multiple_includes = true; + } + } fprintf ( OUT, "\"\r\n" ); StringSet defines = common_defines; @@ -296,6 +303,15 @@ MSVCBackend::_generate_vcproj ( const Module& module ) defines.insert ( "NDEBUG" ); } + if ( cfg.headers == MSVCHeaders ) + { + // this is a define in MinGW w32api, but not Microsoft's headers + defines.insert ( "STDCALL=__stdcall" ); + // MinGW doesn't have a safe-string library yet + defines.insert ( "_CRT_SECURE_NO_DEPRECATE" ); + defines.insert ( "_CRT_NON_CONFORMING_SWPRINTFS" ); + } + if ( lib || exe ) { defines.insert ( "_LIB" ); @@ -390,9 +406,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, ";" ); string libpath = libraries[i].c_str(); - libpath.replace (libpath.find("---"), - 3, - cfg); + libpath.replace (libpath.find("---"), 3, cfg.name); libpath = libpath.substr (0, libpath.find_last_of ("\\") ); fprintf ( OUT, "%s", libpath.c_str() ); } @@ -457,7 +471,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, "./;" ); for ( i = 0; i < includes.size(); i++ ) { - const string& include = includes[i]; + const std::string& include = includes[i]; if ( strcmp ( include.c_str(), "." ) ) { if ( multiple_includes ) @@ -466,6 +480,17 @@ MSVCBackend::_generate_vcproj ( const Module& module ) multiple_includes = true; } } + if ( cfg.headers == WineHeaders ) + { + for ( i = 0; i < includes_wine.size(); i++ ) + { + const std::string& include = includes_wine[i]; + if ( multiple_includes ) + fprintf ( OUT, ";" ); + fprintf ( OUT, "%s", include.c_str() ); + multiple_includes = true; + } + } fprintf ( OUT, "\"/>\r\n " ); fprintf ( OUT, "\t\t\t\r\n" ); fprintf ( OUT, "\t\t\t\t\t\r\n" ); fprintf ( OUT, "\t\t\t\t\t