more efficient detection of C++ modules, fixed bug in C++ pch support, always clean pch files, even if pch not being used
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-10 20:07:17 UTC (rev 13916)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-10 20:34:08 UTC (rev 13917)
@@ -1056,24 +1056,27 @@
 	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 @@
 	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;
 }
 
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-03-10 20:07:17 UTC (rev 13916)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-03-10 20:34:08 UTC (rev 13917)
@@ -91,7 +91,8 @@
 	  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-<module> node" );
@@ -185,6 +186,17 @@
 					e.location,
 					"attribute 'first' of <file> 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 );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-03-10 20:07:17 UTC (rev 13916)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-03-10 20:34:08 UTC (rev 13917)
@@ -152,6 +152,7 @@
 	std::vector<CompilerFlag*> compilerFlags;
 	std::vector<LinkerFlag*> linkerFlags;
 	PchFile* pch;
+	bool cplusplus;
 
 	Module ( const Project& project,
 	         const XMLElement& moduleNode,