diff --git a/reactos/tools/rbuild/backend/msvc/msvc.cpp b/reactos/tools/rbuild/backend/msvc/msvc.cpp index 418ad69547b..29827012cd6 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.cpp +++ b/reactos/tools/rbuild/backend/msvc/msvc.cpp @@ -68,9 +68,9 @@ void MSVCBackend::Process() //string filename_rules = "gccasm.rules"; if ( configuration.VSProjectVersion == "6.00" ) - filename_sln += ".dsw"; + filename_sln += "_auto.dsw"; else { - filename_sln += ".sln"; + filename_sln += "_auto.sln"; //m_rulesFile = fopen ( filename_rules.c_str(), "wb" ); //if ( m_rulesFile ) @@ -109,9 +109,9 @@ void MSVCBackend::ProcessModules() module.guid = _gen_guid(); if (configuration.VSProjectVersion == "6.00") - this->_generate_dsp ( module ); + _generate_dsp ( module ); else - this->_generate_vcproj ( module ); + _generate_vcproj ( module ); /*for(size_t k = 0; k < module.non_if_data.files.size(); k++) diff --git a/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp b/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp index 87cbc46ab58..adaeb804e62 100644 --- a/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp @@ -23,6 +23,7 @@ #include #include +#include #include @@ -30,6 +31,9 @@ using std::string; using std::vector; +using std::set; + +typedef set StringSet; #ifdef OUT #undef OUT @@ -79,13 +83,14 @@ MSVCBackend::_generate_dsp ( const Module& module ) // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'? string dsp_path = module.GetBasePath(); - vector c_srcs, source_files, resource_files, includes, libraries, defines; + vector c_srcs, source_files, resource_files, includes, libraries; + StringSet common_defines; vector ifs_list; ifs_list.push_back ( &module.project.non_if_data ); ifs_list.push_back ( &module.non_if_data ); // this is a define in MinGW w32api, but not Microsoft's headers - defines.push_back ( "STDCALL=__stdcall" ); + common_defines.insert ( "STDCALL=__stdcall" ); while ( ifs_list.size() ) { @@ -132,9 +137,9 @@ MSVCBackend::_generate_dsp ( const Module& module ) for ( i = 0; i < defs.size(); i++ ) { if ( defs[i]->value[0] ) - defines.push_back ( defs[i]->name + "=" + defs[i]->value ); + common_defines.insert( defs[i]->name + "=" + defs[i]->value ); else - defines.push_back ( defs[i]->name ); + common_defines.insert( defs[i]->name ); } } // TODO FIXME - we don't include header files in our build system @@ -318,44 +323,46 @@ MSVCBackend::_generate_dsp ( const Module& module ) if ( dll ) fprintf ( OUT, "# PROP Ignore_Export_Lib 0\r\n" ); fprintf ( OUT, "# PROP Target_Dir \"\"\r\n" ); + StringSet defines = common_defines; + if ( debug ) { - defines.push_back ( "_DEBUG" ); + defines.insert ( "_DEBUG" ); if ( lib || exe ) { fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" ); - defines.push_back ( "_LIB" ); + defines.insert ( "_LIB" ); } else { fprintf ( OUT, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" ); - defines.push_back ( "_WINDOWS" ); - defines.push_back ( "_USRDLL" ); + defines.insert ( "_WINDOWS" ); + defines.insert ( "_USRDLL" ); // TODO FIXME - wine hack? - //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" ); + //defines.insert ( string("\U") + module.name + "\E_EXPORTS" ); } } else { - defines.push_back ( "NDEBUG" ); + defines.insert ( "NDEBUG" ); if ( lib || exe ) { fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /GX /O2" ); - defines.push_back ( "_LIB" ); + defines.insert ( "_LIB" ); } else { fprintf ( OUT, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" ); - defines.push_back ( "_WINDOWS" ); - defines.push_back ( "_USRDLL" ); + defines.insert ( "_WINDOWS" ); + defines.insert ( "_USRDLL" ); // TODO FIXME - wine hack? - //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" ); + //defines.insert ( string("\U") + module.name + "\E_EXPORTS" ); } } - for ( i = 0; i < defines.size(); i++ ) + for ( StringSet::const_iterator it1=defines.begin(); it1!=defines.end(); it1++ ) { - fprintf ( OUT, " /D \"%s\"", defines[i].c_str() ); + fprintf ( OUT, " /D \"%s\"", it1->c_str() ); } if ( lib || exe ) fprintf ( OUT, " /YX" ); fprintf ( OUT, " /FD" ); @@ -367,33 +374,32 @@ MSVCBackend::_generate_dsp ( const Module& module ) fprintf ( OUT, " /c" ); fprintf ( OUT, "\r\n" ); - vector defines2 = defines; if ( debug ) { - defines2.push_back ( "_DEBUG" ); + defines.insert ( "_DEBUG" ); if(lib) { fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" ); - defines2.push_back ( "_LIB" ); + defines.insert ( "_LIB" ); } else { fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" ); - defines2.push_back ( "_USRDLL" ); + defines.insert ( "_USRDLL" ); } } else { - defines2.push_back ( "NDEBUG" ); + defines.insert ( "NDEBUG" ); if(lib) { fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" ); - defines2.push_back ( "_LIB" ); + defines.insert ( "_LIB" ); } else { fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" ); - defines2.push_back ( "_USRDLL" ); + defines.insert ( "_USRDLL" ); } } @@ -401,16 +407,16 @@ MSVCBackend::_generate_dsp ( const Module& module ) if ( wine ) { // TODO FIXME - wine hack? - //defines2.push_back ( string("_\U") + module.name + "\E_" ); + //defines.insert ( string("_\U") + module.name + "\E_" ); // TODO FIXME - wine hack? /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ ) - defines2.push_back ( "__WINESRC__" );*/ + defines.insert ( "__WINESRC__" );*/ if ( msvc_headers ) - defines2.push_back ( "__WINE_USE_NATIVE_HEADERS" ); + defines.insert ( "__WINE_USE_NATIVE_HEADERS" ); string output_dir2 = Replace(output_dir,"\\","\\\\"); - defines2.push_back ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir.c_str()) ); - defines2.push_back ( "__i386__" ); - defines2.push_back ( "_X86_" ); + defines.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir.c_str()) ); + defines.insert ( "__i386__" ); + defines.insert ( "_X86_" ); // TODO FIXME - wine hacks? /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) { @@ -445,9 +451,9 @@ MSVCBackend::_generate_dsp ( const Module& module ) } fprintf ( OUT, " /I \".\"" ); - for ( i = 0; i < defines2.size(); i++ ) + for ( StringSet::const_iterator it2=defines.begin(); it2!=defines.end(); it2++ ) { - const string& define = defines2[i]; + const string& define = *it2; if ( strpbrk ( define.c_str(), "[\\\"]" ) ) { fprintf ( OUT, " /D \"%s\"", define.c_str() ); @@ -486,9 +492,9 @@ MSVCBackend::_generate_dsp ( const Module& module ) } } - for ( i = 0; i < defines.size(); i++ ) + for ( StringSet::const_iterator it3=defines.begin(); it3!=defines.end(); it3++ ) { - fprintf ( OUT, " /D \"%s\"", defines[i].c_str() ); + fprintf ( OUT, " /D \"%s\"", it3->c_str() ); } fprintf ( OUT, " /d \"_DEBUG\"\r\n" ); } @@ -508,9 +514,9 @@ MSVCBackend::_generate_dsp ( const Module& module ) fprintf ( OUT, " /i \"%s\"", includes[i].c_str() ); } - for ( i = 0; i < defines.size(); i++ ) + for ( StringSet::const_iterator it4=defines.begin(); it4!=defines.end(); it4++ ) { - fprintf ( OUT, " /D \"%s\"", defines[i].c_str() ); + fprintf ( OUT, " /D \"%s\"", it4->c_str() ); } diff --git a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp index 3140229860c..10551d7209a 100644 --- a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp @@ -23,6 +23,7 @@ #include #include +#include #include @@ -30,6 +31,9 @@ using std::string; using std::vector; +using std::set; + +typedef set StringSet; #ifdef OUT #undef OUT @@ -91,16 +95,17 @@ 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, defines; + vector source_files, resource_files, includes, 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 - defines.push_back ( "_CRT_SECURE_NO_DEPRECATE" ); - defines.push_back ( "_CRT_NON_CONFORMING_SWPRINTFS" ); + 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 - defines.push_back ( "STDCALL=__stdcall" ); + common_defines.insert ( "STDCALL=__stdcall" ); string baseaddr; @@ -158,9 +163,9 @@ MSVCBackend::_generate_vcproj ( const Module& module ) for ( i = 0; i < defs.size(); i++ ) { if ( defs[i]->value[0] ) - defines.push_back ( defs[i]->name + "=" + defs[i]->value ); + common_defines.insert( defs[i]->name + "=" + defs[i]->value ); else - defines.push_back ( defs[i]->name ); + common_defines.insert( defs[i]->name ); } for ( i = 0; i < data.properties.size(); i++ ) { @@ -278,39 +283,45 @@ MSVCBackend::_generate_vcproj ( const Module& module ) } fprintf ( OUT, "\"\r\n " ); + StringSet defines = common_defines; + if ( debug ) { - defines.push_back ( "_DEBUG" ); + defines.insert ( "_DEBUG" ); } else { - defines.push_back ( "NDEBUG" ); + defines.insert ( "NDEBUG" ); } if ( lib || exe ) { - defines.push_back ( "_LIB" ); + defines.insert ( "_LIB" ); } else { - defines.push_back ( "_WINDOWS" ); - defines.push_back ( "_USRDLL" ); + defines.insert ( "_WINDOWS" ); + defines.insert ( "_USRDLL" ); } fprintf ( OUT, "\t\t\t\tPreprocessorDefinitions=\"" ); - for ( i = 0; i < defines.size(); i++ ) + for ( StringSet::iterator it1=defines.begin(); it1!=defines.end(); it1++ ) { if ( i > 0 ) fprintf ( OUT, ";" ); - defines[i] = _replace_str(defines[i], "\"","""); - fprintf ( OUT, "%s", defines[i].c_str() ); + string unescaped = *it1; + defines.erase(unescaped); + const string& escaped = _replace_str(unescaped, "\"","""); + + defines.insert(escaped); + fprintf ( OUT, "%s", escaped.c_str() ); } fprintf ( OUT, "\"\r\n" ); fprintf ( OUT, "\t\t\t\tMinimalRebuild=\"%s\"\r\n", speed ? "FALSE" : "TRUE" ); fprintf ( OUT, "\t\t\t\tBasicRuntimeChecks=\"%s\"\r\n", sys ? 0 : (debug ? "3" : "0") ); - fprintf ( OUT, "\t\t\t\tRuntimeLibrary=\"5\"\r\n" ); + fprintf ( OUT, "\t\t\t\tRuntimeLibrary=\"%d\"\r\n", debug? 1: 5 ); // 1=/MTd 5=/MT fprintf ( OUT, "\t\t\t\tBufferSecurityCheck=\"%s\"\r\n", sys ? "FALSE" : (debug ? "TRUE" : "FALSE" )); fprintf ( OUT, "\t\t\t\tEnableFunctionLevelLinking=\"%s\"\r\n", debug ? "TRUE" : "FALSE" ); @@ -337,14 +348,13 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, "\t\t\t\tStringPooling=\"true\"\r\n" ); } - fprintf ( OUT, "\t\t\t\tEnablePREfast=\"%s\"\r\n", debug ? "TRUE" : "FALSE"); fprintf ( OUT, "\t\t\t\tDisableSpecificWarnings=\"4201;4127;4214\"\r\n" ); fprintf ( OUT, "\t\t\t\tWarningLevel=\"%s\"\r\n", speed ? "0" : "4" ); fprintf ( OUT, "\t\t\t\tDetect64BitPortabilityProblems=\"%s\"\r\n", speed ? "FALSE" : "TRUE"); if ( !module.cplusplus ) fprintf ( OUT, "\t\t\t\tCompileAs=\"1\"\r\n" ); - fprintf ( OUT, "\t\t\t\tCallingConvention=\"%d\"\r\n", (sys || (exe && module.type == Kernel)) ? 2: 1); - fprintf ( OUT, "\t\t\t\tDebugInformationFormat=\"%s\"/>\r\n", speed ? "0" : "4"); + fprintf ( OUT, "\t\t\t\tCallingConvention=\"%d\"\r\n", (sys || (exe && module.type == Kernel)) ? 2: 0); // 2=__stdcall 0=__cdecl + fprintf ( OUT, "\t\t\t\tDebugInformationFormat=\"%s\"/>\r\n", speed ? "0" : release ? "3": "4"); // 3=/Zi 4=ZI fprintf ( OUT, "\t\t\t\r\n" ); @@ -382,6 +392,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"\r\n", module.name.c_str(), module_type.c_str() ); fprintf ( OUT, "\t\t\t\tLinkIncremental=\"%d\"\r\n", debug ? 2 : 1 ); fprintf ( OUT, "\t\t\t\tGenerateDebugInformation=\"%s\"\r\n", speed ? "FALSE" : "TRUE" ); + fprintf ( OUT, "\t\t\t\tLinkTimeCodeGeneration=\"%d\"\r\n", release? 1: 0); // whole program optimization if ( debug ) fprintf ( OUT, "\t\t\t\tProgramDatabaseFile=\"$(OutDir)/%s.pdb\"\r\n", module.name.c_str() ); diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index eb8f69c9131..181defedcb0 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -244,7 +244,7 @@ Project::ReadXml () { node = head->subElements[i]; string path; - this->ProcessXML ( path ); + ProcessXML ( path ); return; } } diff --git a/reactos/tools/rbuild/rbuild.cpp b/reactos/tools/rbuild/rbuild.cpp index ff098db8ee9..447ff4f94d1 100644 --- a/reactos/tools/rbuild/rbuild.cpp +++ b/reactos/tools/rbuild/rbuild.cpp @@ -229,7 +229,7 @@ main ( int argc, char** argv ) printf ( " -v Be verbose.\n" ); printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" ); printf ( " needed anymore.\n" ); - printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" ); + printf ( " -r{file.rbuild} Name of the root rbuild file. Default is ReactOS.rbuild.\n" ); printf ( " -dd Disable automatic dependencies.\n" ); printf ( " -dm{module} Check only automatic dependencies for this module.\n" ); printf ( " -ud Disable multiple source files per compilation unit.\n" );