simplified <if> handling ( and fixed several bugs, too )
cleaned up devcpp backend to compile with these changes
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/automaticdependency.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/automaticdependency.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/automaticdependency.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/automaticdependency.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -281,8 +281,9 @@
 void
 AutomaticDependency::ProcessModule ( Module& module )
 {
-	for ( size_t i = 0; i < module.files.size (); i++ )
-		ProcessFile ( module, *module.files[i] );
+	const vector<File*>& files = module.non_if_data.files;
+	for ( size_t i = 0; i < files.size (); i++ )
+		ProcessFile ( module, *files[i] );
 }
 
 void
@@ -330,37 +331,30 @@
 	                                      bool includeNext,
 	                                      string& resolvedFilename )
 {
-	size_t i;
-	for ( i = 0; i < module.includes.size (); i++ )
+	size_t i, j;
+	const vector<Include*>* pincludes;
+	for ( i = 0; i < 2; i++ )
 	{
-		Include* include = module.includes[i];
-		if ( LocateIncludedFile ( include->directory,
-		                          includedFilename,
-		                          resolvedFilename ) )
+		if ( !i )
+			pincludes = &module.non_if_data.includes;
+		else
+			pincludes = &module.project.non_if_data.includes;
+		const vector<Include*>& includes = *pincludes;
+		for ( j = 0; j < includes.size (); j++ )
 		{
-			if ( includeNext && stricmp ( resolvedFilename.c_str (),
-			                              sourceFile->filename.c_str () ) == 0 )
-				continue;
-			return true;
+			Include& include = *includes[j];
+			if ( LocateIncludedFile ( include.directory,
+									  includedFilename,
+									  resolvedFilename ) )
+			{
+				if ( includeNext && stricmp ( resolvedFilename.c_str (),
+											  sourceFile->filename.c_str () ) == 0 )
+					continue;
+				return true;
+			}
 		}
 	}
 
-	/* FIXME: Ifs */
-
-	for ( i = 0; i < module.project.includes.size (); i++ )
-	{
-		Include* include = module.project.includes[i];
-		if ( LocateIncludedFile ( include->directory,
-		                          includedFilename,
-		                          resolvedFilename ) )
-		{
-			if ( includeNext && stricmp ( resolvedFilename.c_str (),
-			                              sourceFile->filename.c_str () ) == 0 )
-				continue;
-			return true;
-		}
-	}
-
 	resolvedFilename = "";
 	return false;
 }
@@ -398,10 +392,11 @@
 	struct utimbuf timebuf;
 	for ( size_t mi = 0; mi < project.modules.size (); mi++ )
 	{
-		Module& module = *project.modules[mi];
-		for ( size_t fi = 0; fi < module.files.size (); fi++ )
+		const vector<File*>& files = project.modules[mi]->non_if_data.files;
+		//Module& module = *project.modules[mi];
+		for ( size_t fi = 0; fi < files.size (); fi++ )
 		{
-			File& file = *module.files[fi];
+			File& file = *files[fi];
 			string normalizedFilename = NormalizeFilename ( file.name );
 
 			SourceFile* sourceFile = RetrieveFromCache ( normalizedFilename );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -16,6 +16,10 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
+
+#ifdef _MSC_VER
+#pragma warning ( disable : 4786 )
+#endif//_MSC_VER
 
 #include <iostream>
 #include <fstream>
@@ -122,9 +126,9 @@
 	{
 		Module &module = *ProjectNode.modules[i];
 
-		for(size_t k = 0; k < module.files.size(); k++)
+		for(size_t k = 0; k < module.non_if_data.files.size(); k++)
 		{
-			File &file = *module.files[k];
+			File &file = *module.non_if_data.files[k];
 			
 			ProcessFile(file.name);
 		}

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -67,8 +67,7 @@
 
 void
 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation,
-                                           const vector<Include*>& includes,
-                                           const vector<Define*>& defines ) const
+                                           IfableData& data ) const
 {
 	size_t i;
 
@@ -76,17 +75,17 @@
 		fMakefile,
 		"PROJECT_CFLAGS %s",
 		assignmentOperation );
-	for ( i = 0; i < includes.size(); i++ )
+	for ( i = 0; i < data.includes.size(); i++ )
 	{
 		fprintf (
 			fMakefile,
 			" -I%s",
-			includes[i]->directory.c_str() );
+			data.includes[i]->directory.c_str() );
 	}
 
-	for ( i = 0; i < defines.size(); i++ )
+	for ( i = 0; i < data.defines.size(); i++ )
 	{
-		Define& d = *defines[i];
+		Define& d = *data.defines[i];
 		fprintf (
 			fMakefile,
 			" -D%s",
@@ -103,32 +102,30 @@
 void
 MingwBackend::GenerateGlobalCFlagsAndProperties (
 	const char* assignmentOperation,
-	const vector<Property*>& properties,
-	const vector<Include*>& includes,
-	const vector<Define*>& defines,
-	const vector<If*>& ifs ) const
+	IfableData& data ) const
 {
 	size_t i;
 
-	for ( i = 0; i < properties.size(); i++ )
+	for ( i = 0; i < data.properties.size(); i++ )
 	{
-		Property& prop = *properties[i];
+		Property& prop = *data.properties[i];
 		fprintf ( fMakefile, "%s := %s\n",
 			prop.name.c_str(),
 			prop.value.c_str() );
 	}
 
-	if ( includes.size() || defines.size() )
+	if ( data.includes.size() || data.defines.size() )
 	{
 		GenerateProjectCFlagsMacro ( assignmentOperation,
-                                     includes,
-                                     defines );
+                                     data );
 	}
 
-	for ( i = 0; i < ifs.size(); i++ )
+	for ( i = 0; i < data.ifs.size(); i++ )
 	{
-		If& rIf = *ifs[i];
-		if ( rIf.defines.size() || rIf.includes.size() || rIf.ifs.size() )
+		If& rIf = *data.ifs[i];
+		if ( rIf.data.defines.size()
+			|| rIf.data.includes.size()
+			|| rIf.data.ifs.size() )
 		{
 			fprintf (
 				fMakefile,
@@ -137,10 +134,7 @@
 				rIf.value.c_str() );
 			GenerateGlobalCFlagsAndProperties (
 				"+=",
-				rIf.properties,
-				rIf.includes,
-				rIf.defines,
-				rIf.ifs );
+				rIf.data );
 			fprintf (
 				fMakefile,
 				"endif\n\n" );
@@ -175,10 +169,7 @@
 	fprintf ( fMakefile, "\n" );
 	GenerateGlobalCFlagsAndProperties (
 		"=",
-		ProjectNode.properties,
-		ProjectNode.includes,
-		ProjectNode.defines,
-		ProjectNode.ifs );
+		ProjectNode.non_if_data );
 	fprintf ( fMakefile, "PROJECT_RCFLAGS = $(PROJECT_CFLAGS)\n" );
 	fprintf ( fMakefile, "PROJECT_LFLAGS = %s\n",
 	          GenerateProjectLFLAGS ().c_str () );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-03-09 22:29:18 UTC (rev 13901)
@@ -16,13 +16,9 @@
 	void CloseMakefile () const;
 	void GenerateHeader () const;
 	void GenerateProjectCFlagsMacro ( const char* assignmentOperation,
-	                                  const std::vector<Include*>& includes,
-	                                  const std::vector<Define*>& defines ) const;
+	                                  IfableData& data ) const;
 	void GenerateGlobalCFlagsAndProperties ( const char* op,
-	                                         const std::vector<Property*>& properties,
-	                                         const std::vector<Include*>& includes,
-	                                         const std::vector<Define*>& defines,
-	                                         const std::vector<If*>& ifs ) const;
+	                                         IfableData& data ) const;
 	std::string GenerateProjectLFLAGS () const;
 	void GenerateDirectoryTargets () const;
 	void GenerateGlobalVariables () const;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -179,22 +179,29 @@
 	size_t i;
 
 	string sourceFilenames ( "" );
-	for ( i = 0; i < module.files.size (); i++ )
+	const vector<File*>& files = module.non_if_data.files;
+	for ( i = 0; i < files.size (); i++ )
 	{
-		if ( includeGeneratedFiles || !IsGeneratedFile ( *module.files[i] ) )
-			sourceFilenames += " " + GetActualSourceFilename ( module.files[i]->name );
+		if ( includeGeneratedFiles || !IsGeneratedFile ( *files[i] ) )
+			sourceFilenames += " " + GetActualSourceFilename ( files[i]->name );
 	}
-	vector<If*> ifs = module.ifs;
-	for ( i = 0; i < ifs.size (); i++ )
+	// intentionally make a copy so that we can append more work in
+	// the middle of processing without having to go recursive
+	vector<If*> v = module.non_if_data.ifs;
+	for ( i = 0; i < v.size (); i++ )
 	{
 		size_t j;
-		If& rIf = *ifs[i];
-		for ( j = 0; j < rIf.ifs.size (); j++ )
-			ifs.push_back ( rIf.ifs[j] );
-		for ( j = 0; j < rIf.files.size (); j++ )
+		If& rIf = *v[i];
+		// check for sub-ifs to add to list
+		const vector<If*>& ifs = rIf.data.ifs;
+		for ( j = 0; j < ifs.size (); j++ )
+			v.push_back ( ifs[j] );
+		const vector<File*>& files = rIf.data.files;
+		for ( j = 0; j < files.size (); j++ )
 		{
-			if ( includeGeneratedFiles || !IsGeneratedFile ( *rIf.files[j] ) )
-				sourceFilenames += " " + GetActualSourceFilename ( rIf.files[j]->name );
+			File& file = *files[j];
+			if ( includeGeneratedFiles || !IsGeneratedFile ( file ) )
+				sourceFilenames += " " + GetActualSourceFilename ( file.name );
 		}
 	}
 	return sourceFilenames;
@@ -250,15 +257,16 @@
 string
 MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
 {
-	if ( module.files.size () == 0 )
+	const vector<File*>& files = module.non_if_data.files;
+	if ( files.size () == 0 )
 		return "";
 	
 	string objectFilenames ( "" );
-	for ( size_t i = 0; i < module.files.size (); i++ )
+	for ( size_t i = 0; i < files.size (); i++ )
 	{
 		if ( objectFilenames.size () > 0 )
 			objectFilenames += " ";
-		objectFilenames += PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( module.files[i]->name ) );
+		objectFilenames += PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) );
 	}
 	return objectFilenames;
 }
@@ -342,8 +350,8 @@
 string
 MingwModuleHandler::GenerateGccDefineParameters ( const Module& module ) const
 {
-	string parameters = GenerateGccDefineParametersFromVector ( module.project.defines );
-	string s = GenerateGccDefineParametersFromVector ( module.defines );
+	string parameters = GenerateGccDefineParametersFromVector ( module.project.non_if_data.defines );
+	string s = GenerateGccDefineParametersFromVector ( module.non_if_data.defines );
 	if ( s.length () > 0 )
 	{
 		parameters += " ";
@@ -381,8 +389,8 @@
 string
 MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
 {
-	string parameters = GenerateGccIncludeParametersFromVector ( module.includes );
-	string s = GenerateGccIncludeParametersFromVector ( module.project.includes );
+	string parameters = GenerateGccIncludeParametersFromVector ( module.non_if_data.includes );
+	string s = GenerateGccIncludeParametersFromVector ( module.project.non_if_data.includes );
 	if ( s.length () > 0 )
 	{
 		parameters += " ";
@@ -444,11 +452,11 @@
 }
 
 void
-MingwModuleHandler::GenerateMacro ( const char* assignmentOperation,
-                                    const string& macro,
-                                    const vector<Include*>& includes,
-                                    const vector<Define*>& defines,
-                                    const vector<CompilerFlag*>* compilerFlags ) const
+MingwModuleHandler::GenerateMacro (
+	const char* assignmentOperation,
+	const string& macro,
+	const IfableData& data,
+	const vector<CompilerFlag*>* compilerFlags ) const
 {
 	size_t i;
 
@@ -470,16 +478,16 @@
 		}
 	}
 
-	for ( i = 0; i < includes.size(); i++ )
+	for ( i = 0; i < data.includes.size(); i++ )
 	{
 		fprintf (
 			fMakefile,
 			" -I%s",
-			includes[i]->directory.c_str() );
+			data.includes[i]->directory.c_str() );
 	}
-	for ( i = 0; i < defines.size(); i++ )
+	for ( i = 0; i < data.defines.size(); i++ )
 	{
-		Define& d = *defines[i];
+		Define& d = *data.defines[i];
 		fprintf (
 			fMakefile,
 			" -D%s",
@@ -496,13 +504,9 @@
 void
 MingwModuleHandler::GenerateMacros (
 	const char* assignmentOperation,
-	const vector<File*>& files,
-	const vector<Include*>& includes,
-	const vector<Define*>& defines,
-	const vector<Library*>& libraries,
+	const IfableData& data,
 	const vector<CompilerFlag*>* compilerFlags,
 	const vector<LinkerFlag*>* linkerFlags,
-	const vector<If*>& ifs,
 	const string& cflags_macro,
 	const string& nasmflags_macro,
 	const string& windresflags_macro,
@@ -513,17 +517,15 @@
 {
 	size_t i;
 
-	if ( includes.size () > 0 || defines.size () > 0 )
+	if ( data.includes.size () > 0 || data.defines.size () > 0 )
 	{
 		GenerateMacro ( assignmentOperation,
 		                cflags_macro,
-		                includes,
-		                defines,
+		                data,
 		                compilerFlags );
 		GenerateMacro ( assignmentOperation,
 		                windresflags_macro,
-		                includes,
-		                defines,
+		                data,
 		                compilerFlags );
 	}
 	
@@ -541,9 +543,9 @@
 		}
 	}
 
-	if ( libraries.size () > 0 )
+	if ( data.libraries.size () > 0 )
 	{
-		string deps = GenerateImportLibraryDependenciesFromVector ( libraries );
+		string deps = GenerateImportLibraryDependenciesFromVector ( data.libraries );
 		if ( deps.size () > 0 )
 		{
 			fprintf (
@@ -555,16 +557,19 @@
 		}
 	}
 
+	const vector<File*>& files = data.files;
 	if ( files.size () > 0 )
 	{
 		for ( i = 0; i < files.size (); i++ )
 		{
-			if ( files[i]->first )
+			File& file = *files[i];
+			if ( file.first )
 			{
 				fprintf ( fMakefile,
 					"%s := %s $(%s)\n",
 					objs_macro.c_str(),
-					PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ).c_str (),
+					PassThruCacheDirectory (
+						MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str (),
 					objs_macro.c_str() );
 			}
 		}
@@ -575,26 +580,29 @@
 			assignmentOperation );
 		for ( i = 0; i < files.size(); i++ )
 		{
-			if ( !files[i]->first )
+			File& file = *files[i];
+			if ( !file.first )
 			{
 				fprintf (
 					fMakefile,
 					"%s%s",
 					( i%10 == 9 ? "\\\n\t" : " " ),
-					PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ).c_str () );
+					PassThruCacheDirectory (
+						MingwModuleHandler::GetObjectFilename ( file.name ) ).c_str () );
 			}
 		}
 		fprintf ( fMakefile, "\n" );
 	}
 
+	const vector<If*>& ifs = data.ifs;
 	for ( i = 0; i < ifs.size(); i++ )
 	{
 		If& rIf = *ifs[i];
-		if ( rIf.defines.size()
-			|| rIf.includes.size()
-			|| rIf.libraries.size()
-			|| rIf.files.size()
-			|| rIf.ifs.size() )
+		if ( rIf.data.defines.size()
+			|| rIf.data.includes.size()
+			|| rIf.data.libraries.size()
+			|| rIf.data.files.size()
+			|| rIf.data.ifs.size() )
 		{
 			fprintf (
 				fMakefile,
@@ -603,13 +611,9 @@
 				rIf.value.c_str() );
 			GenerateMacros (
 				"+=",
-				rIf.files,
-				rIf.includes,
-				rIf.defines,
-				rIf.libraries,
+				rIf.data,
 				NULL,
 				NULL,
-				rIf.ifs,
 				cflags_macro,
 				nasmflags_macro,
 				windresflags_macro,
@@ -637,13 +641,9 @@
 {
 	GenerateMacros (
 		"=",
-		module.files,
-		module.includes,
-		module.defines,
-		module.libraries,
+		module.non_if_data,
 		&module.compilerFlags,
 		&module.linkerFlags,
-		module.ifs,
 		cflags_macro,
 		nasmflags_macro,
 		windresflags_macro,
@@ -655,9 +655,10 @@
 	if ( module.importLibrary )
 	{
 		string s;
-		for ( size_t i = 0; i < module.files.size (); i++ )
+		const vector<File*>& files = module.non_if_data.files;
+		for ( size_t i = 0; i < files.size (); i++ )
 		{
-			File& file = *module.files[i];
+			File& file = *files[i];
 			string extension = GetExtension ( file.name );
 			if ( extension == ".spec" || extension == ".SPEC" )
 			{
@@ -991,8 +992,7 @@
 void
 MingwModuleHandler::GenerateObjectFileTargets (
 	const Module& module,
-	const vector<File*>& files,
-	const vector<If*>& ifs,
+	const IfableData& data,
 	const string& cc,
 	const string& cppc,
 	const string& cflagsMacro,
@@ -1002,6 +1002,7 @@
 {
 	size_t i;
 
+	const vector<File*>& files = data.files;
 	for ( i = 0; i < files.size (); i++ )
 	{
 		string sourceFilename = files[i]->name;
@@ -1017,11 +1018,11 @@
 		          "\n" );
 	}
 
+	const vector<If*>& ifs = data.ifs;
 	for ( i = 0; i < ifs.size(); i++ )
 	{
 		GenerateObjectFileTargets ( module,
-		                            ifs[i]->files,
-		                            ifs[i]->ifs,
+		                            ifs[i]->data,
 		                            cc,
 		                            cppc,
 		                            cflagsMacro,
@@ -1042,8 +1043,7 @@
 	string_list& clean_files ) const
 {
 	GenerateObjectFileTargets ( module,
-	                            module.files,
-	                            module.ifs,
+	                            module.non_if_data,
 	                            cc,
 	                            cppc,
 	                            cflagsMacro,
@@ -1054,17 +1054,19 @@
 }
 
 void
-MingwModuleHandler::GetCleanTargets ( string_list& out,
-                                      const vector<File*>& files,
-                                      const vector<If*>& ifs ) const
+MingwModuleHandler::GetCleanTargets (
+	string_list& out,
+	const IfableData& data ) const
 {
 	size_t i;
 
+	const vector<File*>& files = data.files;
 	for ( i = 0; i < files.size(); i++ )
 		out.push_back ( PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( files[i]->name ) ) );
 
+	const vector<If*>& ifs = data.ifs;
 	for ( i = 0; i < ifs.size(); i++ )
-		GetCleanTargets ( out, ifs[i]->files, ifs[i]->ifs );
+		GetCleanTargets ( out, ifs[i]->data );
 }
 
 string
@@ -1405,9 +1407,10 @@
 	string dkNkmLibNoFixup = "dk/nkm/lib";
 	dependencies += FixupTargetFilename ( dkNkmLibNoFixup );
 	PassThruCacheDirectory ( dkNkmLibNoFixup + SSEP );
-	for ( size_t i = 0; i < module.files.size (); i++ )
+	const vector<File*>& files = module.non_if_data.files;
+	for ( size_t i = 0; i < files.size (); i++ )
 	{
-		File& file = *module.files[i];
+		File& file = *files[i];
 		string extension = GetExtension ( file.name );
 		if ( extension == ".spec" || extension == ".SPEC" )
 		{
@@ -1419,27 +1422,14 @@
 	return dependencies;
 }
 
-/*string
-MingwModuleHandler::GetLinkingDependencies ( const Module& module ) const
-{
-	string dependencies = GetImportLibraryDependencies ( module );
-	string s = GetDefinitionDependencies ( module );
-	if ( s.length () > 0 )
-	{
-		dependencies += " ";
-		dependencies += s;
-	}
-	return dependencies;
-}*/
-
 bool
 MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const
 {
-	if ( module.HasFileWithExtensions ( ".cc", ".CC" ) )
+	if ( module.HasFileWithExtension ( module.non_if_data, ".cc" ) )
 		return true;
-	if ( module.HasFileWithExtensions ( ".cxx", ".CXX" ) )
+	if ( module.HasFileWithExtension ( module.non_if_data, ".cxx" ) )
 		return true;
-	if ( module.HasFileWithExtensions ( ".cpp", ".CPP" ) )
+	if ( module.HasFileWithExtension ( module.non_if_data, ".cpp" ) )
 		return true;
 	return false;
 }
@@ -1636,7 +1626,9 @@
 }
 
 void
-MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module, string_list& clean_files )
+MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget (
+	const Module& module,
+	string_list& clean_files )
 {
 	static string ros_junk ( "$(ROS_TEMPORARY)" );
 	string target ( FixupTargetFilename ( module.GetPath () ) );
@@ -1647,7 +1639,7 @@
 
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		GenerateMacrosAndTargetsTarget ( module, clean_files );
 
@@ -1706,7 +1698,7 @@
 
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		string cflags ( "-D__NTDRIVER__" );
 		GenerateMacrosAndTargetsTarget ( module,
@@ -1766,7 +1758,7 @@
 	
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		GenerateMacrosAndTargetsTarget ( module, clean_files );
 
@@ -1822,7 +1814,7 @@
 	
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		string cflags ( "-D__NTAPP__" );
 		GenerateMacrosAndTargetsTarget ( module,
@@ -1878,9 +1870,10 @@
 	          module.name.c_str () );
 	fprintf ( fMakefile, "%s_extractresources: bin2res\n",
 	          module.name.c_str () );
-	for ( size_t i = 0; i < module.files.size (); i++ )
+	const vector<File*>& files = module.non_if_data.files;
+	for ( size_t i = 0; i < files.size (); i++ )
 	{
-		File& file = *module.files[i];
+		File& file = *files[i];
 		string extension = GetExtension ( file.name );
 		if ( extension == ".rc" || extension == ".RC" )
 		{
@@ -1905,7 +1898,7 @@
 
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		GenerateMacrosAndTargetsTarget ( module, clean_files );
 
@@ -1967,7 +1960,7 @@
 
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		GenerateMacrosAndTargetsTarget ( module, clean_files );
 
@@ -2029,7 +2022,7 @@
 
 	GenerateImportLibraryTargetIfNeeded ( module, clean_files );
 
-	if ( module.files.size () > 0 )
+	if ( module.non_if_data.files.size () > 0 )
 	{
 		GenerateMacrosAndTargetsTarget ( module, clean_files );
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-03-09 22:29:18 UTC (rev 13901)
@@ -86,17 +86,12 @@
 	std::string GenerateLinkerParameters ( const Module& module ) const;
 	void GenerateMacro ( const char* assignmentOperation,
 	                     const std::string& macro,
-	                     const std::vector<Include*>& includes,
-	                     const std::vector<Define*>& defines,
+	                     const IfableData& data,
 	                     const std::vector<CompilerFlag*>* compilerFlags ) const;
 	void GenerateMacros ( const char* op,
-	                      const std::vector<File*>& files,
-	                      const std::vector<Include*>& includes,
-	                      const std::vector<Define*>& defines,
-	                      const std::vector<Library*>& libraries,
+	                      const IfableData& data,
 	                      const std::vector<CompilerFlag*>* compilerFlags,
 	                      const std::vector<LinkerFlag*>* linkerFlags,
-	                      const std::vector<If*>& ifs,
 	                      const std::string& cflags_macro,
 	                      const std::string& nasmflags_macro,
 	                      const std::string& windresflags_macro,
@@ -141,8 +136,7 @@
 	                        const std::string& windresflagsMacro,
 	                        string_list& clean_files ) const;
 	void GenerateObjectFileTargets ( const Module& module,
-	                                 const std::vector<File*>& files,
-	                                 const std::vector<If*>& ifs,
+	                                 const IfableData& data,
 	                                 const std::string& cc,
 	                                 const std::string& cppc,
 	                                 const std::string& cflagsMacro,
@@ -157,8 +151,7 @@
 	                                 const std::string& windresflagsMacro,
 	                                 string_list& clean_files ) const;
 	void GetCleanTargets ( string_list& out,
-	                       const std::vector<File*>& files,
-	                       const std::vector<If*>& ifs ) const;
+	                       const IfableData& data ) const;
 	std::string GenerateArchiveTarget ( const Module& module,
 	                                    const std::string& ar,
 	                                    const std::string& objs_macro ) const;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -50,6 +50,40 @@
 	return FixSeparator ( relativeNormalizedPath );
 }
 
+IfableData::~IfableData()
+{
+	size_t i;
+	for ( i = 0; i < files.size(); i++ )
+		delete files[i];
+	for ( i = 0; i < includes.size(); i++ )
+		delete includes[i];
+	for ( i = 0; i < defines.size(); i++ )
+		delete defines[i];
+	for ( i = 0; i < libraries.size(); i++ )
+		delete libraries[i];
+	for ( i = 0; i < properties.size(); i++ )
+		delete properties[i];
+	for ( i = 0; i < ifs.size(); i++ )
+		delete ifs[i];
+}
+
+void IfableData::ProcessXML ()
+{
+	size_t i;
+	for ( i = 0; i < files.size (); i++ )
+		files[i]->ProcessXML ();
+	for ( i = 0; i < includes.size (); i++ )
+		includes[i]->ProcessXML ();
+	for ( i = 0; i < defines.size (); i++ )
+		defines[i]->ProcessXML ();
+	for ( i = 0; i < libraries.size (); i++ )
+		libraries[i]->ProcessXML ();
+	for ( i = 0; i < properties.size(); i++ )
+		properties[i]->ProcessXML ();
+	for ( i = 0; i < ifs.size (); i++ )
+		ifs[i]->ProcessXML ();
+}
+
 Module::Module ( const Project& project,
                  const XMLElement& moduleNode,
                  const string& modulePath )
@@ -99,20 +133,10 @@
 Module::~Module ()
 {
 	size_t i;
-	for ( i = 0; i < files.size(); i++ )
-		delete files[i];
-	for ( i = 0; i < libraries.size(); i++ )
-		delete libraries[i];
-	for ( i = 0; i < includes.size(); i++ )
-		delete includes[i];
-	for ( i = 0; i < defines.size(); i++ )
-		delete defines[i];
 	for ( i = 0; i < invocations.size(); i++ )
 		delete invocations[i];
 	for ( i = 0; i < dependencies.size(); i++ )
 		delete dependencies[i];
-	for ( i = 0; i < ifs.size(); i++ )
-		delete ifs[i];
 	for ( i = 0; i < compilerFlags.size(); i++ )
 		delete compilerFlags[i];
 	for ( i = 0; i < linkerFlags.size(); i++ )
@@ -125,24 +149,15 @@
 	size_t i;
 	for ( i = 0; i < node.subElements.size(); i++ )
 		ProcessXMLSubElement ( *node.subElements[i], path );
-	for ( i = 0; i < files.size (); i++ )
-		files[i]->ProcessXML ();
-	for ( i = 0; i < libraries.size(); i++ )
-		libraries[i]->ProcessXML ();
-	for ( i = 0; i < includes.size(); i++ )
-		includes[i]->ProcessXML ();
-	for ( i = 0; i < defines.size(); i++ )
-		defines[i]->ProcessXML ();
 	for ( i = 0; i < invocations.size(); i++ )
 		invocations[i]->ProcessXML ();
 	for ( i = 0; i < dependencies.size(); i++ )
 		dependencies[i]->ProcessXML ();
-	for ( i = 0; i < ifs.size(); i++ )
-		ifs[i]->ProcessXML();
 	for ( i = 0; i < compilerFlags.size(); i++ )
 		compilerFlags[i]->ProcessXML();
 	for ( i = 0; i < linkerFlags.size(); i++ )
 		linkerFlags[i]->ProcessXML();
+	non_if_data.ProcessXML();
 }
 
 void
@@ -167,18 +182,18 @@
 		}
 		File* pFile = new File ( FixSeparator ( path + CSEP + e.value ), first );
 		if ( pIf )
-			pIf->files.push_back ( pFile );
+			pIf->data.files.push_back ( pFile );
 		else
-			files.push_back ( pFile );
+			non_if_data.files.push_back ( pFile );
 		subs_invalid = true;
 	}
 	else if ( e.name == "library" && e.value.size () )
 	{
-		/*if ( pIf )
-			throw InvalidBuildFileException (
-				e.location,
-				"<library> is not a valid sub-element of <if>" );*/
-		libraries.push_back ( new Library ( e, *this, e.value ) );
+		Library* pLibrary = new Library ( e, *this, e.value );
+		if ( pIf )
+			pIf->data.libraries.push_back ( pLibrary );
+		else
+			non_if_data.libraries.push_back ( pLibrary );
 		subs_invalid = true;
 	}
 	else if ( e.name == "directory" )
@@ -191,18 +206,18 @@
 	{
 		Include* include = new Include ( project, this, e );
 		if ( pIf )
-			pIf->includes.push_back ( include );
+			pIf->data.includes.push_back ( include );
 		else
-			includes.push_back ( include );
+			non_if_data.includes.push_back ( include );
 		subs_invalid = true;
 	}
 	else if ( e.name == "define" )
 	{
 		Define* pDefine = new Define ( project, this, e );
 		if ( pIf )
-			pIf->defines.push_back ( pDefine );
+			pIf->data.defines.push_back ( pDefine );
 		else
-			defines.push_back ( pDefine );
+			non_if_data.defines.push_back ( pDefine );
 		subs_invalid = true;
 	}
 	else if ( e.name == "invoke" )
@@ -241,9 +256,9 @@
 		If* pOldIf = pIf;
 		pIf = new If ( e, project, this );
 		if ( pOldIf )
-			pOldIf->ifs.push_back ( pIf );
+			pOldIf->data.ifs.push_back ( pIf );
 		else
-			ifs.push_back ( pIf );
+			non_if_data.ifs.push_back ( pIf );
 		subs_invalid = false;
 	}
 	else if ( e.name == "compilerflag" )
@@ -483,16 +498,23 @@
 }
 
 bool
-Module::HasFileWithExtensions ( const std::string& extension1,
-	                            const std::string& extension2 ) const
+Module::HasFileWithExtension (
+	const IfableData& data,
+	const std::string& extension ) const
 {
-	for ( size_t i = 0; i < files.size (); i++ )
+	size_t i;
+	for ( i = 0; i < data.files.size (); i++ )
 	{
-		File& file = *files[i];
-		string extension = GetExtension ( file.name );
-		if ( extension == extension1 || extension == extension2 )
+		File& file = *data.files[i];
+		string file_ext = GetExtension ( file.name );
+		if ( !stricmp ( file_ext.c_str (), extension.c_str () ) )
 			return true;
 	}
+	for ( i = 0; i < data.ifs.size (); i++ )
+	{
+		if ( HasFileWithExtension ( data.ifs[i]->data, extension ) )
+			return true;
+	}
 	return false;
 }
 
@@ -756,15 +778,6 @@
 
 If::~If ()
 {
-	size_t i;
-	for ( i = 0; i < files.size(); i++ )
-		delete files[i];
-	for ( i = 0; i < includes.size(); i++ )
-		delete includes[i];
-	for ( i = 0; i < defines.size(); i++ )
-		delete defines[i];
-	for ( i = 0; i < ifs.size(); i++ )
-		delete ifs[i];
 }
 
 void

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-03-09 22:20:41 UTC (rev 13900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-03-09 22:29:18 UTC (rev 13901)
@@ -20,16 +20,8 @@
 	size_t i;
 	for ( i = 0; i < modules.size (); i++ )
 		delete modules[i];
-	for ( i = 0; i < includes.size (); i++ )
-		delete includes[i];
-	for ( i = 0; i < defines.size (); i++ )
-		delete defines[i];
 	for ( i = 0; i < linkerFlags.size (); i++ )
 		delete linkerFlags[i];
-	for ( i = 0; i < properties.size (); i++ )
-		delete properties[i];
-	for ( i = 0; i < ifs.size (); i++ )
-		delete ifs[i];
 	for ( i = 0; i < cdfiles.size (); i++ )
 		delete cdfiles[i];
 	delete head;
@@ -38,9 +30,9 @@
 const Property*
 Project::LookupProperty ( const string& name ) const
 {
-	for ( size_t i = 0; i < properties.size (); i++ )
+	for ( size_t i = 0; i < non_if_data.properties.size (); i++ )
 	{
-		const Property* property = properties[i];
+		const Property* property = non_if_data.properties[i];
 		if ( property->name == name )
 			return property;
 	}
@@ -222,18 +214,11 @@
 		ProcessXMLSubElement ( *node->subElements[i], path );
 	for ( i = 0; i < modules.size (); i++ )
 		modules[i]->ProcessXML ();
-	for ( i = 0; i < includes.size (); i++ )
-		includes[i]->ProcessXML ();
-	for ( i = 0; i < defines.size (); i++ )
-		defines[i]->ProcessXML ();
 	for ( i = 0; i < linkerFlags.size (); i++ )
 		linkerFlags[i]->ProcessXML ();
-	for ( i = 0; i < properties.size(); i++ )
-		properties[i]->ProcessXML ();
-	for ( i = 0; i < ifs.size (); i++ )
-		ifs[i]->ProcessXML ();
[truncated at 1000 lines; 139 more skipped]