add 'location' information to a couple exceptions that should have it
fixed bug I introduced in MingwBackend::ProcessModule()
fixed bug in std::map usage, apparently map<const char*,...> is a bad idea
let make do some work, create variables to hold include list for each module
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h
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/exception.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -422,7 +422,8 @@
 	}
 	if ( required )
 	{
-		throw RequiredAttributeNotFoundException ( attribute,
+		throw RequiredAttributeNotFoundException ( location,
+		                                           attribute,
 		                                           name );
 	}
 	return NULL;
@@ -441,7 +442,8 @@
 	}
 	if ( required )
 	{
-		throw RequiredAttributeNotFoundException ( attribute,
+		throw RequiredAttributeNotFoundException ( location,
+		                                           attribute,
 		                                           name );
 	}
 	return NULL;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -8,25 +8,26 @@
 using std::vector;
 using std::map;
 
-map<const char*,Backend::Factory*>* Backend::Factory::factories = NULL;
+map<string,Backend::Factory*>* Backend::Factory::factories = NULL;
 
 Backend::Factory::Factory ( const std::string& name_ )
 {
 	string name(name_);
 	strlwr ( &name[0] );
 	if ( !factories )
-		factories = new map<const char*,Factory*>;
-	(*factories)[name.c_str()] = this;
+		factories = new map<string,Factory*>;
+	(*factories)[name] = this;
 }
 
 /*static*/ Backend*
-Backend::Factory::Create ( const std::string& name, Project& project )
+Backend::Factory::Create ( const string& name,
+                           Project& project )
 {
 	string sname ( name );
 	strlwr ( &sname[0] );
 	if ( !factories || !factories->size() )
 		throw Exception ( "internal tool error: no registered factories" );
-	Backend::Factory* f = (*factories)[sname.c_str()];
+	Backend::Factory* f = (*factories)[sname];
 	if ( !f )
 	{
 		throw UnknownBackendException ( sname );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h	2005-01-09 03:29:46 UTC (rev 12901)
@@ -12,7 +12,7 @@
 public:
 	class Factory
 	{
-		static std::map<const char*,Factory*>* factories;
+		static std::map<std::string,Factory*>* factories;
 
 	protected:
 
@@ -22,7 +22,8 @@
 		virtual Backend* operator() ( Project& ) = 0;
 
 	public:
-		static Backend* Create ( const std::string& name, Project& project );
+		static Backend* Create ( const std::string& name,
+		                         Project& project );
 
 	private:
 	};

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -90,7 +90,9 @@
 void
 MingwBackend::ProcessModule ( Module& module )
 {
-	MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.name );
+	MingwModuleHandler* h = MingwModuleHandler::LookupHandler (
+		module.node.location,
+		module.stype );
 	h->Process ( module );
 }
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -10,7 +10,7 @@
 using std::vector;
 using std::map;
 
-map<const char*,MingwModuleHandler*>*
+map<string,MingwModuleHandler*>*
 MingwModuleHandler::handler_map = NULL;
 
 FILE*
@@ -21,8 +21,8 @@
 	string moduletype ( moduletype_ );
 	strlwr ( &moduletype[0] );
 	if ( !handler_map )
-		handler_map = new map<const char*,MingwModuleHandler*>;
-	(*handler_map)[moduletype.c_str()] = this;
+		handler_map = new map<string,MingwModuleHandler*>;
+	(*handler_map)[moduletype] = this;
 }
 
 /*static*/ void
@@ -32,16 +32,17 @@
 }
 
 /*static*/ MingwModuleHandler*
-MingwModuleHandler::LookupHandler ( const string& moduletype_ )
+MingwModuleHandler::LookupHandler ( const string& location,
+                                    const string& moduletype_ )
 {
 	string moduletype ( moduletype_ );
 	strlwr ( &moduletype[0] );
 	if ( !handler_map )
 		throw Exception ( "internal tool error: no registered module handlers" );
-	MingwModuleHandler* h = (*handler_map)[moduletype.c_str()];
+	MingwModuleHandler* h = (*handler_map)[moduletype];
 	if ( !h )
 	{
-		throw UnknownModuleTypeException ( moduletype );
+		throw UnknownModuleTypeException ( location, moduletype );
 		return NULL;
 	}
 	return h;
@@ -217,6 +218,16 @@
 	return parameters;
 }
 
+void
+MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const
+{
+	string name ( module.name + "_INCLUDES" );
+	fprintf ( fMakefile,
+	          "%s := %s\n",
+	          name.c_str(),
+	          GenerateGccIncludeParameters(module).c_str() );
+}
+
 string
 MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
 {
@@ -234,12 +245,7 @@
 MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
 {
 	string parameters = GenerateGccDefineParameters ( module );
-	string s = GenerateGccIncludeParameters ( module );
-	if ( s.length () > 0 )
-	{
-		parameters += " ";
-		parameters += s;
-	}
+	parameters += ssprintf(" $(%s_INCLUDES)",module.name.c_str());
 	return parameters;
 }
 
@@ -250,6 +256,8 @@
 	if ( module.files.size () == 0 )
 		return;
 	
+	GenerateGccModuleIncludeVariable ( module );
+
 	for ( size_t i = 0; i < module.files.size (); i++ )
 	{
 		string sourceFilename = module.files[i]->name;
@@ -378,7 +386,7 @@
 	{
 		const Invoke& invoke = *module.invocations[i];
 
-		if ( invoke.invokeModule->type != BuildTool )
+		if ( invoke.invokeModule->etype != BuildTool )
 			throw InvalidBuildFileException ( module.node.location,
 		                                      "Only modules of type buildtool can be invoked." );
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-01-09 03:29:46 UTC (rev 12901)
@@ -6,13 +6,14 @@
 class MingwModuleHandler
 {
 public:
-	static std::map<const char*,MingwModuleHandler*>* handler_map;
+	static std::map<std::string,MingwModuleHandler*>* handler_map;
 
 	MingwModuleHandler ( const char* moduletype_ );
 	virtual ~MingwModuleHandler() {}
 
 	static void SetMakefile ( FILE* f );
-	static MingwModuleHandler* LookupHandler ( const std::string& moduletype_ );
+	static MingwModuleHandler* LookupHandler ( const std::string& location,
+	                                           const std::string& moduletype_ );
 	virtual void Process ( const Module& module ) = 0;
 
 protected:
@@ -42,6 +43,7 @@
 	std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
 	std::string GenerateGccDefineParameters ( const Module& module ) const;
 	std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
+	void GenerateGccModuleIncludeVariable ( const Module& module ) const;
 	std::string GenerateGccIncludeParameters ( const Module& module ) const;
 	std::string GenerateGccParameters ( const Module& module ) const;
 	void GenerateObjectFileTargets ( const Module& module,

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -93,17 +93,23 @@
 }
 
 
-RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName,
-                                                                         const string& elementName )
-	: InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.",
+RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
+	const string& location,
+	const string& attributeName,
+	const string& elementName )
+	: InvalidBuildFileException ( location,
+	                              "Required attribute '%s' not found on '%s'.",
 	                              attributeName.c_str (),
 	                              elementName.c_str ())
 {
 }
 
-InvalidAttributeValueException::InvalidAttributeValueException ( const string& name,
-	                                                             const string& value )
-	: InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.",
+InvalidAttributeValueException::InvalidAttributeValueException (
+	const string& location,
+	const string& name,
+	const string& value )
+	: InvalidBuildFileException ( location,
+	                              "Attribute '%s' has an invalid value '%s'.",
 	                              name.c_str (),
 	                              value.c_str () )
 {
@@ -119,12 +125,14 @@
 
 UnknownBackendException::UnknownBackendException ( const string& name )
 	: Exception ( "Unknown Backend requested: '%s'",
-	             name.c_str() )
+	              name.c_str() )
 {
 }
 
-UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype )
-	: Exception ( "module type requested: '%s'",
-	              moduletype.c_str() )
+UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
+                                                         const string& moduletype )
+	: InvalidBuildFileException ( location,
+	                              "module type requested: '%s'",
+	                              moduletype.c_str() )
 {
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/exception.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/exception.h	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/exception.h	2005-01-09 03:29:46 UTC (rev 12901)
@@ -66,7 +66,8 @@
 class RequiredAttributeNotFoundException : public InvalidBuildFileException
 {
 public:
-	RequiredAttributeNotFoundException ( const std::string& attributeName,
+	RequiredAttributeNotFoundException ( const std::string& location,
+	                                     const std::string& attributeName,
 	                                     const std::string& elementName );
 };
 
@@ -74,7 +75,8 @@
 class InvalidAttributeValueException : public InvalidBuildFileException
 {
 public:
-	InvalidAttributeValueException ( const std::string& name,
+	InvalidAttributeValueException ( const std::string& location,
+	                                 const std::string& name,
 	                                 const std::string& value );
 };
 
@@ -92,10 +94,11 @@
 	UnknownBackendException ( const std::string& name );
 };
 
-class UnknownModuleTypeException : public Exception
+class UnknownModuleTypeException : public InvalidBuildFileException
 {
 public:
-	UnknownModuleTypeException ( const std::string& moduletype );
+	UnknownModuleTypeException ( const std::string& location,
+	                             const std::string& moduletype );
 };
 
 #endif /* __EXCEPTION_H */

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -38,7 +38,9 @@
 
 	att = moduleNode.GetAttribute ( "type", true );
 	assert(att);
-	type = GetModuleType ( *att );
+	stype = att->value;
+	strlwr ( &stype[0] );
+	etype = GetModuleType ( node.location, *att );
 
 	att = moduleNode.GetAttribute ( "extension", false );
 	if (att != NULL)
@@ -136,7 +138,7 @@
 }
 
 ModuleType
-Module::GetModuleType ( const XMLAttribute& attribute )
+Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
 {
 	if ( attribute.value == "buildtool" )
 		return BuildTool;
@@ -144,14 +146,15 @@
 		return StaticLibrary;
 	if ( attribute.value == "kernelmodedll" )
 		return KernelModeDLL;
-	throw InvalidAttributeValueException ( attribute.name,
+	throw InvalidAttributeValueException ( location,
+	                                       attribute.name,
 	                                       attribute.value );
 }
 
 string
 Module::GetDefaultModuleExtension () const
 {
-	switch (type)
+	switch (etype)
 	{
 		case BuildTool:
 			return EXEPOSTFIX;
@@ -264,7 +267,7 @@
 				module.name.c_str(),
 				att->value.c_str() );
 	}
-	
+
 	for ( size_t i = 0; i < node.subElements.size (); i++ )
 		ProcessXMLSubElement ( *node.subElements[i] );
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-09 03:29:46 UTC (rev 12901)
@@ -39,7 +39,7 @@
 	std::vector<Module*> modules;
 	std::vector<Include*> includes;
 	std::vector<Define*> defines;
-	
+
 	Project ();
 	Project ( const std::string& filename );
 	~Project ();
@@ -71,19 +71,21 @@
 	std::string name;
 	std::string extension;
 	std::string path;
-	ModuleType type;
+	ModuleType etype;
+	std::string stype;
 	std::vector<File*> files;
 	std::vector<Library*> libraries;
 	std::vector<Include*> includes;
 	std::vector<Define*> defines;
 	std::vector<Invoke*> invocations;
 	std::vector<Dependency*> dependencies;
-	
+
 	Module ( const Project& project,
 	         const XMLElement& moduleNode,
 	         const std::string& modulePath );
 	~Module ();
-	ModuleType GetModuleType (const XMLAttribute& attribute );
+	ModuleType GetModuleType ( const std::string& location,
+	                           const XMLAttribute& attribute );
 	std::string GetBasePath() const;
 	std::string GetPath () const;
 	std::string GetTargets () const;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp	2005-01-09 01:58:53 UTC (rev 12900)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/moduletest.cpp	2005-01-09 03:29:46 UTC (rev 12901)
@@ -9,7 +9,7 @@
 	ARE_EQUAL(2, project.modules.size());
 
 	Module& module1 = *project.modules[0];
-	IS_TRUE(module1.type == BuildTool);
+	IS_TRUE(module1.etype == BuildTool);
 	ARE_EQUAL(2, module1.files.size());
 	ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name);
 	ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name);
@@ -17,7 +17,7 @@
 	ARE_EQUAL(0, module1.libraries.size());
 
 	Module& module2 = *project.modules[1];
-	IS_TRUE(module2.type == KernelModeDLL);
+	IS_TRUE(module2.etype == KernelModeDLL);
 	ARE_EQUAL(2, module2.files.size());
 	ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name);
 	ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);