From 107eec449d209ac0a5458c59480859b2d5f8df5f Mon Sep 17 00:00:00 2001 From: Royce Mitchell III Date: Thu, 10 Mar 2005 20:34:08 +0000 Subject: [PATCH] more efficient detection of C++ modules, fixed bug in C++ pch support, always clean pch files, even if pch not being used svn path=/branches/xmlbuildsystem/; revision=13917 --- .../rbuild/backend/mingw/modulehandler.cpp | 41 ++++++++----------- reactos/tools/rbuild/module.cpp | 14 ++++++- reactos/tools/rbuild/rbuild.h | 1 + 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 76560345ca2..90bd48ef394 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -1056,24 +1056,27 @@ MingwModuleHandler::GenerateObjectFileTargets ( const string& windresflagsMacro, string_list& clean_files ) const { - if ( module.pch && use_pch ) + if ( module.pch ) { const string& pch_file = module.pch->header; string gch_file = pch_file + ".gch"; CLEAN_FILE(gch_file); - fprintf ( - fMakefile, - "%s: %s\n", - gch_file.c_str(), - pch_file.c_str() ); - fprintf ( fMakefile, "\t$(ECHO_PCH)\n" ); - fprintf ( - fMakefile, - "\t%s -c %s -o %s %s\n\n", - cc.c_str(), - pch_file.c_str(), - gch_file.c_str(), - cflagsMacro.c_str() ); + if ( use_pch ) + { + fprintf ( + fMakefile, + "%s: %s\n", + gch_file.c_str(), + pch_file.c_str() ); + fprintf ( fMakefile, "\t$(ECHO_PCH)\n" ); + fprintf ( + fMakefile, + "\t%s -o %s %s -g %s\n\n", + ( module.cplusplus ? cppc.c_str() : cc.c_str() ), + gch_file.c_str(), + cflagsMacro.c_str(), + pch_file.c_str() ); + } } GenerateObjectFileTargets ( module, @@ -1456,18 +1459,10 @@ MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const return dependencies; } -// TODO FIXME - check for C++ extensions when parsing XML, and set a -// bool in the Module class bool MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const { - if ( module.HasFileWithExtension ( module.non_if_data, ".cc" ) ) - return true; - if ( module.HasFileWithExtension ( module.non_if_data, ".cxx" ) ) - return true; - if ( module.HasFileWithExtension ( module.non_if_data, ".cpp" ) ) - return true; - return false; + return module.cplusplus; } diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 2425f1d8494..0ffae73d17e 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -91,7 +91,8 @@ Module::Module ( const Project& project, node (moduleNode), importLibrary (NULL), bootstrap (NULL), - pch (NULL) + pch (NULL), + cplusplus (false) { if ( node.name != "module" ) throw Exception ( "internal tool error: Module created with non- node" ); @@ -185,6 +186,17 @@ Module::ProcessXMLSubElement ( const XMLElement& e, e.location, "attribute 'first' of element can only be 'true' or 'false'" ); } + if ( !cplusplus ) + { + // check for c++ file + string ext = GetExtension ( e.value ); + if ( !stricmp ( ext.c_str(), ".cpp" ) ) + cplusplus = true; + else if ( !stricmp ( ext.c_str(), ".cc" ) ) + cplusplus = true; + else if ( !stricmp ( ext.c_str(), ".cxx" ) ) + cplusplus = true; + } File* pFile = new File ( FixSeparator ( path + CSEP + e.value ), first ); if ( pIf ) pIf->data.files.push_back ( pFile ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 08112e87c8d..b541363b9dc 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -152,6 +152,7 @@ public: std::vector compilerFlags; std::vector linkerFlags; PchFile* pch; + bool cplusplus; Module ( const Project& project, const XMLElement& moduleNode,