Support compilerflag within IFs
Modified: branches/xmlbuildsystem/reactos/ntoskrnl/rtl/misc.c
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
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/compilerflag.cpp
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/rbuild.txt
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/if.xml
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/iftest.cpp

Modified: branches/xmlbuildsystem/reactos/ntoskrnl/rtl/misc.c
--- branches/xmlbuildsystem/reactos/ntoskrnl/rtl/misc.c	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/ntoskrnl/rtl/misc.c	2005-05-13 19:17:44 UTC (rev 15267)
@@ -1,4 +1,4 @@
-/* $Id:$
+/* $Id$
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -393,6 +393,15 @@
 		fMakefile,
 		"PROJECT_CFLAGS %s",
 		assignmentOperation );
+	
+	for ( i = 0; i < data.compilerFlags.size(); i++ )
+	{
+		fprintf (
+			fMakefile,
+			" %s",
+			data.compilerFlags[i]->flag.c_str() );
+	}
+
 	for ( i = 0; i < data.includes.size(); i++ )
 	{
 		fprintf (
@@ -432,7 +441,7 @@
 			prop.value.c_str() );
 	}
 
-	if ( data.includes.size() || data.defines.size() )
+	if ( data.includes.size() || data.defines.size() || data.compilerFlags.size() )
 	{
 		GenerateProjectCFlagsMacro ( assignmentOperation,
 		                             data );
@@ -443,6 +452,7 @@
 		If& rIf = *data.ifs[i];
 		if ( rIf.data.defines.size()
 			|| rIf.data.includes.size()
+			|| rIf.data.compilerFlags.size()
 			|| rIf.data.ifs.size() )
 		{
 			fprintf (

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -562,7 +562,6 @@
 	return parameters;
 }
 
-
 string
 MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
 {
@@ -618,8 +617,7 @@
 MingwModuleHandler::GenerateMacro (
 	const char* assignmentOperation,
 	const string& macro,
-	const IfableData& data,
-	const vector<CompilerFlag*>* compilerFlags )
+	const IfableData& data )
 {
 	size_t i;
 
@@ -629,16 +627,13 @@
 		macro.c_str(),
 		assignmentOperation );
 	
-	if ( compilerFlags != NULL )
+	string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags );
+	if ( compilerParameters.size () > 0 )
 	{
-		string compilerParameters = GenerateCompilerParametersFromVector ( *compilerFlags );
-		if ( compilerParameters.size () > 0 )
-		{
-			fprintf (
-				fMakefile,
-				" %s",
-				compilerParameters.c_str () );
-		}
+		fprintf (
+			fMakefile,
+			" %s",
+			compilerParameters.c_str () );
 	}
 
 	for ( i = 0; i < data.includes.size(); i++ )
@@ -668,21 +663,18 @@
 MingwModuleHandler::GenerateMacros (
 	const char* assignmentOperation,
 	const IfableData& data,
-	const vector<CompilerFlag*>* compilerFlags,
 	const vector<LinkerFlag*>* linkerFlags )
 {
 	size_t i;
 
-	if ( data.includes.size () > 0 || data.defines.size () > 0 )
+	if ( data.includes.size () > 0 || data.defines.size () > 0 || data.compilerFlags.size () > 0 )
 	{
 		GenerateMacro ( assignmentOperation,
 		                cflagsMacro,
-		                data,
-		                compilerFlags );
+		                data );
 		GenerateMacro ( assignmentOperation,
 		                windresflagsMacro,
-		                data,
-		                compilerFlags );
+		                data );
 	}
 	
 	if ( linkerFlags != NULL )
@@ -721,6 +713,7 @@
 			|| rIf.data.includes.size()
 			|| rIf.data.libraries.size()
 			|| rIf.data.files.size()
+			|| rIf.data.compilerFlags.size()
 			|| rIf.data.ifs.size() )
 		{
 			fprintf (
@@ -731,7 +724,6 @@
 			GenerateMacros (
 				"+=",
 				rIf.data,
-				NULL,
 				NULL );
 			fprintf ( 
 				fMakefile,
@@ -744,7 +736,6 @@
 MingwModuleHandler::GenerateObjectMacros (
 	const char* assignmentOperation,
 	const IfableData& data,
-	const vector<CompilerFlag*>* compilerFlags,
 	const vector<LinkerFlag*>* linkerFlags )
 {
 	size_t i;
@@ -794,6 +785,7 @@
 			|| rIf.data.includes.size()
 			|| rIf.data.libraries.size()
 			|| rIf.data.files.size()
+			|| rIf.data.compilerFlags.size()
 			|| rIf.data.ifs.size() )
 		{
 			fprintf (
@@ -804,7 +796,6 @@
 			GenerateObjectMacros (
 				"+=",
 				rIf.data,
-				NULL,
 				NULL );
 			fprintf ( 
 				fMakefile,
@@ -1531,7 +1522,6 @@
 	GenerateObjectMacros (
 		"=",
 		module.non_if_data,
-		&module.compilerFlags,
 		&module.linkerFlags );
 
 	// future references to the macro will be to get its values
@@ -1561,7 +1551,6 @@
 	GenerateMacros (
 		"=",
 		module.non_if_data,
-		&module.compilerFlags,
 		&module.linkerFlags );
 
 	if ( module.importLibrary )

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-05-13 19:17:44 UTC (rev 15267)
@@ -109,15 +109,12 @@
 	std::string GenerateLinkerParameters () const;
 	void GenerateMacro ( const char* assignmentOperation,
 	                     const std::string& macro,
-	                     const IfableData& data,
-	                     const std::vector<CompilerFlag*>* compilerFlags );
+	                     const IfableData& data );
 	void GenerateMacros ( const char* op,
 	                      const IfableData& data,
-	                      const std::vector<CompilerFlag*>* compilerFlags,
 	                      const std::vector<LinkerFlag*>* linkerFlags );
 	void GenerateObjectMacros ( const char* assignmentOperation,
 	                            const IfableData& data,
-	                            const std::vector<CompilerFlag*>* compilerFlags,
 	                            const std::vector<LinkerFlag*>* linkerFlags );
 	std::string GenerateGccIncludeParameters () const;
 	std::string GenerateGccParameters () const;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/compilerflag.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/compilerflag.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/compilerflag.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -32,11 +32,6 @@
 void
 CompilerFlag::Initialize ()
 {
-}
-
-void
-CompilerFlag::ProcessXML ()
-{
 	if (node.value.size () == 0)
 	{
 		throw InvalidBuildFileException (
@@ -45,3 +40,8 @@
 	}
 	flag = node.value;
 }
+
+void
+CompilerFlag::ProcessXML ()
+{
+}

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -100,6 +100,8 @@
 		delete libraries[i];
 	for ( i = 0; i < properties.size(); i++ )
 		delete properties[i];
+	for ( i = 0; i < compilerFlags.size(); i++ )
+		delete compilerFlags[i];
 	for ( i = 0; i < ifs.size(); i++ )
 		delete ifs[i];
 }
@@ -117,6 +119,8 @@
 		libraries[i]->ProcessXML ();
 	for ( i = 0; i < properties.size(); i++ )
 		properties[i]->ProcessXML ();
+	for ( i = 0; i < compilerFlags.size(); i++ )
+		compilerFlags[i]->ProcessXML ();
 	for ( i = 0; i < ifs.size (); i++ )
 		ifs[i]->ProcessXML ();
 }
@@ -390,7 +394,11 @@
 	}
 	else if ( e.name == "compilerflag" )
 	{
-		compilerFlags.push_back ( new CompilerFlag ( project, this, e ) );
+		CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
+		if ( pIf )
+			pIf->data.compilerFlags.push_back ( pCompilerFlag );
+		else
+			non_if_data.compilerFlags.push_back ( pCompilerFlag );
 		subs_invalid = true;
 	}
 	else if ( e.name == "linkerflag" )

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -285,6 +285,15 @@
 			non_if_data.defines.push_back ( define );
 		subs_invalid = true;
 	}
+	else if ( e.name == "compilerflag" )
+	{
+		CompilerFlag* pCompilerFlag = new CompilerFlag ( *this, e );
+		if ( pIf )
+			pIf->data.compilerFlags.push_back ( pCompilerFlag );
+		else
+			non_if_data.compilerFlags.push_back ( pCompilerFlag );
+		subs_invalid = true;
+	}
 	else if ( e.name == "linkerflag" )
 	{
 		linkerFlags.push_back ( new LinkerFlag ( *this, e ) );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-05-13 19:17:44 UTC (rev 15267)
@@ -73,6 +73,7 @@
 	std::vector<Define*> defines;
 	std::vector<Library*> libraries;
 	std::vector<Property*> properties;
+	std::vector<CompilerFlag*> compilerFlags;
 	std::vector<If*> ifs;
 
 	~IfableData();

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.txt
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.txt	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.txt	2005-05-13 19:17:44 UTC (rev 15267)
@@ -310,7 +310,7 @@
 	None.
 
 Elements:
-	define, directory, file, if, include, property.
+	compilerflag, define, directory, file, if, include, property.
 
 
 Importlibrary element

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/test.h	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/test.h	2005-05-13 19:17:44 UTC (rev 15267)
@@ -97,6 +97,9 @@
 {
 public:
 	void Run ();
+private:
+	void TestProjectIf ( Project& project );
+	void TestModuleIf ( Project& project );
 };
 
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/if.xml
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/if.xml	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/data/if.xml	2005-05-13 19:17:44 UTC (rev 15267)
@@ -1,7 +1,11 @@
 <?xml version="1.0" ?>
 <project name="Project" makefile="Makefile">
+	<if property="VAR1" value="value1">
+		<compilerflag>compilerflag1</compilerflag>
+	</if>
 	<module name="module1" type="buildtool">
-		<if property="VAR1" value="value1">
+		<if property="VAR2" value="value2">
+			<compilerflag>compilerflag2</compilerflag>
 			<file>file1.c</file>
 		</if>
 		<file>file2.c</file>

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/iftest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/iftest.cpp	2005-05-13 19:01:46 UTC (rev 15266)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/iftest.cpp	2005-05-13 19:17:44 UTC (rev 15267)
@@ -2,18 +2,29 @@
 
 using std::string;
 
-void IfTest::Run()
+void
+IfTest::TestProjectIf ( Project& project )
 {
-	string projectFilename ( RBUILD_BASE "tests/data/if.xml" );
-	Project project ( projectFilename );
+	ARE_EQUAL ( 1, project.non_if_data.ifs.size () );
+	If& if1 = *project.non_if_data.ifs[0];
+	ARE_EQUAL ( "VAR1", if1.property );
+	ARE_EQUAL ( "value1", if1.value );
 
+	ARE_EQUAL ( 1, if1.data.compilerFlags.size () );
+	CompilerFlag& compilerFlag1 = *if1.data.compilerFlags[0];
+	ARE_EQUAL( "compilerflag1", compilerFlag1.flag );
+}
+
+void
+IfTest::TestModuleIf ( Project& project )
+{
 	ARE_EQUAL ( 1, project.modules.size () );
 	Module& module1 = *project.modules[0];
 
 	ARE_EQUAL ( 1, module1.non_if_data.ifs.size () );
 	If& if1 = *module1.non_if_data.ifs[0];
-	ARE_EQUAL ( "VAR1", if1.property );
-	ARE_EQUAL ( "value1", if1.value );
+	ARE_EQUAL ( "VAR2", if1.property );
+	ARE_EQUAL ( "value2", if1.value );
 
 	ARE_EQUAL ( 1, if1.data.files.size () );
 	File& file1 = *if1.data.files[0];
@@ -22,4 +33,18 @@
 	ARE_EQUAL ( 1, module1.non_if_data.files.size () );
 	File& file2 = *module1.non_if_data.files[0];
 	ARE_EQUAL( SSEP "file2.c", file2.name );
+
+	ARE_EQUAL ( 1, if1.data.compilerFlags.size () );
+	CompilerFlag& compilerFlag2 = *if1.data.compilerFlags[0];
+	ARE_EQUAL( "compilerflag2", compilerFlag2.flag );
 }
+
+void
+IfTest::Run ()
+{
+	string projectFilename ( RBUILD_BASE "tests/data/if.xml" );
+	Project project ( projectFilename );
+
+	TestProjectIf ( project );
+	TestModuleIf ( project );
+}